Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1525 e2e import wallet internal #1184

Open
wants to merge 8 commits into
base: TW-1446-epic-evm-account-management
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion e2e/src/page-objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ import { SwapPage } from '../page-objects/pages/swap.page';
import { OperationStatusAlert } from './pages/alerts/operation-status.alert';
import { DelegateFormPage } from './pages/delegate-form.page';
import { DelegateTab } from './pages/delegate-tab.page';
import { ImportAccountPrivateKeyTab } from './pages/import-account-tabs/import-account-private-key-tab.page';
import { ImportAccountMnemonicTab } from './pages/import-account-tabs/import-account-wallet-from-seed-tab.page';
import { ImportAccountWatchOnlyTab } from './pages/import-account-tabs/import-account-watch-only-tab.page';
import { ImportExistingWalletPage } from './pages/importing-existing-wallet.page';
import { InternalConfirmationPage } from './pages/internal-confirmation.page';
import { AddNewWalletListPage } from './pages/lists/add-new-wallet-list.page';
import { AccountsModalPage } from './pages/modal/accounts-modal.page';
import { ManualBackupModalPage } from './pages/modal/manual-backup-modal.page';
import { NewsletterModalPage } from './pages/modal/newsletter-modal.page';
import { OnRumModalPage } from './pages/modal/on-rum-modal.page';
Expand Down Expand Up @@ -50,5 +55,10 @@ export const Pages = {
GeneralSettings: new GeneralSettingsPage(),
ManualBackupModal: new ManualBackupModalPage(),
BackupOptionsModal: new BackupOptionsModalPage(),
Home: new HomePage()
Home: new HomePage(),
AccountsModal: new AccountsModalPage(),
AddNewWalletList: new AddNewWalletListPage(),
ImportAccountMnemonicTab: new ImportAccountMnemonicTab(),
ImportAccountPrivateKeyTab: new ImportAccountPrivateKeyTab(),
ImportAccountWatchOnlyTab: new ImportAccountWatchOnlyTab()
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ImportAccountSelectors } from 'src/app/pages/ImportAccount/selectors';

import { Page } from '../../../classes/page.class';
import { createPageElement, findElements } from '../../../utils/search.utils';

export class ImportAccountMnemonicTab extends Page {
mnemonicWordInput = createPageElement(ImportAccountSelectors.mnemonicWordInput);
mnemonicPasswordField = createPageElement(ImportAccountSelectors.mnemonicPasswordInput);
mnemonicImportButton = createPageElement(ImportAccountSelectors.mnemonicImportButton);

async isVisible() {
await this.mnemonicWordInput.waitForDisplayed();
await this.mnemonicPasswordField.waitForDisplayed();
await this.mnemonicImportButton.waitForDisplayed();
}

async enterSeedPhrase(seedPhrase: string) {
const wordsArray = seedPhrase.split(' ');
const wordsInputs = await findElements(ImportAccountSelectors.mnemonicWordInput);

for (let i = 0; i < wordsArray.length; i++) {
const word = wordsArray[i];
const input = wordsInputs[i];

await input.fill(word);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ImportAccountSelectors } from 'src/app/pages/ImportAccount/selectors';

import { Page } from '../../../classes/page.class';
import { createPageElement } from '../../../utils/search.utils';

export class ImportAccountPrivateKeyTab extends Page {
privateKeyInput = createPageElement(ImportAccountSelectors.privateKeyInput);
privateKeyImportButton = createPageElement(ImportAccountSelectors.privateKeyImportButton);

async isVisible() {
await this.privateKeyInput.waitForDisplayed();
await this.privateKeyImportButton.waitForDisplayed();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Locator } from '@playwright/test';
import { ImportAccountSelectors } from 'src/app/pages/ImportAccount/selectors';

import { Page } from '../../../classes/page.class';
import { createPageElement, findElements, getElementText } from '../../../utils/search.utils';

export class ImportAccountTab extends Page {
tabSwitcher = createPageElement(ImportAccountSelectors.tabSwitcher);

async isVisible() {
await this.tabSwitcher.waitForDisplayed();
}
async selectTab(tabName: string) {
const tabElements = await findElements(ImportAccountSelectors.tabSwitcher);

for (const tabElement of tabElements) {
const getTabValue = await tabElement.textContent();

if (getTabValue === tabName) {
await tabElement.click();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ImportAccountSelectors } from 'src/app/pages/ImportAccount/selectors';

import { Page } from '../../../classes/page.class';
import { createPageElement, findElements } from '../../../utils/search.utils';

export class ImportAccountMnemonicTab extends Page {
walletFromMnemonicWordInput = createPageElement(ImportAccountSelectors.walletFromMnemonicWordInput);
walletFromMnemonicImportButton = createPageElement(ImportAccountSelectors.walletFromMnemonicImportButton);

async isVisible() {
await this.walletFromMnemonicWordInput.waitForDisplayed();
await this.walletFromMnemonicImportButton.waitForDisplayed();
}

async enterSeedPhrase(seedPhrase: string) {
const wordsArray = seedPhrase.split(' ');
const wordsInputs = await findElements(ImportAccountSelectors.walletFromMnemonicWordInput);

for (let i = 0; i < wordsArray.length; i++) {
const word = wordsArray[i];
const input = wordsInputs[i];

await input.fill(word);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ImportAccountSelectors } from 'src/app/pages/ImportAccount/selectors';

import { Page } from '../../../classes/page.class';
import { createPageElement } from '../../../utils/search.utils';

export class ImportAccountWatchOnlyTab extends Page {
watchOnlyInput = createPageElement(ImportAccountSelectors.watchOnlyInput);
watchOnlyImportButton = createPageElement(ImportAccountSelectors.watchOnlyImportButton);

async isVisible() {
await this.watchOnlyInput.waitForDisplayed();
await this.watchOnlyImportButton.waitForDisplayed();
}
}
18 changes: 18 additions & 0 deletions e2e/src/page-objects/pages/lists/add-new-wallet-list.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NewWalletActionsPopperSelectors } from 'src/app/templates/NewWalletActionsPopper/selectors';

import { Page } from '../../../classes/page.class';
import { createPageElement } from '../../../utils/search.utils';

export class AddNewWalletListPage extends Page {
createWallet = createPageElement(NewWalletActionsPopperSelectors.createWallet);
importWallet = createPageElement(NewWalletActionsPopperSelectors.importWallet);
ledgerConnect = createPageElement(NewWalletActionsPopperSelectors.ledgerConnect);
watchOnlyAccount = createPageElement(NewWalletActionsPopperSelectors.watchOnlyAccount);

async isVisible() {
await this.createWallet.waitForDisplayed();
await this.importWallet.waitForDisplayed();
await this.ledgerConnect.waitForDisplayed();
await this.watchOnlyAccount.waitForDisplayed();
}
}
Empty file.
27 changes: 27 additions & 0 deletions e2e/src/page-objects/pages/manual-backup-modal.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ManualBackupModalSelectors } from 'src/app/templates/ManualBackupModal/selectors';

import { Page } from '../../classes/page.class';
import { createPageElement } from '../../utils/search.utils';

export class ManualBackupModalPage extends Page {
confirmButton = createPageElement(ManualBackupModalSelectors.confirmButton);
cancelButton = createPageElement(ManualBackupModalSelectors.cancelButton);
notedDownButton = createPageElement(ManualBackupModalSelectors.notedDownButton);
protectedMask = createPageElement(ManualBackupModalSelectors.protectedMask);
wordIndex = createPageElement(ManualBackupModalSelectors.wordIndex);
seedWordButton = createPageElement(ManualBackupModalSelectors.seedWordButton);

async isVisible(modalPage: string) {
if (modalPage == 'Backup your Seed Phrase') {
await this.notedDownButton.waitForDisplayed();
await this.protectedMask.waitForDisplayed();
}

if (modalPage == 'Verify Seed Phrase') {
await this.confirmButton.waitForDisplayed();
await this.cancelButton.waitForDisplayed();
await this.wordIndex.waitForDisplayed();
await this.seedWordButton.waitForDisplayed();
}
}
}
18 changes: 18 additions & 0 deletions e2e/src/page-objects/pages/modal/accounts-modal.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { AccountsModalSelectors } from 'src/app/templates/AppHeader/selectors';

import { Page } from '../../../classes/page.class';
import { createPageElement } from '../../../utils/search.utils';

export class AccountsModalPage extends Page {
searchField = createPageElement(AccountsModalSelectors.searchField);
accountsManagementButton = createPageElement(AccountsModalSelectors.accountsManagementButton);
newWalletActionsButton = createPageElement(AccountsModalSelectors.newWalletActionsButton);
cancelButton = createPageElement(AccountsModalSelectors.cancelButton);

async isVisible() {
await this.searchField.waitForDisplayed();
await this.accountsManagementButton.waitForDisplayed();
await this.newWalletActionsButton.waitForDisplayed();
await this.cancelButton.waitForDisplayed();
}
}
21 changes: 21 additions & 0 deletions e2e/src/tests/import-wallet-internal.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test } from '../fixtures/extension';
import { describeScenario } from '../fixtures/hooks';
import { Pages } from '../page-objects';
import { envVars } from '../utils/env.utils';
import { importWalletPrecondition } from '../utils/shared.utils';
import { sleep } from '../utils/timing.utils';

describeScenario('Import Wallet Internal @internal', () => {
test('Import Wallet Internal: positive scenario', async () => {
await importWalletPrecondition();

await Pages.Home.accountIcon.click();
await Pages.AccountsModal.isVisible();
await Pages.AccountsModal.newWalletActionsButton.click();
await Pages.AddNewWalletList.isVisible();
await Pages.AddNewWalletList.importWallet.click();
await Pages.ImportAccountMnemonicTab.enterSeedPhrase(envVars.IMPORTED_HD_ACCOUNT_SEED_PHRASE);
await Pages.ImportAccountMnemonicTab.walletFromMnemonicImportButton.click();
await sleep(5000);
});
});
6 changes: 6 additions & 0 deletions e2e/src/utils/search.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,9 @@ export class PageElement {
return await element.innerText({ timeout });
}
}

export const getElementText = async (selector: string) => {
const element = await findElement(selector);

return await element.textContent();
};
17 changes: 17 additions & 0 deletions e2e/src/utils/shared.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { CustomBrowserContext } from '../classes/browser-context.class';
import { Pages } from '../page-objects';

import { envVars } from './env.utils';

export const switchToPage = async (pageUrl: string) => {
const pages = CustomBrowserContext.browser.pages();
Expand All @@ -11,3 +14,17 @@ export const switchToPage = async (pageUrl: string) => {
}
}
};

export const importWalletPrecondition = async () => {
await Pages.Welcome.importExistingWalletButton.waitForDisplayed();
await Pages.Welcome.importExistingWalletButton.click();
await Pages.ImportExistingWallet.enterSeedPhrase(envVars.DEFAULT_HD_ACCOUNT_SEED_PHRASE);
await Pages.ImportExistingWallet.nextButton.click();

await Pages.SetWallet.passwordField.fill(envVars.DEFAULT_PASSWORD);
await Pages.SetWallet.repeatPasswordField.fill(envVars.DEFAULT_PASSWORD);
await Pages.SetWallet.acceptTerms.click();
await Pages.SetWallet.importButton.click();

await Pages.NewsletterModal.closeButton.click();
};
5 changes: 4 additions & 1 deletion src/app/pages/ImportAccount/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export enum ImportAccountSelectors {
fundraiserImportButton = 'Import Account(Fundraiser)/Import Button',

managedContractInput = 'Import Account(ManagedKT)/Managed Contract Input',
managedKTImportButton = 'Import Account(ManagedKT)/Import Account Button'
managedKTImportButton = 'Import Account(ManagedKT)/Import Account Button',

walletFromMnemonicWordInput = 'Import Account(Mnemonic)/Wallet From Mnemonic Word Input',
walletFromMnemonicImportButton = 'Import Account(Mnemonic)/Wallet From Mnemonic Import Button'
}

export enum ImportAccountFormType {
Expand Down
3 changes: 3 additions & 0 deletions src/app/pages/ImportAccount/wallet-from-mnemonic-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { T, t } from 'lib/i18n';
import { useTempleClient } from 'lib/temple/front';

import { defaultNumberOfWords } from './constants';
import { ImportAccountSelectors } from './selectors';

export const WalletFromMnemonicForm = memo(() => {
const { createOrImportWallet } = useTempleClient();
Expand Down Expand Up @@ -70,6 +71,7 @@ export const WalletFromMnemonicForm = memo(() => {
reset={reset}
numberOfWords={numberOfWords}
setNumberOfWords={setNumberOfWords}
testID={ImportAccountSelectors.walletFromMnemonicWordInput}
/>

<Button
Expand All @@ -79,6 +81,7 @@ export const WalletFromMnemonicForm = memo(() => {
(isSubmitting || Boolean(error)) && 'opacity-75'
)}
onClick={handleSubmit}
testID={ImportAccountSelectors.walletFromMnemonicImportButton}
>
<T id="importYourWallet" />
</Button>
Expand Down
Loading