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

[KL-216] e2e - add imported account by private key #290

Open
wants to merge 15 commits into
base: development
Choose a base branch
from
2 changes: 2 additions & 0 deletions apps/extension-e2e/src/classes/browser-context.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ 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;
public static page: Page;
public static recorder: PuppeteerScreenRecorder;
public static seedPhrase = DEFAULT_SEED_PHRASE;
public static password = DEFAULT_PASSWORD;
public static privateKey = PRIVATE_KEY_FOR_IMPORT;
yarmoshevych marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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();
}
}
4 changes: 3 additions & 1 deletion apps/extension-e2e/src/page-objects/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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()
};
2 changes: 1 addition & 1 deletion apps/extension-e2e/src/step-definitions/common.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions apps/extension-e2e/src/utils/input.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export const getInputText = (inputType: string) => {
case 'password':
inputText = BrowserContext.password;
break;
case 'private key':
inputText = BrowserContext.privateKey;
break;
}

return inputText;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum AddByPrivateKeyTestIDs {
PrivateKeyInput = 'AddNewAccountByPrivateKey/Private Key input',
ImportButton = 'AddNewAccountByPrivateKey/Import button'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -137,6 +138,7 @@ export const PrivateKey: FC = () => {
inputInnerContainerStyle={styles.inputInnerContainer}
inputStyle={styles.textarea}
clearIconStyles={styles.clearIcon}
testID={AddByPrivateKeyTestIDs.PrivateKeyInput}
/>
)}
/>
Expand All @@ -151,6 +153,7 @@ export const PrivateKey: FC = () => {
onSubmitPress={handleSubmit(onSubmit)}
isSubmitDisabled={Boolean(Object.keys(errors).length)}
style={styles.buttons}
testID={AddByPrivateKeyTestIDs.ImportButton}
/>
</>
);
Expand Down