Skip to content

Commit

Permalink
corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
chloeYue committed Sep 18, 2024
1 parent 83e4ff0 commit 4ef6cc7
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 122 deletions.
65 changes: 0 additions & 65 deletions test/e2e/accounts/forgot-password.spec.ts

This file was deleted.

13 changes: 13 additions & 0 deletions test/e2e/page-objects/pages/account-list-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ class AccountListPage {
'.multichain-account-menu-popover__list--menu-item-hidden-account [data-testid="account-list-item-menu-button"]';
}

async check_pageIsLoaded(): Promise<void> {
try {
await this.driver.waitForMultipleSelectors([
this.accountListItem,
this.accountOptionsMenuButton,
]);
} catch (e) {
console.log('Timeout while waiting for account list to be loaded', e);
throw e;
}
console.log('Account list is loaded');
}

async hideAccount(): Promise<void> {
console.log(`Hide account in account list`);
await this.driver.clickElement(this.hideUnhideAccountButton);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/page-objects/pages/login-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LoginPage {
this.forgotPasswordButton = {
text: 'Forgot password?',
tag: 'a',
}
};
}

async check_pageIsLoaded(): Promise<void> {
Expand Down
47 changes: 38 additions & 9 deletions test/e2e/page-objects/pages/reset-password-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,51 @@ import { Driver } from '../../webdriver/driver';
class ResetPasswordPage {
private driver: Driver;

private seedPhraseInput: string;

private passwordInput: string;

private confirmPasswordInput: string;

private restoreButton: string;

constructor(driver: Driver) {
this.driver = driver;
this.seedPhraseInput = '[data-testid="import-srp__srp-word-0"]';
this.passwordInput = '[data-testid="create-vault-password"]';
this.confirmPasswordInput = '[data-testid="create-vault-confirm-password"]';
this.restoreButton = '[data-testid="create-new-vault-submit-button"]';
}

async check_pageIsLoaded(): Promise<void> {
try {
await this.driver.waitForMultipleSelectors([
this.passwordInput,
this.confirmPasswordInput,
]);
} catch (e) {
console.log(
'Timeout while waiting for reset password page to be loaded',
e,
);
throw e;
}
console.log('Reset password page is loaded');
}

/**
* Resets the password using the provided seed phrase and new password.
*
* @param seedPhrase - The seed phrase to verify account ownership
* @param newPassword - The new password to set for the account
*/
async resetPassword(seedPhrase: string, newPassword: string): Promise<void> {
console.log('Resetting password');
await this.driver.pasteIntoField(
'[data-testid="import-srp__srp-word-0"]',
seedPhrase,
);
await this.driver.fill('#password', newPassword);
await this.driver.fill('#confirm-password', newPassword);
await this.driver.press('#confirm-password', this.driver.Key.ENTER);
console.log(`Resetting password with new password: ${newPassword}`);
await this.driver.pasteIntoField(this.seedPhraseInput, seedPhrase);
await this.driver.fill(this.passwordInput, newPassword);
await this.driver.fill(this.confirmPasswordInput, newPassword);
await this.driver.clickElement(this.restoreButton);
}

}

export default ResetPasswordPage;
1 change: 1 addition & 0 deletions test/e2e/tests/account/account-hide-unhide.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('Account list - hide/unhide functionality', function (this: Suite) {

// hide account
const accountListPage = new AccountListPage(driver);
await accountListPage.check_pageIsLoaded();
await accountListPage.openAccountOptionsMenu();
await accountListPage.hideAccount();
await accountListPage.check_hiddenAccountsListExists();
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/tests/account/account-pin-unpin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('Account list - pin/unpin functionality', function (this: Suite) {

// pin account
const accountListPage = new AccountListPage(driver);
await accountListPage.check_pageIsLoaded();
await accountListPage.openAccountOptionsMenu();
await accountListPage.pinAccount();
await accountListPage.check_accountIsPinned();
Expand All @@ -45,6 +46,7 @@ describe('Account list - pin/unpin functionality', function (this: Suite) {

// pin account
const accountListPage = new AccountListPage(driver);
await accountListPage.check_pageIsLoaded();
await accountListPage.openAccountOptionsMenu();
await accountListPage.pinAccount();
await accountListPage.check_accountIsPinned();
Expand Down
11 changes: 3 additions & 8 deletions test/e2e/tests/account/forgot-password.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
withFixtures,
TEST_SEED_PHRASE_TWO,
} from '../../helpers';
import { withFixtures } from '../../helpers';
import FixtureBuilder from '../../fixture-builder';
import { E2E_SRP } from '../../default-fixture';
import { Driver } from '../../webdriver/driver';
import HomePage from '../../page-objects/pages/homepage';
import LoginPage from '../../page-objects/pages/login-page';
Expand All @@ -29,10 +27,7 @@ describe('Forgot password', function () {
await new LoginPage(driver).gotoResetPasswordPage();

// Reset password with a new password
await new ResetPasswordPage(driver).resetPassword(
TEST_SEED_PHRASE_TWO,
newPassword,
);
await new ResetPasswordPage(driver).resetPassword(E2E_SRP, newPassword);

// Lock wallet again
await homePage.headerNavbar.lockMetaMask();
Expand Down
39 changes: 0 additions & 39 deletions test/e2e/tests/account/migrate-old-vault.spec.js

This file was deleted.

0 comments on commit 4ef6cc7

Please sign in to comment.