Skip to content

Commit

Permalink
Merge branch 'develop' into feat/YOEXT-599/create-restore-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vsubhuman committed May 29, 2023
2 parents 23fbf3e + 718a6e9 commit 8c389dc
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 359 deletions.
60 changes: 51 additions & 9 deletions packages/yoroi-extension/features/mock-chain/TestWallets.js
Expand Up @@ -7,8 +7,8 @@ export type RestorationInput = {|
password: string,
mnemonic: string,
plate: string,
plateByron?: string,
deviceId?: ?string,
plateByron: string,
deviceId: string,
|};

function getMnemonicFromEnv(walletName): string {
Expand All @@ -19,16 +19,17 @@ function createWallet(payload: {|
name: string,
mnemonic: string,
plate: string,
plateByron?: ?string,
deviceId?: ?string,
plateByron: string,
deviceId: string,
|}) {
const { name, mnemonic, plate } = payload;
const { name, mnemonic, plate, plateByron, deviceId } = payload;
return { [name]: {
name,
mnemonic,
plate,
plateByron,
password: commonWalletPassword,
deviceId: payload.deviceId,
deviceId,
} };
}

Expand Down Expand Up @@ -67,45 +68,60 @@ export const testWallets: { [key: WalletNames]: RestorationInput, ... } = Object
createWallet({
name: ('small-single-tx': WalletNames),
mnemonic: 'eight country switch draw meat scout mystery blade tip drift useless good keep usage title',
plate: 'EAJD-7036',
plate: '',
plateByron: 'EAJD-7036',
deviceId: '',
}),
createWallet({
name: ('failed-single-tx': WalletNames),
mnemonic: 'broken common spring toilet work safe decrease equal velvet cluster myth old toy hold rain',
plate: 'JSLX-5059',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('many-tx-wallet': WalletNames),
mnemonic: 'final autumn bacon fold horse scissors act pole country focus task blush basket move view',
plate: 'ZKTZ-4614',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('empty-wallet': WalletNames),
mnemonic: 'burst hood dance captain city crane over olive notice sugar what bubble butter wealth grace',
plate: 'PZEB-5741',
plateByron: 'ZPOX-6942',
deviceId: '',
}),
createWallet({
name: ('simple-pending-wallet': WalletNames),
mnemonic: 'ritual horn upon plastic foster enemy expect hand control coil jeans wolf arch isolate farm',
plate: 'DPAH-1099',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('tx-big-input-wallet': WalletNames),
mnemonic: 'dragon mango general very inmate idea rabbit pencil element bleak term cart critic kite pill',
plate: 'EDAO-9229',
plateByron: '',
deviceId: '',
}),
createWallet({
// a wallet to send stuff to when you need a tx output
// but don't want to affect the other wallets for testing
name: ('dump-wallet': WalletNames),
mnemonic: 'proud nuclear patch arm digital theory peasant winner person knock mirror across immune certain power',
plate: 'XXXX-1111',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('jormungandr-test': WalletNames),
mnemonic: '',
plate: 'XXXX-1111',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('ledger-wallet': WalletNames),
Expand All @@ -125,72 +141,98 @@ export const testWallets: { [key: WalletNames]: RestorationInput, ... } = Object
name: ('shelley-simple-24': WalletNames),
mnemonic: 'reunion walnut update express purse defense slice barrel estate olympic february flock give team alert coast luggage exhaust notable bag december split furnace sponsor',
plate: 'DSKC-9213',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('shelley-collateral': WalletNames),
mnemonic: 'deal calm cloth world refuse pledge grant tuna inner body fat afford absorb off barely',
plate: 'HLBZ-9462',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('shelley-simple-15': WalletNames),
mnemonic: 'eight country switch draw meat scout mystery blade tip drift useless good keep usage title',
plate: 'ZDDC-9858',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('shelley-delegated': WalletNames),
mnemonic: 'parrot offer switch thank film high drop salute task train squirrel coral consider coyote evolve',
plate: 'PALP-0076',
plateByron: '',
deviceId: '6495958994A4025BB5EE1DB1',
}),
createWallet({
name: ('shelley-ledger-delegated': WalletNames),
mnemonic: 'parrot offer switch thank film high drop salute task train squirrel coral consider coyote evolve',
plate: 'PALP-0076',
plateByron: '',
deviceId: '707fa118bf6b84',
}),
createWallet({
name: ('shelley-only-registered': WalletNames),
mnemonic: 'pig organ result afraid abstract arrest brass kangaroo hub cube crunch return vibrant core make',
plate: 'TDDO-4310',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('shelley-enterprise': WalletNames),
mnemonic: 'much million increase spot visa domain grow brother chief mechanic innocent envelope vacant bundle coyote',
plate: 'HBDZ-9545',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('shelley-mangled': WalletNames),
mnemonic: 'weekend december choose maid rack helmet canoe bridge strike section lift autumn route practice seat',
plate: 'JCEH-5025',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('ergo-simple-wallet': WalletNames),
mnemonic: 'eight country switch draw meat scout mystery blade tip drift useless good keep usage title',
plate: 'CXTP-1821',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('ergo-token-wallet': WalletNames),
mnemonic: 'rent sword help dynamic enhance collect biology drama agent raven grape bike march length leisure',
plate: 'AZTH-1588',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('cardano-token-wallet': WalletNames),
mnemonic: 'rent sword help dynamic enhance collect biology drama agent raven grape bike march length leisure',
plate: 'HZPX-1482',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('First-Smoke-Test-Wallet': WalletNames),
mnemonic: getMnemonicFromEnv('FIRST_SMOKE_TEST_WALLET'),
plate: 'XONT-4910'
plate: 'XONT-4910',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('Second-Smoke-Test-Wallet': WalletNames),
mnemonic: getMnemonicFromEnv('SECOND_SMOKE_TEST_WALLET'),
plate: 'XZHD-1651',
plateByron: '',
deviceId: '',
}),
createWallet({
name: ('Second-Smoke-Test-Wallet-FF': WalletNames),
mnemonic: getMnemonicFromEnv('SECOND_SMOKE_TEST_WALLET_FF'),
plate: 'CJBE-8896'
plate: 'CJBE-8896',
plateByron: '',
deviceId: '',
}),
);
34 changes: 2 additions & 32 deletions packages/yoroi-extension/features/pages/newWalletPages.js
Expand Up @@ -17,10 +17,6 @@ export const pickUpCurrencyDialog: LocatorObject = {
locator: '.PickCurrencyOptionDialog',
method: 'css',
};
export const pickUpCurrencyDialogErgo: LocatorObject = {
locator: '.PickCurrencyOptionDialog_ergo',
method: 'css',
};
export const pickUpCurrencyDialogCardano: LocatorObject = {
locator: '.PickCurrencyOptionDialog_cardano',
method: 'css',
Expand Down Expand Up @@ -75,18 +71,6 @@ export const trezorWalletName: LocatorObject = {
};
export const trezorConfirmButton: LocatorObject = { locator: '.MuiButton-primary', method: 'css' };
// Create wallet dialog
export const createOptionDialog: LocatorObject = {
locator: '.WalletCreateOptionDialog',
method: 'css',
};
export const createNormalWalletButton: LocatorObject = {
locator: '.WalletCreateOptionDialog_createWallet',
method: 'css'
};
export const createPaperWalletButton: LocatorObject = {
locator: '.WalletCreateOptionDialog_restorePaperWallet',
method: 'css',
};
export const createWalletPasswordInput: LocatorObject = {
locator: '.WalletCreateDialog .walletPassword input',
method: 'css',
Expand Down Expand Up @@ -140,34 +124,20 @@ export const getRecoveryPhraseWord = (indexNumber: number): LocatorObject => {
};
};

// Paper Wallet dialog
export const paperWalletDialogSelect: LocatorObject = {
locator: '.WalletPaperDialog_component .MuiSelect-select',
method: 'css',
};
export const restorePaperWalletButton: LocatorObject = {
locator: '.WalletRestoreOptionDialog_restorePaperWallet',
method: 'css',
};
export const restoreDialogButton: LocatorObject = {
locator: '.WalletRestoreDialog .primary',
method: 'css',
};
export const getAddressesAmountButton = (addressesAmount: string): LocatorObject => {
return { locator: `//li[contains(text(), "${addressesAmount}")]`, method: 'xpath' };
};

export const recoveryPhraseDeleteIcon = {
locator: `(//span[contains(text(), '×')])[1]`,
method: 'xpath',
};

export const recoveryPhraseError: LocatorObject = {
locator: '//p[starts-with(@id, "recoveryPhrase--")]',
method: 'xpath',
};
export const addressElement : LocatorObject = {
locator: '//span[contains(@class, "RawHash_hash")]',
method: 'xpath',
};

// Common elements
export const walletNameInput: LocatorObject = {
Expand Down
Expand Up @@ -49,7 +49,6 @@ export const walletNameInput: LocatorObject = { locator: "input[name='walletName
export const confirmRestoreWalletButton: LocatorObject = { locator: '.WalletRestoreDialog .primary', method: 'css' };
export const walletPasswordInput: LocatorObject = { locator: "input[name='walletPassword']", method: 'css' };
export const repeatPasswordInput: LocatorObject = { locator: "input[name='repeatPassword']", method: 'css' };
export const paperPasswordInput: LocatorObject = { locator: "input[name='paperPassword']", method: 'css' };
export const confirmButton: LocatorObject = { locator: '.confirmButton', method: 'css' };
export const confirmConfirmationButton: LocatorObject = { locator: '.WalletRestoreDialog .primary', method: 'css' };
export const verifyRestoredInfoDialog: LocatorObject = { locator: '.WalletRestoreVerifyDialog_dialog', method: 'css' };
Expand Down
29 changes: 2 additions & 27 deletions packages/yoroi-extension/features/step_definitions/common-steps.js
Expand Up @@ -50,16 +50,12 @@ import {
trezorConfirmButton,
walletNameInput,
saveDialog,
pickUpCurrencyDialogErgo,
walletRestoreOptionDialog,
restoreNormalWallet,
walletRestoreDialog,
restoreWalletButton,
saveButton,
byronEraButton,
createWalletButton,
createOptionDialog,
createNormalWalletButton,
} from '../pages/newWalletPages';
import { allowPubKeysAndSwitchToYoroi, switchToTrezorAndAllow } from './trezor-steps';
import {
Expand Down Expand Up @@ -276,8 +272,9 @@ export async function getIndexedDBTablesInfo(customWorld: any, postfix: string =
}
};

export async function getPlates(customWorld: any): Promise<any> {
export async function getPlates(customWorld: any): Promise<Array<any>> {
// check plate in confirmation dialog
await customWorld.waitForElement(restoringDialogPlate);
let plateElements = await customWorld.findElements(restoringDialogPlate);

// this makes this function also work for wallets that already exist
Expand Down Expand Up @@ -437,25 +434,6 @@ Then(/^I pause the test to debug$/, async function () {
await this.waitForElement({ locator: '.element_that_does_not_exist', method: 'css' });
});

Given(/^There is an Ergo wallet stored named ([^"]*)$/, async function (walletName) {
this.webDriverLogger.info(`Step: There is an Ergo wallet stored named ${walletName}`);
const restoreInfo = testWallets[walletName];
expect(restoreInfo).to.not.equal(undefined);

await this.click(restoreWalletButton);

await this.waitForElement(pickUpCurrencyDialog);
await this.click(pickUpCurrencyDialogErgo);

await this.waitForElement(walletRestoreOptionDialog);

await this.click(restoreNormalWallet);
await this.waitForElement(walletRestoreDialog);

await inputMnemonicForWallet(this, restoreInfo);
await checkWalletPlate(this, walletName, restoreInfo);
});

Given(/^There is a Shelley wallet stored named ([^"]*)$/, async function (walletName: WalletNames) {
this.webDriverLogger.info(`Step: There is a Shelley wallet stored named ${walletName}`);
const browserName = await this.getBrowser();
Expand All @@ -477,9 +455,6 @@ Given(/^I create a new Shelley wallet with the name ([^"]*)$/, async function (w
await this.waitForElement(pickUpCurrencyDialog);
await this.click(getCurrencyButton('cardano'));

await this.waitForElement(createOptionDialog);
await this.click(createNormalWalletButton);

await this.waitForElement(walletInfoDialog);
await this.input(walletNameInput, walletName);
await this.input(walletPasswordInput, commonWalletPassword);
Expand Down
Expand Up @@ -7,9 +7,6 @@ import { expect } from 'chai';
import { checkErrorByTranslationId } from './common-steps';
import {
clearButton,
createNormalWalletButton,
createOptionDialog,
createPaperWalletButton,
createPersonalWalletButton,
createWalletButton,
createWalletNameError,
Expand Down Expand Up @@ -39,15 +36,6 @@ When(/^I select the currency ([^"]*)$/, async function (currency) {
await this.click(getCurrencyButton(currency));
});

When(/^I select Create Wallet$/, async function () {
await this.waitForElement(createOptionDialog);
await this.click(createNormalWalletButton);
});
When(/^I select Paper Wallet$/, async function () {
await this.waitForElement(createOptionDialog);
await this.click(createPaperWalletButton);
});

When(/^I enter the created wallet password:$/, async function (table) {
const fields = table.hashes()[0];
await this.input(createWalletPasswordInput, fields.password);
Expand Down

0 comments on commit 8c389dc

Please sign in to comment.