From df15b835be3d24e94bdf447a8e8d1afbbeca7aff Mon Sep 17 00:00:00 2001 From: Yarmosh01 Date: Wed, 15 Feb 2023 03:22:17 +0200 Subject: [PATCH 01/12] easy-done --- .../src/classes/browser-context.class.ts | 2 ++ .../import-account-by-mnemonic.feature | 3 +-- .../import-account-by-private-key.feature | 21 +++++++++++++++++++ .../extension-e2e/src/hooks/after-all.hook.ts | 2 +- .../add-new-account-by-private-key.page.ts | 11 ++++++++++ apps/extension-e2e/src/page-objects/index.ts | 4 +++- .../src/step-definitions/common.steps.ts | 2 +- apps/extension-e2e/src/utils/input.utils.ts | 3 +++ .../private-key/private-key.test-ids.ts | 4 ++++ .../components/private-key/private-key.tsx | 3 +++ 10 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 apps/extension-e2e/src/features/import-account-by-private-key.feature create mode 100644 apps/extension-e2e/src/page-objects/add-new-account-by-private-key.page.ts create mode 100644 libs/ui/src/modals/screens/add-account/components/private-key/private-key.test-ids.ts diff --git a/apps/extension-e2e/src/classes/browser-context.class.ts b/apps/extension-e2e/src/classes/browser-context.class.ts index 8c4a5ca29..a0332cfc7 100644 --- a/apps/extension-e2e/src/classes/browser-context.class.ts +++ b/apps/extension-e2e/src/classes/browser-context.class.ts @@ -7,6 +7,7 @@ export const DEFAULT_SEED_PHRASE = getEnv('DEFAULT_SEED_PHRASE'); export const DEFAULT_PASSWORD = getEnv('DEFAULT_PASSWORD'); export const DEFAULT_HD_ACCOUNT_PRIVATE_KEY = getEnv('DEFAULT_HD_ACCOUNT_PRIVATE_KEY'); export const SEED_PHRASE_FOR_IMPORT = getEnv('SEED_PHRASE_FOR_IMPORT'); +export const PRIVATE_KEY_FOR_IMPORT = getEnv('PRIVATE_KEY_FOR_IMPORT'); export class BrowserContext { public static browser: Browser; @@ -14,4 +15,5 @@ export class BrowserContext { public static recorder: PuppeteerScreenRecorder; public static seedPhrase = DEFAULT_SEED_PHRASE; public static password = DEFAULT_PASSWORD; + public static privateKey = PRIVATE_KEY_FOR_IMPORT; } diff --git a/apps/extension-e2e/src/features/import-account-by-mnemonic.feature b/apps/extension-e2e/src/features/import-account-by-mnemonic.feature index 6e85abd7d..9c53b0ad5 100644 --- a/apps/extension-e2e/src/features/import-account-by-mnemonic.feature +++ b/apps/extension-e2e/src/features/import-account-by-mnemonic.feature @@ -1,6 +1,5 @@ Feature: Add imported account by mnemonic - @dev Scenario: As a user, I'd like to add imported account by mnemonic Given I have imported account And I press Accounts Selector button on the Wallet page @@ -9,9 +8,9 @@ Feature: Add imported account by mnemonic And I press Account Adding button on the AccountsSelector page And I select Seed Phrase as account adding method - And I enter old mnemonic And I am on the AddNewAccountBySeed page + And I enter old mnemonic And I press Import button on the AddNewAccountBySeed page And I am on the Wallet page diff --git a/apps/extension-e2e/src/features/import-account-by-private-key.feature b/apps/extension-e2e/src/features/import-account-by-private-key.feature new file mode 100644 index 000000000..870a4fc5e --- /dev/null +++ b/apps/extension-e2e/src/features/import-account-by-private-key.feature @@ -0,0 +1,21 @@ +Feature: Add imported account by private key + + @dev + Scenario: As a user, I'd like to add imported account by private key + Given I have imported account + And I press Accounts Selector button on the Wallet page + + And I am on the AccountsSelector page + And I press Account Adding button on the AccountsSelector page + + And I select Private Key as account adding method + + And I am on the AddNewAccountByPrivateKey page + And I enter private key into Private Key input on the AddNewAccountByPrivateKey page + And I press Import button on the AddNewAccountByPrivateKey page + + And I am on the Wallet page + And I press Accounts Selector button on the Wallet page + + And I am on the AccountsSelector page + And I see Account 2 on the AccountsSelector page diff --git a/apps/extension-e2e/src/hooks/after-all.hook.ts b/apps/extension-e2e/src/hooks/after-all.hook.ts index 47a1a5655..1ed5ba7d8 100644 --- a/apps/extension-e2e/src/hooks/after-all.hook.ts +++ b/apps/extension-e2e/src/hooks/after-all.hook.ts @@ -4,5 +4,5 @@ import { BrowserContext } from '../classes/browser-context.class'; AfterAll(async () => { await BrowserContext.recorder.stop(); - await BrowserContext.browser.close(); + //await BrowserContext.browser.close(); }); diff --git a/apps/extension-e2e/src/page-objects/add-new-account-by-private-key.page.ts b/apps/extension-e2e/src/page-objects/add-new-account-by-private-key.page.ts new file mode 100644 index 000000000..9948aeb12 --- /dev/null +++ b/apps/extension-e2e/src/page-objects/add-new-account-by-private-key.page.ts @@ -0,0 +1,11 @@ +import { AddByPrivateKeyTestIDs } from '../../../../libs/ui/src/modals/screens/add-account/components/private-key/private-key.test-ids'; +import { Page } from '../classes/page.class'; +import { createPageElement } from '../utils/search.utils'; + +export class AddNewAccountByPrivateKeyPage extends Page { + privateKeyInput = createPageElement(AddByPrivateKeyTestIDs.PrivateKeyInput); + + async isVisible() { + await this.privateKeyInput.waitForDisplayed(); + } +} diff --git a/apps/extension-e2e/src/page-objects/index.ts b/apps/extension-e2e/src/page-objects/index.ts index 57b46d274..d4968e0a0 100644 --- a/apps/extension-e2e/src/page-objects/index.ts +++ b/apps/extension-e2e/src/page-objects/index.ts @@ -1,5 +1,6 @@ import { AccountsSelectorPage } from './accounts-selector.page'; import { AccountsSettingsPage } from './accounts-settings.page'; +import { AddNewAccountByPrivateKeyPage } from './add-new-account-by-private-key.page'; import { AddNewAccountBySeedPage } from './add-new-account-by-seed.page'; import { AddNewHdAccountPage } from './add-new-hd-account.page'; import { AlmostDonePage } from './almost-done.page'; @@ -25,5 +26,6 @@ export const Pages = { RevealSeedPhrase: new RevealSeedPhrasePage(), AccountsSelector: new AccountsSelectorPage(), AddNewHdAccount: new AddNewHdAccountPage(), - AddNewAccountBySeed: new AddNewAccountBySeedPage() + AddNewAccountBySeed: new AddNewAccountBySeedPage(), + AddNewAccountByPrivateKey: new AddNewAccountByPrivateKeyPage() }; diff --git a/apps/extension-e2e/src/step-definitions/common.steps.ts b/apps/extension-e2e/src/step-definitions/common.steps.ts index 5e7e54bdc..699cf783a 100644 --- a/apps/extension-e2e/src/step-definitions/common.steps.ts +++ b/apps/extension-e2e/src/step-definitions/common.steps.ts @@ -15,7 +15,7 @@ Given(/I press (.*) on the (.*) page/, async (elementName: string, pageName: str }); Given( - /I enter (seed|password) into (.*) on the (.*) page/, + /I enter (seed|password|private key) into (.*) on the (.*) page/, async (inputType: string, elementName: string, pageName: string) => { const inputText = getInputText(inputType); diff --git a/apps/extension-e2e/src/utils/input.utils.ts b/apps/extension-e2e/src/utils/input.utils.ts index d74265b21..00c7ff59c 100644 --- a/apps/extension-e2e/src/utils/input.utils.ts +++ b/apps/extension-e2e/src/utils/input.utils.ts @@ -10,6 +10,9 @@ export const getInputText = (inputType: string) => { case 'password': inputText = BrowserContext.password; break; + case 'private key': + inputText = BrowserContext.privateKey; + break; } return inputText; diff --git a/libs/ui/src/modals/screens/add-account/components/private-key/private-key.test-ids.ts b/libs/ui/src/modals/screens/add-account/components/private-key/private-key.test-ids.ts new file mode 100644 index 000000000..7db649226 --- /dev/null +++ b/libs/ui/src/modals/screens/add-account/components/private-key/private-key.test-ids.ts @@ -0,0 +1,4 @@ +export enum AddByPrivateKeyTestIDs { + PrivateKeyInput = 'AddNewAccountByPrivateKey/Private Key input', + ImportButton = 'AddNewAccountByPrivateKey/Import button' +} diff --git a/libs/ui/src/modals/screens/add-account/components/private-key/private-key.tsx b/libs/ui/src/modals/screens/add-account/components/private-key/private-key.tsx index 4bf48ed72..0ff5f8684 100644 --- a/libs/ui/src/modals/screens/add-account/components/private-key/private-key.tsx +++ b/libs/ui/src/modals/screens/add-account/components/private-key/private-key.tsx @@ -16,6 +16,7 @@ import { ModalFooterButtons } from '../../../../components/modal-footer-buttons/ import { useAccountFieldRules } from '../../../../hooks/use-validate-account-field.hook'; import { styles } from './private-key.styles'; +import { AddByPrivateKeyTestIDs } from './private-key.test-ids'; interface FormTypes { name: string; @@ -137,6 +138,7 @@ export const PrivateKey: FC = () => { inputInnerContainerStyle={styles.inputInnerContainer} inputStyle={styles.textarea} clearIconStyles={styles.clearIcon} + testID={AddByPrivateKeyTestIDs.PrivateKeyInput} /> )} /> @@ -151,6 +153,7 @@ export const PrivateKey: FC = () => { onSubmitPress={handleSubmit(onSubmit)} isSubmitDisabled={Boolean(Object.keys(errors).length)} style={styles.buttons} + testID={AddByPrivateKeyTestIDs.ImportButton} /> ); From 7d7f2164445665dd8ff4bd9cd6296d0d2a2d9a78 Mon Sep 17 00:00:00 2001 From: Yarmosh01 Date: Wed, 15 Feb 2023 11:40:20 +0200 Subject: [PATCH 02/12] browser close --- apps/extension-e2e/src/hooks/after-all.hook.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/extension-e2e/src/hooks/after-all.hook.ts b/apps/extension-e2e/src/hooks/after-all.hook.ts index 1ed5ba7d8..47a1a5655 100644 --- a/apps/extension-e2e/src/hooks/after-all.hook.ts +++ b/apps/extension-e2e/src/hooks/after-all.hook.ts @@ -4,5 +4,5 @@ import { BrowserContext } from '../classes/browser-context.class'; AfterAll(async () => { await BrowserContext.recorder.stop(); - //await BrowserContext.browser.close(); + await BrowserContext.browser.close(); }); From 224b08f5d6a5560115120858736a4e190498eec0 Mon Sep 17 00:00:00 2001 From: Yarmosh01 Date: Fri, 17 Feb 2023 16:33:23 +0200 Subject: [PATCH 03/12] secrets replacement --- apps/extension-e2e/.env.dist | 1 + apps/extension-e2e/src/classes/browser-context.class.ts | 9 +-------- apps/extension-e2e/src/hooks/before.hook.ts | 3 ++- .../src/page-objects/add-new-account-by-seed.page.ts | 2 +- .../src/step-definitions/reveal-private-key.ts | 2 +- apps/extension-e2e/src/utils/env.utils.ts | 6 ++++++ apps/extension-e2e/src/utils/input.utils.ts | 4 +++- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/apps/extension-e2e/.env.dist b/apps/extension-e2e/.env.dist index fa7eae42f..4d6382115 100644 --- a/apps/extension-e2e/.env.dist +++ b/apps/extension-e2e/.env.dist @@ -3,3 +3,4 @@ DEFAULT_PASSWORD= DEFAULT_HD_ACCOUNT_PRIVATE_KEY= SEED_PHRASE_FOR_IMPORT= +PRIVATE_KEY_FOR_IMPORT= \ No newline at end of file diff --git a/apps/extension-e2e/src/classes/browser-context.class.ts b/apps/extension-e2e/src/classes/browser-context.class.ts index a0332cfc7..7702800b1 100644 --- a/apps/extension-e2e/src/classes/browser-context.class.ts +++ b/apps/extension-e2e/src/classes/browser-context.class.ts @@ -1,13 +1,7 @@ import { Browser, Page } from 'puppeteer'; import { PuppeteerScreenRecorder } from 'puppeteer-screen-recorder'; -import { getEnv } from '../utils/env.utils'; - -export const DEFAULT_SEED_PHRASE = getEnv('DEFAULT_SEED_PHRASE'); -export const DEFAULT_PASSWORD = getEnv('DEFAULT_PASSWORD'); -export const DEFAULT_HD_ACCOUNT_PRIVATE_KEY = getEnv('DEFAULT_HD_ACCOUNT_PRIVATE_KEY'); -export const SEED_PHRASE_FOR_IMPORT = getEnv('SEED_PHRASE_FOR_IMPORT'); -export const PRIVATE_KEY_FOR_IMPORT = getEnv('PRIVATE_KEY_FOR_IMPORT'); +import { DEFAULT_PASSWORD, DEFAULT_SEED_PHRASE } from '../utils/env.utils'; export class BrowserContext { public static browser: Browser; @@ -15,5 +9,4 @@ export class BrowserContext { public static recorder: PuppeteerScreenRecorder; public static seedPhrase = DEFAULT_SEED_PHRASE; public static password = DEFAULT_PASSWORD; - public static privateKey = PRIVATE_KEY_FOR_IMPORT; } diff --git a/apps/extension-e2e/src/hooks/before.hook.ts b/apps/extension-e2e/src/hooks/before.hook.ts index 16331d726..f08f7ce5e 100644 --- a/apps/extension-e2e/src/hooks/before.hook.ts +++ b/apps/extension-e2e/src/hooks/before.hook.ts @@ -2,7 +2,8 @@ import { Before } from '@cucumber/cucumber'; import { E2eMessageType } from '../../../../libs/ui/src/messagers/enums/e2e-message-type.enum'; import { BackgroundMessage } from '../../../../libs/ui/src/messagers/types/background-message.type'; -import { BrowserContext, DEFAULT_PASSWORD, DEFAULT_SEED_PHRASE } from '../classes/browser-context.class'; +import { BrowserContext } from '../classes/browser-context.class'; +import { DEFAULT_PASSWORD, DEFAULT_SEED_PHRASE } from '../utils/env.utils'; const clearStorageMessage: BackgroundMessage = { type: E2eMessageType.ClearStorage }; diff --git a/apps/extension-e2e/src/page-objects/add-new-account-by-seed.page.ts b/apps/extension-e2e/src/page-objects/add-new-account-by-seed.page.ts index a00caf5d0..ead29033e 100644 --- a/apps/extension-e2e/src/page-objects/add-new-account-by-seed.page.ts +++ b/apps/extension-e2e/src/page-objects/add-new-account-by-seed.page.ts @@ -1,6 +1,6 @@ import { AddBySeedPhraseTestIDs } from '../../../../libs/ui/src/modals/screens/add-account/components/seed-phrase/seed-phrase.test-ids'; -import { SEED_PHRASE_FOR_IMPORT } from '../classes/browser-context.class'; import { Page } from '../classes/page.class'; +import { SEED_PHRASE_FOR_IMPORT } from '../utils/env.utils'; import { createPageElement, findElements } from '../utils/search.utils'; export class AddNewAccountBySeedPage extends Page { diff --git a/apps/extension-e2e/src/step-definitions/reveal-private-key.ts b/apps/extension-e2e/src/step-definitions/reveal-private-key.ts index a1eb6977b..0f8db3027 100644 --- a/apps/extension-e2e/src/step-definitions/reveal-private-key.ts +++ b/apps/extension-e2e/src/step-definitions/reveal-private-key.ts @@ -1,8 +1,8 @@ import { Given } from '@cucumber/cucumber'; import { expect } from 'chai'; -import { DEFAULT_HD_ACCOUNT_PRIVATE_KEY } from '../classes/browser-context.class'; import { Pages } from '../page-objects'; +import { DEFAULT_HD_ACCOUNT_PRIVATE_KEY } from '../utils/env.utils'; Given(/I verify private key/, async () => { const privateKeyText = await Pages.RevealPrivateKey.privateKeyText.getText(); diff --git a/apps/extension-e2e/src/utils/env.utils.ts b/apps/extension-e2e/src/utils/env.utils.ts index 64f6c753d..701edb080 100644 --- a/apps/extension-e2e/src/utils/env.utils.ts +++ b/apps/extension-e2e/src/utils/env.utils.ts @@ -3,3 +3,9 @@ import * as dotenv from 'dotenv'; dotenv.config(); export const getEnv = (key: string) => process.env[key] ?? ''; + +export const DEFAULT_SEED_PHRASE = getEnv('DEFAULT_SEED_PHRASE'); +export const DEFAULT_PASSWORD = getEnv('DEFAULT_PASSWORD'); +export const DEFAULT_HD_ACCOUNT_PRIVATE_KEY = getEnv('DEFAULT_HD_ACCOUNT_PRIVATE_KEY'); +export const SEED_PHRASE_FOR_IMPORT = getEnv('SEED_PHRASE_FOR_IMPORT'); +export const PRIVATE_KEY_FOR_IMPORT = getEnv('PRIVATE_KEY_FOR_IMPORT'); diff --git a/apps/extension-e2e/src/utils/input.utils.ts b/apps/extension-e2e/src/utils/input.utils.ts index 00c7ff59c..be4cf0bc0 100644 --- a/apps/extension-e2e/src/utils/input.utils.ts +++ b/apps/extension-e2e/src/utils/input.utils.ts @@ -1,5 +1,7 @@ import { BrowserContext } from '../classes/browser-context.class'; +import { PRIVATE_KEY_FOR_IMPORT } from './env.utils'; + export const getInputText = (inputType: string) => { let inputText = ''; @@ -11,7 +13,7 @@ export const getInputText = (inputType: string) => { inputText = BrowserContext.password; break; case 'private key': - inputText = BrowserContext.privateKey; + inputText = PRIVATE_KEY_FOR_IMPORT; break; } From ffa65b25227285b2e70c2857b5334c12f2b1b210 Mon Sep 17 00:00:00 2001 From: Yarmosh01 Date: Fri, 17 Feb 2023 17:22:46 +0200 Subject: [PATCH 04/12] existing namings changed --- .github/workflows/code-quality.yml | 5 +++-- .github/workflows/secrets-setup/action.yml | 13 ++++++++----- apps/extension-e2e/.env.dist | 4 ++-- .../src/classes/browser-context.class.ts | 4 ++-- apps/extension-e2e/src/hooks/before.hook.ts | 4 ++-- .../src/step-definitions/reveal-private-key.ts | 4 ++-- apps/extension-e2e/src/utils/env.utils.ts | 4 ++-- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 52f2ec5c6..8326eb630 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -21,10 +21,11 @@ jobs: - name: Secrets setup uses: ./.github/workflows/secrets-setup with: - DEFAULT_SEED_PHRASE: ${{ secrets.DEFAULT_SEED_PHRASE }} + DEFAULT_HD_ACCOUNT_SEED_PHRASE: ${{ secrets.DEFAULT_HD_ACCOUNT_SEED_PHRASE }} DEFAULT_PASSWORD: ${{ secrets.DEFAULT_PASSWORD }} - DEFAULT_HD_ACCOUNT_PRIVATE_KEY: ${{ secrets.DEFAULT_HD_ACCOUNT_PRIVATE_KEY }} + DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY: ${{ secrets.DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY }} SEED_PHRASE_FOR_IMPORT: ${{ secrets.SEED_PHRASE_FOR_IMPORT }} + PRIVATE_KEY_FOR_IMPORT: ${{secrets.PRIVATE_KEY_FOR_IMPORT}} BACKEND_URL: ${{ secrets.BACKEND_URL }} - name: Get yarn cache directory path diff --git a/.github/workflows/secrets-setup/action.yml b/.github/workflows/secrets-setup/action.yml index b7650f967..617f4316c 100644 --- a/.github/workflows/secrets-setup/action.yml +++ b/.github/workflows/secrets-setup/action.yml @@ -6,18 +6,21 @@ inputs: BACKEND_URL: description: "Backend API url" required: true - DEFAULT_SEED_PHRASE: + DEFAULT_HD_ACCOUNT_SEED_PHRASE: description: "Seed phrase for E2E tests" required: false DEFAULT_PASSWORD: description: "Wallet password for E2E tests" required: false - DEFAULT_HD_ACCOUNT_PRIVATE_KEY: + DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY: description: "First account private key for E2E tests" required: false SEED_PHRASE_FOR_IMPORT: description: "Seed phrase for account import for E2E tests" required: false + PRIVATE_KEY_FOR_IMPORT: + description: "Private key for account import for E2E tests" + required: false runs: using: 'composite' @@ -26,11 +29,11 @@ runs: shell: bash run: | cat << EOF > apps/extension-e2e/.env - DEFAULT_SEED_PHRASE=${{ inputs.DEFAULT_SEED_PHRASE }} + DEFAULT_HD_ACCOUNT_SEED_PHRASE=${{ inputs.DEFAULT_HD_ACCOUNT_SEED_PHRASE }} DEFAULT_PASSWORD=${{ inputs.DEFAULT_PASSWORD }} - DEFAULT_HD_ACCOUNT_PRIVATE_KEY=${{ inputs.DEFAULT_HD_ACCOUNT_PRIVATE_KEY }} - + DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY=${{ inputs.DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY }} SEED_PHRASE_FOR_IMPORT=${{ inputs.SEED_PHRASE_FOR_IMPORT }} + PRIVATE_KEY_FOR_IMPORT=${{ inputs.PRIVATE_KEY_FOR_IMPORT }} EOF - name: Create apps/extension/.env file diff --git a/apps/extension-e2e/.env.dist b/apps/extension-e2e/.env.dist index 4d6382115..bdd976245 100644 --- a/apps/extension-e2e/.env.dist +++ b/apps/extension-e2e/.env.dist @@ -1,6 +1,6 @@ -DEFAULT_SEED_PHRASE= +DEFAULT_HD_ACCOUNT_SEED_PHRASE= DEFAULT_PASSWORD= -DEFAULT_HD_ACCOUNT_PRIVATE_KEY= +DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY= SEED_PHRASE_FOR_IMPORT= PRIVATE_KEY_FOR_IMPORT= \ No newline at end of file diff --git a/apps/extension-e2e/src/classes/browser-context.class.ts b/apps/extension-e2e/src/classes/browser-context.class.ts index 7702800b1..7547989cc 100644 --- a/apps/extension-e2e/src/classes/browser-context.class.ts +++ b/apps/extension-e2e/src/classes/browser-context.class.ts @@ -1,12 +1,12 @@ import { Browser, Page } from 'puppeteer'; import { PuppeteerScreenRecorder } from 'puppeteer-screen-recorder'; -import { DEFAULT_PASSWORD, DEFAULT_SEED_PHRASE } from '../utils/env.utils'; +import { DEFAULT_PASSWORD, DEFAULT_HD_ACCOUNT_SEED_PHRASE } from '../utils/env.utils'; export class BrowserContext { public static browser: Browser; public static page: Page; public static recorder: PuppeteerScreenRecorder; - public static seedPhrase = DEFAULT_SEED_PHRASE; + public static seedPhrase = DEFAULT_HD_ACCOUNT_SEED_PHRASE; public static password = DEFAULT_PASSWORD; } diff --git a/apps/extension-e2e/src/hooks/before.hook.ts b/apps/extension-e2e/src/hooks/before.hook.ts index f08f7ce5e..1483a56d8 100644 --- a/apps/extension-e2e/src/hooks/before.hook.ts +++ b/apps/extension-e2e/src/hooks/before.hook.ts @@ -3,7 +3,7 @@ import { Before } from '@cucumber/cucumber'; import { E2eMessageType } from '../../../../libs/ui/src/messagers/enums/e2e-message-type.enum'; import { BackgroundMessage } from '../../../../libs/ui/src/messagers/types/background-message.type'; import { BrowserContext } from '../classes/browser-context.class'; -import { DEFAULT_PASSWORD, DEFAULT_SEED_PHRASE } from '../utils/env.utils'; +import { DEFAULT_PASSWORD, DEFAULT_HD_ACCOUNT_SEED_PHRASE } from '../utils/env.utils'; const clearStorageMessage: BackgroundMessage = { type: E2eMessageType.ClearStorage }; @@ -12,7 +12,7 @@ Before(async () => { // @ts-ignore .evaluate(message => chrome.runtime.sendMessage(undefined, message), clearStorageMessage) .catch(error => console.log(error)); - BrowserContext.seedPhrase = DEFAULT_SEED_PHRASE; + BrowserContext.seedPhrase = DEFAULT_HD_ACCOUNT_SEED_PHRASE; BrowserContext.password = DEFAULT_PASSWORD; await BrowserContext.page.reload(); }); diff --git a/apps/extension-e2e/src/step-definitions/reveal-private-key.ts b/apps/extension-e2e/src/step-definitions/reveal-private-key.ts index 0f8db3027..bf328298e 100644 --- a/apps/extension-e2e/src/step-definitions/reveal-private-key.ts +++ b/apps/extension-e2e/src/step-definitions/reveal-private-key.ts @@ -2,10 +2,10 @@ import { Given } from '@cucumber/cucumber'; import { expect } from 'chai'; import { Pages } from '../page-objects'; -import { DEFAULT_HD_ACCOUNT_PRIVATE_KEY } from '../utils/env.utils'; +import { DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY } from '../utils/env.utils'; Given(/I verify private key/, async () => { const privateKeyText = await Pages.RevealPrivateKey.privateKeyText.getText(); - expect(privateKeyText).eql(DEFAULT_HD_ACCOUNT_PRIVATE_KEY); + expect(privateKeyText).eql(DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY); }); diff --git a/apps/extension-e2e/src/utils/env.utils.ts b/apps/extension-e2e/src/utils/env.utils.ts index 701edb080..c4aeb16ef 100644 --- a/apps/extension-e2e/src/utils/env.utils.ts +++ b/apps/extension-e2e/src/utils/env.utils.ts @@ -4,8 +4,8 @@ dotenv.config(); export const getEnv = (key: string) => process.env[key] ?? ''; -export const DEFAULT_SEED_PHRASE = getEnv('DEFAULT_SEED_PHRASE'); +export const DEFAULT_HD_ACCOUNT_SEED_PHRASE = getEnv('DEFAULT_HD_ACCOUNT_SEED_PHRASE'); export const DEFAULT_PASSWORD = getEnv('DEFAULT_PASSWORD'); -export const DEFAULT_HD_ACCOUNT_PRIVATE_KEY = getEnv('DEFAULT_HD_ACCOUNT_PRIVATE_KEY'); +export const DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY = getEnv('DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY'); export const SEED_PHRASE_FOR_IMPORT = getEnv('SEED_PHRASE_FOR_IMPORT'); export const PRIVATE_KEY_FOR_IMPORT = getEnv('PRIVATE_KEY_FOR_IMPORT'); From 392d4459cdee22d4675bf1cc94afa511e60bfecb Mon Sep 17 00:00:00 2001 From: Yarmosh01 Date: Mon, 20 Feb 2023 10:57:47 +0200 Subject: [PATCH 05/12] draft --- .../src/features/import-account-by-mnemonic.feature | 2 ++ .../src/features/import-account-by-private-key.feature | 1 - apps/extension-e2e/src/hooks/before.hook.ts | 2 +- apps/extension-e2e/src/page-objects/accounts-selector.page.ts | 2 ++ .../screens/accounts-selector/accounts-selector.test-ids.ts | 3 ++- .../src/modals/screens/accounts-selector/accounts-selector.tsx | 1 + 6 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/extension-e2e/src/features/import-account-by-mnemonic.feature b/apps/extension-e2e/src/features/import-account-by-mnemonic.feature index 9c53b0ad5..0b55f6569 100644 --- a/apps/extension-e2e/src/features/import-account-by-mnemonic.feature +++ b/apps/extension-e2e/src/features/import-account-by-mnemonic.feature @@ -1,5 +1,6 @@ Feature: Add imported account by mnemonic +@dev Scenario: As a user, I'd like to add imported account by mnemonic Given I have imported account And I press Accounts Selector button on the Wallet page @@ -18,3 +19,4 @@ Feature: Add imported account by mnemonic And I am on the AccountsSelector page And I see Account 2 on the AccountsSelector page + And I press Account Settings button on the AccountsSelector page diff --git a/apps/extension-e2e/src/features/import-account-by-private-key.feature b/apps/extension-e2e/src/features/import-account-by-private-key.feature index 870a4fc5e..fdbd06225 100644 --- a/apps/extension-e2e/src/features/import-account-by-private-key.feature +++ b/apps/extension-e2e/src/features/import-account-by-private-key.feature @@ -1,6 +1,5 @@ Feature: Add imported account by private key - @dev Scenario: As a user, I'd like to add imported account by private key Given I have imported account And I press Accounts Selector button on the Wallet page diff --git a/apps/extension-e2e/src/hooks/before.hook.ts b/apps/extension-e2e/src/hooks/before.hook.ts index 1483a56d8..69d2c3cbf 100644 --- a/apps/extension-e2e/src/hooks/before.hook.ts +++ b/apps/extension-e2e/src/hooks/before.hook.ts @@ -11,7 +11,7 @@ Before(async () => { await BrowserContext.page // @ts-ignore .evaluate(message => chrome.runtime.sendMessage(undefined, message), clearStorageMessage) - .catch(error => console.log(error)); + .catch(() => void 0); BrowserContext.seedPhrase = DEFAULT_HD_ACCOUNT_SEED_PHRASE; BrowserContext.password = DEFAULT_PASSWORD; await BrowserContext.page.reload(); diff --git a/apps/extension-e2e/src/page-objects/accounts-selector.page.ts b/apps/extension-e2e/src/page-objects/accounts-selector.page.ts index 12c88df46..d29a0e05c 100644 --- a/apps/extension-e2e/src/page-objects/accounts-selector.page.ts +++ b/apps/extension-e2e/src/page-objects/accounts-selector.page.ts @@ -7,10 +7,12 @@ import { createPageElement, findElements } from '../utils/search.utils'; export class AccountsSelectorPage extends Page { accountsScreenTitle = createPageElement(AccountsSelectorTestIDs.AccountsScreenTitle); accountAddingButton = createPageElement(SearchPanelTestIDs.AccountAddingIcon); + accountsSettinButton = createPageElement(AccountsSelectorTestIDs.AccountsSettingsButton); async isVisible() { await this.accountsScreenTitle.waitForDisplayed(); await this.accountAddingButton.waitForDisplayed(); + await this.accountsSettinButton.waitForDisplayed(); } async isAccountNameDisplayed(name: string) { diff --git a/libs/ui/src/modals/screens/accounts-selector/accounts-selector.test-ids.ts b/libs/ui/src/modals/screens/accounts-selector/accounts-selector.test-ids.ts index 6eb7cea27..1dd8c66c1 100644 --- a/libs/ui/src/modals/screens/accounts-selector/accounts-selector.test-ids.ts +++ b/libs/ui/src/modals/screens/accounts-selector/accounts-selector.test-ids.ts @@ -1,4 +1,5 @@ export enum AccountsSelectorTestIDs { AccountsScreenTitle = 'Accounts/Screen Title', - AccountsTabs = 'Accounts/Account Rendered item' + AccountsTabs = 'Accounts/Account Rendered item', + AccountsSettingsButton = 'Accounts/Account Settings button' } diff --git a/libs/ui/src/modals/screens/accounts-selector/accounts-selector.tsx b/libs/ui/src/modals/screens/accounts-selector/accounts-selector.tsx index 56e0bab94..50f287caa 100644 --- a/libs/ui/src/modals/screens/accounts-selector/accounts-selector.tsx +++ b/libs/ui/src/modals/screens/accounts-selector/accounts-selector.tsx @@ -76,6 +76,7 @@ export const AccountsSelector: FC = () => { onPress={onAccountSettings} rightIcon={IconNameEnum.User} style={styles.button} + testID={AccountsSelectorTestIDs.AccountsSettingsButton} /> From be8b0550bc8d5dda1e1218c0103e44db1d6312eb Mon Sep 17 00:00:00 2001 From: Yarmosh01 Date: Fri, 24 Feb 2023 12:26:47 +0200 Subject: [PATCH 06/12] account imported checks improvements etc --- .github/workflows/code-quality.yml | 2 +- .github/workflows/secrets-setup/action.yml | 4 ++-- apps/extension-e2e/.env.dist | 5 ++++- .../features/import-account-by-mnemonic.feature | 8 ++++++-- .../import-account-by-private-key.feature | 5 +++++ .../src/features/reveal-private-key.feature | 2 +- .../src/features/reveal-seed-phrase.feature | 2 +- .../src/page-objects/accounts-selector.page.ts | 2 ++ apps/extension-e2e/src/page-objects/index.ts | 4 +++- .../src/page-objects/receive.page.ts | 11 +++++++++++ .../src/page-objects/wallet.page.ts | 4 ++++ .../public-key-verification.steps.ts | 13 +++++++++++++ apps/extension-e2e/src/utils/browser.utils.ts | 3 ++- apps/extension-e2e/src/utils/env.utils.ts | 4 +++- apps/extension-e2e/src/utils/input.utils.ts | 4 ++-- apps/extension-e2e/src/utils/public-key.utils.ts | 16 ++++++++++++++++ .../navigation-bar/navigation-bar.test-ids.ts | 10 +++++----- .../header-close-button.test-ids.ts | 2 +- libs/ui/src/screens/receive/receive.test-ids.ts | 3 +++ libs/ui/src/screens/receive/receive.tsx | 3 ++- .../wallet/components/header/header.test-ids.ts | 3 +++ .../screens/wallet/components/header/header.tsx | 7 ++++++- .../components/qr-code/qr-code.test-ids.ts | 3 +++ .../wallet/components/qr-code/qr-code.tsx | 3 ++- 24 files changed, 101 insertions(+), 22 deletions(-) create mode 100644 apps/extension-e2e/src/page-objects/receive.page.ts create mode 100644 apps/extension-e2e/src/step-definitions/public-key-verification.steps.ts create mode 100644 apps/extension-e2e/src/utils/public-key.utils.ts create mode 100644 libs/ui/src/screens/receive/receive.test-ids.ts create mode 100644 libs/ui/src/screens/wallet/components/header/header.test-ids.ts create mode 100644 libs/ui/src/screens/wallet/components/qr-code/qr-code.test-ids.ts diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 8326eb630..456e06d84 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -25,7 +25,7 @@ jobs: DEFAULT_PASSWORD: ${{ secrets.DEFAULT_PASSWORD }} DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY: ${{ secrets.DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY }} SEED_PHRASE_FOR_IMPORT: ${{ secrets.SEED_PHRASE_FOR_IMPORT }} - PRIVATE_KEY_FOR_IMPORT: ${{secrets.PRIVATE_KEY_FOR_IMPORT}} + IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY: ${{secrets.IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY}} BACKEND_URL: ${{ secrets.BACKEND_URL }} - name: Get yarn cache directory path diff --git a/.github/workflows/secrets-setup/action.yml b/.github/workflows/secrets-setup/action.yml index 617f4316c..ddcc57a6b 100644 --- a/.github/workflows/secrets-setup/action.yml +++ b/.github/workflows/secrets-setup/action.yml @@ -18,7 +18,7 @@ inputs: SEED_PHRASE_FOR_IMPORT: description: "Seed phrase for account import for E2E tests" required: false - PRIVATE_KEY_FOR_IMPORT: + IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY: description: "Private key for account import for E2E tests" required: false @@ -33,7 +33,7 @@ runs: DEFAULT_PASSWORD=${{ inputs.DEFAULT_PASSWORD }} DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY=${{ inputs.DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY }} SEED_PHRASE_FOR_IMPORT=${{ inputs.SEED_PHRASE_FOR_IMPORT }} - PRIVATE_KEY_FOR_IMPORT=${{ inputs.PRIVATE_KEY_FOR_IMPORT }} + IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY=${{ inputs.IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY }} EOF - name: Create apps/extension/.env file diff --git a/apps/extension-e2e/.env.dist b/apps/extension-e2e/.env.dist index bdd976245..618a54447 100644 --- a/apps/extension-e2e/.env.dist +++ b/apps/extension-e2e/.env.dist @@ -3,4 +3,7 @@ DEFAULT_PASSWORD= DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY= SEED_PHRASE_FOR_IMPORT= -PRIVATE_KEY_FOR_IMPORT= \ No newline at end of file +IMPORTED_BY_SEED_PRIVATE_KEY= +IMPORTED_BY_SEED_PUBLIC_KEY= +IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY= +IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY= \ No newline at end of file diff --git a/apps/extension-e2e/src/features/import-account-by-mnemonic.feature b/apps/extension-e2e/src/features/import-account-by-mnemonic.feature index 0b55f6569..a5cd69494 100644 --- a/apps/extension-e2e/src/features/import-account-by-mnemonic.feature +++ b/apps/extension-e2e/src/features/import-account-by-mnemonic.feature @@ -1,6 +1,5 @@ Feature: Add imported account by mnemonic -@dev Scenario: As a user, I'd like to add imported account by mnemonic Given I have imported account And I press Accounts Selector button on the Wallet page @@ -15,8 +14,13 @@ Feature: Add imported account by mnemonic And I press Import button on the AddNewAccountBySeed page And I am on the Wallet page + And I press Accounts Selector button on the Wallet page And I am on the AccountsSelector page And I see Account 2 on the AccountsSelector page - And I press Account Settings button on the AccountsSelector page + And I press Close button on the HeaderTitle page + + And I am on the Wallet page + And I press Receive button on the NavigationBar page + And I verify imported by seed public key \ No newline at end of file diff --git a/apps/extension-e2e/src/features/import-account-by-private-key.feature b/apps/extension-e2e/src/features/import-account-by-private-key.feature index fdbd06225..a82b75b0d 100644 --- a/apps/extension-e2e/src/features/import-account-by-private-key.feature +++ b/apps/extension-e2e/src/features/import-account-by-private-key.feature @@ -18,3 +18,8 @@ Feature: Add imported account by private key And I am on the AccountsSelector page And I see Account 2 on the AccountsSelector page + And I press Close button on the HeaderTitle page + + And I am on the Wallet page + And I press Receive button on the NavigationBar page + And I verify imported by private key public key \ No newline at end of file diff --git a/apps/extension-e2e/src/features/reveal-private-key.feature b/apps/extension-e2e/src/features/reveal-private-key.feature index 52dcdfcb2..095d86a78 100644 --- a/apps/extension-e2e/src/features/reveal-private-key.feature +++ b/apps/extension-e2e/src/features/reveal-private-key.feature @@ -2,7 +2,7 @@ Feature: Reveal Privat Key Scenario: As a user, I'd like to reveal private key Given I have imported account - And I press Settings button on the Navigation Bar page + And I press Settings button on the NavigationBar page And I am on the Settings page And I press Accounts Settings button on the Settings page diff --git a/apps/extension-e2e/src/features/reveal-seed-phrase.feature b/apps/extension-e2e/src/features/reveal-seed-phrase.feature index e01fb576e..c715e41af 100644 --- a/apps/extension-e2e/src/features/reveal-seed-phrase.feature +++ b/apps/extension-e2e/src/features/reveal-seed-phrase.feature @@ -2,7 +2,7 @@ Feature: Reveal Private Key Scenario: As a user, I'd like to reveal seed phrase Given I have imported account - And I press Settings button on the Navigation Bar page + And I press Settings button on the NavigationBar page And I am on the Settings page And I press Accounts Settings button on the Settings page diff --git a/apps/extension-e2e/src/page-objects/accounts-selector.page.ts b/apps/extension-e2e/src/page-objects/accounts-selector.page.ts index d29a0e05c..374e67b92 100644 --- a/apps/extension-e2e/src/page-objects/accounts-selector.page.ts +++ b/apps/extension-e2e/src/page-objects/accounts-selector.page.ts @@ -1,3 +1,4 @@ +import { HeaderCloseButtonTestIDs } from '../../../../libs/ui/src/components/navigator/components/header-close-button/header-close-button.test-ids'; import { SearchPanelTestIDs } from '../../../../libs/ui/src/components/search-panel/search-panel.test-ids'; import { AccountTabsTestIDs } from '../../../../libs/ui/src/modals/components/modal-render-item/modal-render-item.test-ids'; import { AccountsSelectorTestIDs } from '../../../../libs/ui/src/modals/screens/accounts-selector/accounts-selector.test-ids'; @@ -8,6 +9,7 @@ export class AccountsSelectorPage extends Page { accountsScreenTitle = createPageElement(AccountsSelectorTestIDs.AccountsScreenTitle); accountAddingButton = createPageElement(SearchPanelTestIDs.AccountAddingIcon); accountsSettinButton = createPageElement(AccountsSelectorTestIDs.AccountsSettingsButton); + closeAccountsModalButton = createPageElement(HeaderCloseButtonTestIDs.CloseButton); async isVisible() { await this.accountsScreenTitle.waitForDisplayed(); diff --git a/apps/extension-e2e/src/page-objects/index.ts b/apps/extension-e2e/src/page-objects/index.ts index d4968e0a0..ad2cb6813 100644 --- a/apps/extension-e2e/src/page-objects/index.ts +++ b/apps/extension-e2e/src/page-objects/index.ts @@ -6,6 +6,7 @@ import { AddNewHdAccountPage } from './add-new-hd-account.page'; import { AlmostDonePage } from './almost-done.page'; import { CreateNewWalletPage } from './create-new-wallet.page'; import { ImportExistingWalletPage } from './import-existing-wallet.page'; +import { ReceivePage } from './receive.page'; import { RevealPrivateKeyPage } from './reveal-private-key.page'; import { RevealSeedPhrasePage } from './reveal-seed-phrase.page'; import { SettingsPage } from './settings.page'; @@ -27,5 +28,6 @@ export const Pages = { AccountsSelector: new AccountsSelectorPage(), AddNewHdAccount: new AddNewHdAccountPage(), AddNewAccountBySeed: new AddNewAccountBySeedPage(), - AddNewAccountByPrivateKey: new AddNewAccountByPrivateKeyPage() + AddNewAccountByPrivateKey: new AddNewAccountByPrivateKeyPage(), + Receive: new ReceivePage() }; diff --git a/apps/extension-e2e/src/page-objects/receive.page.ts b/apps/extension-e2e/src/page-objects/receive.page.ts new file mode 100644 index 000000000..e4c8826c3 --- /dev/null +++ b/apps/extension-e2e/src/page-objects/receive.page.ts @@ -0,0 +1,11 @@ +import { ReceiveTestIDs } from '../../../../libs/ui/src/screens/receive/receive.test-ids'; +import { Page } from '../classes/page.class'; +import { createPageElement } from '../utils/search.utils'; + +export class ReceivePage extends Page { + publicKeyText = createPageElement(ReceiveTestIDs.PublicKeyText); + + async isVisible() { + await this.publicKeyText.waitForDisplayed(); + } +} diff --git a/apps/extension-e2e/src/page-objects/wallet.page.ts b/apps/extension-e2e/src/page-objects/wallet.page.ts index fae98dcd6..9fcb73370 100644 --- a/apps/extension-e2e/src/page-objects/wallet.page.ts +++ b/apps/extension-e2e/src/page-objects/wallet.page.ts @@ -1,4 +1,6 @@ import { HeaderSelectorsTestIDs } from '../../../../libs/ui/src/components/screen-components/header-container/components/header-selectors/header-selectors.test-ids'; +import { HeaderTestIDs } from '../../../../libs/ui/src/screens/wallet/components/header/header.test-ids'; +import { QrCodeTestIDs } from '../../../../libs/ui/src/screens/wallet/components/qr-code/qr-code.test-ids'; import { WalletTestIDs } from '../../../../libs/ui/src/screens/wallet/wallet.test-ids'; import { Page } from '../classes/page.class'; import { createPageElement } from '../utils/search.utils'; @@ -8,6 +10,8 @@ export class WalletPage extends Page { collectiblesWidget = createPageElement(WalletTestIDs.CollectiblesWidget); accountSelectorButton = createPageElement(HeaderSelectorsTestIDs.AccountSelectorButton); networkSelectorButton = createPageElement(HeaderSelectorsTestIDs.NetworkSelectorButton); + showQrButton = createPageElement(HeaderTestIDs.ShowQRButton); + publicKeyText = createPageElement(QrCodeTestIDs.PublicKeyText); async isVisible() { await this.assetsWidget.waitForDisplayed(); diff --git a/apps/extension-e2e/src/step-definitions/public-key-verification.steps.ts b/apps/extension-e2e/src/step-definitions/public-key-verification.steps.ts new file mode 100644 index 000000000..33796b2b7 --- /dev/null +++ b/apps/extension-e2e/src/step-definitions/public-key-verification.steps.ts @@ -0,0 +1,13 @@ +import { Given } from '@cucumber/cucumber'; +import { expect } from 'chai'; + +import { Pages } from '../page-objects'; +import { getPublicKeyVariable } from '../utils/public-key.utils'; + +Given(/I verify (imported by seed|imported by private key) public key/, async (accountPublicKey: string) => { + const publicKey = getPublicKeyVariable(accountPublicKey); + + const publicKeyText = await Pages.Receive.publicKeyText.getText(); + + expect(publicKeyText).eql(publicKey); +}); diff --git a/apps/extension-e2e/src/utils/browser.utils.ts b/apps/extension-e2e/src/utils/browser.utils.ts index c4d710f90..a55ca5116 100644 --- a/apps/extension-e2e/src/utils/browser.utils.ts +++ b/apps/extension-e2e/src/utils/browser.utils.ts @@ -9,7 +9,8 @@ export const initBrowser = () => launch({ headless: false, executablePath: process.env.PUPPETEER_EXEC_PATH, - args: [`--disable-extensions-except=${EXTENSION_PATH}`, `--load-extension=${EXTENSION_PATH}`, '--no-sandbox'] + args: [`--disable-extensions-except=${EXTENSION_PATH}`, `--load-extension=${EXTENSION_PATH}`, '--no-sandbox'], + defaultViewport: { width: 1366, height: 768 } }); export const getExtensionId = async (browser: Browser) => { diff --git a/apps/extension-e2e/src/utils/env.utils.ts b/apps/extension-e2e/src/utils/env.utils.ts index c4aeb16ef..103d4a74a 100644 --- a/apps/extension-e2e/src/utils/env.utils.ts +++ b/apps/extension-e2e/src/utils/env.utils.ts @@ -8,4 +8,6 @@ export const DEFAULT_HD_ACCOUNT_SEED_PHRASE = getEnv('DEFAULT_HD_ACCOUNT_SEED_PH export const DEFAULT_PASSWORD = getEnv('DEFAULT_PASSWORD'); export const DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY = getEnv('DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY'); export const SEED_PHRASE_FOR_IMPORT = getEnv('SEED_PHRASE_FOR_IMPORT'); -export const PRIVATE_KEY_FOR_IMPORT = getEnv('PRIVATE_KEY_FOR_IMPORT'); +export const IMPORTED_BY_SEED_PUBLIC_KEY = getEnv('IMPORTED_BY_SEED_PUBLIC_KEY'); +export const IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY = getEnv('IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY'); +export const IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY = getEnv('IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY'); diff --git a/apps/extension-e2e/src/utils/input.utils.ts b/apps/extension-e2e/src/utils/input.utils.ts index be4cf0bc0..ff1a71d8e 100644 --- a/apps/extension-e2e/src/utils/input.utils.ts +++ b/apps/extension-e2e/src/utils/input.utils.ts @@ -1,6 +1,6 @@ import { BrowserContext } from '../classes/browser-context.class'; -import { PRIVATE_KEY_FOR_IMPORT } from './env.utils'; +import { IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY } from './env.utils'; export const getInputText = (inputType: string) => { let inputText = ''; @@ -13,7 +13,7 @@ export const getInputText = (inputType: string) => { inputText = BrowserContext.password; break; case 'private key': - inputText = PRIVATE_KEY_FOR_IMPORT; + inputText = IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY; break; } diff --git a/apps/extension-e2e/src/utils/public-key.utils.ts b/apps/extension-e2e/src/utils/public-key.utils.ts new file mode 100644 index 000000000..c98c9d3a5 --- /dev/null +++ b/apps/extension-e2e/src/utils/public-key.utils.ts @@ -0,0 +1,16 @@ +import { IMPORTED_BY_SEED_PUBLIC_KEY, IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY } from './env.utils'; + +export const getPublicKeyVariable = (accountPublicKey: string) => { + let publicKey = ''; + + switch (accountPublicKey) { + case 'imported by seed': + publicKey = IMPORTED_BY_SEED_PUBLIC_KEY; + break; + case 'imported by private key': + publicKey = IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY; + break; + } + + return publicKey; +}; diff --git a/libs/ui/src/components/navigation-bar/navigation-bar.test-ids.ts b/libs/ui/src/components/navigation-bar/navigation-bar.test-ids.ts index 6e8dfc8da..0a7510362 100644 --- a/libs/ui/src/components/navigation-bar/navigation-bar.test-ids.ts +++ b/libs/ui/src/components/navigation-bar/navigation-bar.test-ids.ts @@ -1,7 +1,7 @@ export enum NavigationBarTestIDs { - HomeButton = 'Navigation Bar/Home button', - ReceiveButton = 'Navigation Bar/Receive button', - SwapButton = 'Navigation Bar/Swap button', - SendButton = 'Navigation Bar/Send button', - SettingsButton = 'Navigation Bar/Settings button' + HomeButton = 'NavigationBar/Home button', + ReceiveButton = 'NavigationBar/Receive button', + SwapButton = 'NavigationBar/Swap button', + SendButton = 'NavigationBar/Send button', + SettingsButton = 'NavigationBar/Settings button' } diff --git a/libs/ui/src/components/navigator/components/header-close-button/header-close-button.test-ids.ts b/libs/ui/src/components/navigator/components/header-close-button/header-close-button.test-ids.ts index 485c63954..4aca12920 100644 --- a/libs/ui/src/components/navigator/components/header-close-button/header-close-button.test-ids.ts +++ b/libs/ui/src/components/navigator/components/header-close-button/header-close-button.test-ids.ts @@ -1,3 +1,3 @@ export enum HeaderCloseButtonTestIDs { - CloseButton = 'HeaderTitle/CloseButton' + CloseButton = 'HeaderTitle/Close button' } diff --git a/libs/ui/src/screens/receive/receive.test-ids.ts b/libs/ui/src/screens/receive/receive.test-ids.ts new file mode 100644 index 000000000..e87e49d69 --- /dev/null +++ b/libs/ui/src/screens/receive/receive.test-ids.ts @@ -0,0 +1,3 @@ +export enum ReceiveTestIDs { + PublicKeyText = 'Receive/Public Key text' +} diff --git a/libs/ui/src/screens/receive/receive.tsx b/libs/ui/src/screens/receive/receive.tsx index 1857e4f29..81f6c8677 100644 --- a/libs/ui/src/screens/receive/receive.tsx +++ b/libs/ui/src/screens/receive/receive.tsx @@ -26,6 +26,7 @@ import { isMobile } from '../../utils/platform.utils'; import { share } from '../../utils/share.util'; import { styles } from './receive.styles'; +import { ReceiveTestIDs } from './receive.test-ids'; export const Receive: FC = () => { const { navigate } = useNavigation(); @@ -58,7 +59,7 @@ export const Receive: FC = () => { {`Wallet Address on the ${network.name} Network`} - + {publicKeyHash} diff --git a/libs/ui/src/screens/wallet/components/header/header.test-ids.ts b/libs/ui/src/screens/wallet/components/header/header.test-ids.ts new file mode 100644 index 000000000..80e42e025 --- /dev/null +++ b/libs/ui/src/screens/wallet/components/header/header.test-ids.ts @@ -0,0 +1,3 @@ +export enum HeaderTestIDs { + ShowQRButton = 'Wallet/Show QR button' +} diff --git a/libs/ui/src/screens/wallet/components/header/header.tsx b/libs/ui/src/screens/wallet/components/header/header.tsx index da8c60b69..34721c970 100644 --- a/libs/ui/src/screens/wallet/components/header/header.tsx +++ b/libs/ui/src/screens/wallet/components/header/header.tsx @@ -10,6 +10,7 @@ import { TouchableIcon } from '../../../../components/touchable-icon/touchable-i import { isMobile } from '../../../../utils/platform.utils'; import { styles } from './header.styles'; +import { HeaderTestIDs } from './header.test-ids'; interface Props { changeQrCodeVisibility: OnEventFn; @@ -22,7 +23,11 @@ export const Header: FC = ({ changeQrCodeVisibility }) => { {isMobile && } - + diff --git a/libs/ui/src/screens/wallet/components/qr-code/qr-code.test-ids.ts b/libs/ui/src/screens/wallet/components/qr-code/qr-code.test-ids.ts new file mode 100644 index 000000000..28c2f600a --- /dev/null +++ b/libs/ui/src/screens/wallet/components/qr-code/qr-code.test-ids.ts @@ -0,0 +1,3 @@ +export enum QrCodeTestIDs { + PublicKeyText = 'QrCodeBar/Public Key text' +} diff --git a/libs/ui/src/screens/wallet/components/qr-code/qr-code.tsx b/libs/ui/src/screens/wallet/components/qr-code/qr-code.tsx index 6f3708260..27b591519 100644 --- a/libs/ui/src/screens/wallet/components/qr-code/qr-code.tsx +++ b/libs/ui/src/screens/wallet/components/qr-code/qr-code.tsx @@ -15,6 +15,7 @@ import { isMobile } from '../../../../utils/platform.utils'; import { share } from '../../../../utils/share.util'; import { styles } from './qr-code.styles'; +import { QrCodeTestIDs } from './qr-code.test-ids'; interface Props { contentOffsetY: number; @@ -39,7 +40,7 @@ export const QrCode: FC = ({ contentOffsetY }) => { - {publicKeyHash} + {publicKeyHash} testID={QrCodeTestIDs.PublicKeyText} From c7396214aabc3520d2e0085991df7fabe60a7da7 Mon Sep 17 00:00:00 2001 From: Yarmosh01 Date: Fri, 24 Feb 2023 12:47:17 +0200 Subject: [PATCH 07/12] testID --- libs/ui/src/screens/wallet/components/qr-code/qr-code.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ui/src/screens/wallet/components/qr-code/qr-code.tsx b/libs/ui/src/screens/wallet/components/qr-code/qr-code.tsx index 27b591519..45203ace1 100644 --- a/libs/ui/src/screens/wallet/components/qr-code/qr-code.tsx +++ b/libs/ui/src/screens/wallet/components/qr-code/qr-code.tsx @@ -39,8 +39,8 @@ export const QrCode: FC = ({ contentOffsetY }) => { - - {publicKeyHash} testID={QrCodeTestIDs.PublicKeyText} + + {publicKeyHash} From f438b1fa3f8b2c17c7ebf2d84b886c7585f6302d Mon Sep 17 00:00:00 2001 From: Yarmosh01 Date: Fri, 24 Feb 2023 23:23:02 +0200 Subject: [PATCH 08/12] e2e fail investigation --- apps/extension-e2e/src/hooks/before-all.hook.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/extension-e2e/src/hooks/before-all.hook.ts b/apps/extension-e2e/src/hooks/before-all.hook.ts index ab24a782f..753a28b00 100644 --- a/apps/extension-e2e/src/hooks/before-all.hook.ts +++ b/apps/extension-e2e/src/hooks/before-all.hook.ts @@ -4,7 +4,7 @@ import { BrowserContext } from '../classes/browser-context.class'; import { initBrowserContext } from '../utils/browser-context.utils'; import { initBrowser } from '../utils/browser.utils'; -const LONG_TIMEOUT = 10000; +const LONG_TIMEOUT = 1000; const VIDEO_RECORDER_SAVE_PATH = 'video-reports/test-run.mp4'; BeforeAll({ timeout: LONG_TIMEOUT }, async () => { From a0a49dd8d2a30c4c3ec5bcbad8f4b0c8b90eeece Mon Sep 17 00:00:00 2001 From: Yarmosh01 Date: Fri, 24 Feb 2023 23:44:30 +0200 Subject: [PATCH 09/12] mda, namings --- .github/workflows/code-quality.yml | 3 +++ .github/workflows/secrets-setup/action.yml | 12 ++++++++++++ apps/extension-e2e/src/hooks/before-all.hook.ts | 2 +- apps/extension-e2e/src/utils/env.utils.ts | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 2fa6ea8d6..5adbe5569 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -25,7 +25,10 @@ jobs: DEFAULT_PASSWORD: ${{ secrets.DEFAULT_PASSWORD }} DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY: ${{ secrets.DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY }} SEED_PHRASE_FOR_IMPORT: ${{ secrets.SEED_PHRASE_FOR_IMPORT }} + IMPORTED_BY_SEED_PRIVATE_KEY: ${{secrets.IMPORTED_BY_SEED_PRIVATE_KEY}} + IMPORTED_BY_SEED_PUBLIC_KEY: ${{secrets.IMPORTED_BY_SEED_PUBLIC_KEY}} IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY: ${{secrets.IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY}} + IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY: ${{secrets.IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY}} BACKEND_URL: ${{ secrets.BACKEND_URL }} - name: Get yarn cache directory path diff --git a/.github/workflows/secrets-setup/action.yml b/.github/workflows/secrets-setup/action.yml index ddcc57a6b..2cc3fbed8 100644 --- a/.github/workflows/secrets-setup/action.yml +++ b/.github/workflows/secrets-setup/action.yml @@ -18,9 +18,18 @@ inputs: SEED_PHRASE_FOR_IMPORT: description: "Seed phrase for account import for E2E tests" required: false + IMPORTED_BY_SEED_PRIVATE_KEY: + description: "Private key for account imported by seed for E2E tests" + required: false + IMPORTED_BY_SEED_PUBLIC_KEY: + description: "Public key for account imported by seed for E2E tests" + required: false IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY: description: "Private key for account import for E2E tests" required: false + IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY: + description: "Public key for account imported by private key for E2E tests" + required: false runs: using: 'composite' @@ -34,6 +43,9 @@ runs: DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY=${{ inputs.DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY }} SEED_PHRASE_FOR_IMPORT=${{ inputs.SEED_PHRASE_FOR_IMPORT }} IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY=${{ inputs.IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY }} + IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY=${{ inputs.IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY }} + IMPORTED_BY_SEED_PRIVATE_KEY=${{ inputs.IMPORTED_BY_SEED_PRIVATE_KEY }} + IMPORTED_BY_SEED_PUBLIC_KEY=${{ inputs.IMPORTED_BY_SEED_PUBLIC_KEY }} EOF - name: Create apps/extension/.env file diff --git a/apps/extension-e2e/src/hooks/before-all.hook.ts b/apps/extension-e2e/src/hooks/before-all.hook.ts index 753a28b00..ab24a782f 100644 --- a/apps/extension-e2e/src/hooks/before-all.hook.ts +++ b/apps/extension-e2e/src/hooks/before-all.hook.ts @@ -4,7 +4,7 @@ import { BrowserContext } from '../classes/browser-context.class'; import { initBrowserContext } from '../utils/browser-context.utils'; import { initBrowser } from '../utils/browser.utils'; -const LONG_TIMEOUT = 1000; +const LONG_TIMEOUT = 10000; const VIDEO_RECORDER_SAVE_PATH = 'video-reports/test-run.mp4'; BeforeAll({ timeout: LONG_TIMEOUT }, async () => { diff --git a/apps/extension-e2e/src/utils/env.utils.ts b/apps/extension-e2e/src/utils/env.utils.ts index 103d4a74a..913032c65 100644 --- a/apps/extension-e2e/src/utils/env.utils.ts +++ b/apps/extension-e2e/src/utils/env.utils.ts @@ -8,6 +8,7 @@ export const DEFAULT_HD_ACCOUNT_SEED_PHRASE = getEnv('DEFAULT_HD_ACCOUNT_SEED_PH export const DEFAULT_PASSWORD = getEnv('DEFAULT_PASSWORD'); export const DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY = getEnv('DEFAULT_HD_ACCOUNT_FIRST_PRIVATE_KEY'); export const SEED_PHRASE_FOR_IMPORT = getEnv('SEED_PHRASE_FOR_IMPORT'); +export const IMPORTED_BY_SEED_PRIVATE_KEY = getEnv('IMPORTED_BY_SEED_PRIVATE_KEY'); export const IMPORTED_BY_SEED_PUBLIC_KEY = getEnv('IMPORTED_BY_SEED_PUBLIC_KEY'); export const IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY = getEnv('IMPORTED_BY_PRIVATE_KEY_PRIVATE_KEY'); export const IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY = getEnv('IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY'); From 83545c6406af7b54221eeaa3e86b2a74f832acfd Mon Sep 17 00:00:00 2001 From: Andrii Ivaniv Date: Mon, 27 Feb 2023 13:28:27 +0200 Subject: [PATCH 10/12] yml idents fix --- .github/workflows/secrets-setup/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/secrets-setup/action.yml b/.github/workflows/secrets-setup/action.yml index 2cc3fbed8..3ee509b99 100644 --- a/.github/workflows/secrets-setup/action.yml +++ b/.github/workflows/secrets-setup/action.yml @@ -28,8 +28,8 @@ inputs: description: "Private key for account import for E2E tests" required: false IMPORTED_BY_PRIVATE_KEY_PUBLIC_KEY: - description: "Public key for account imported by private key for E2E tests" - required: false + description: "Public key for account imported by private key for E2E tests" + required: false runs: using: 'composite' From 12601318648364f592aa3057c4528774972265a3 Mon Sep 17 00:00:00 2001 From: Yarmosh01 Date: Mon, 27 Feb 2023 16:58:31 +0200 Subject: [PATCH 11/12] clear Storage and reload conflict --- apps/extension-e2e/src/hooks/before.hook.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/extension-e2e/src/hooks/before.hook.ts b/apps/extension-e2e/src/hooks/before.hook.ts index 69d2c3cbf..832f7f31b 100644 --- a/apps/extension-e2e/src/hooks/before.hook.ts +++ b/apps/extension-e2e/src/hooks/before.hook.ts @@ -7,12 +7,16 @@ import { DEFAULT_PASSWORD, DEFAULT_HD_ACCOUNT_SEED_PHRASE } from '../utils/env.u const clearStorageMessage: BackgroundMessage = { type: E2eMessageType.ClearStorage }; -Before(async () => { - await BrowserContext.page +Before(() => + BrowserContext.page // @ts-ignore .evaluate(message => chrome.runtime.sendMessage(undefined, message), clearStorageMessage) - .catch(() => void 0); - BrowserContext.seedPhrase = DEFAULT_HD_ACCOUNT_SEED_PHRASE; - BrowserContext.password = DEFAULT_PASSWORD; - await BrowserContext.page.reload(); -}); + .then(() => { + BrowserContext.seedPhrase = DEFAULT_HD_ACCOUNT_SEED_PHRASE; + BrowserContext.password = DEFAULT_PASSWORD; + + return BrowserContext.page.reload(); + }) + .then(() => console.log('page was reloaded')) + .catch(error => console.log(error)) +); From 5de970439764b5454e315a5271a4a1418833f37f Mon Sep 17 00:00:00 2001 From: Yarmosh01 Date: Tue, 28 Feb 2023 14:59:53 +0200 Subject: [PATCH 12/12] back to stock without sleep --- apps/extension-e2e/src/hooks/before.hook.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/apps/extension-e2e/src/hooks/before.hook.ts b/apps/extension-e2e/src/hooks/before.hook.ts index 832f7f31b..1483a56d8 100644 --- a/apps/extension-e2e/src/hooks/before.hook.ts +++ b/apps/extension-e2e/src/hooks/before.hook.ts @@ -7,16 +7,12 @@ import { DEFAULT_PASSWORD, DEFAULT_HD_ACCOUNT_SEED_PHRASE } from '../utils/env.u const clearStorageMessage: BackgroundMessage = { type: E2eMessageType.ClearStorage }; -Before(() => - BrowserContext.page +Before(async () => { + await BrowserContext.page // @ts-ignore .evaluate(message => chrome.runtime.sendMessage(undefined, message), clearStorageMessage) - .then(() => { - BrowserContext.seedPhrase = DEFAULT_HD_ACCOUNT_SEED_PHRASE; - BrowserContext.password = DEFAULT_PASSWORD; - - return BrowserContext.page.reload(); - }) - .then(() => console.log('page was reloaded')) - .catch(error => console.log(error)) -); + .catch(error => console.log(error)); + BrowserContext.seedPhrase = DEFAULT_HD_ACCOUNT_SEED_PHRASE; + BrowserContext.password = DEFAULT_PASSWORD; + await BrowserContext.page.reload(); +});