2021-04-26 17:02:29 +02:00
|
|
|
const { strict: assert } = require('assert');
|
2023-05-05 15:56:08 +02:00
|
|
|
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
|
2022-10-28 10:42:12 +02:00
|
|
|
const FixtureBuilder = require('../fixture-builder');
|
2021-04-26 17:02:29 +02:00
|
|
|
|
|
|
|
describe('Incremental Security', function () {
|
|
|
|
const ganacheOptions = {
|
|
|
|
accounts: [
|
|
|
|
{
|
|
|
|
secretKey:
|
|
|
|
'0x250F458997A364988956409A164BA4E16F0F99F916ACDD73ADCD3A1DE30CF8D1',
|
2022-01-20 17:56:52 +01:00
|
|
|
balance: convertToHexValue(0),
|
2021-04-26 17:02:29 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
secretKey:
|
|
|
|
'0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9',
|
2022-01-19 00:08:41 +01:00
|
|
|
balance: convertToHexValue(25000000000000000000),
|
2021-04-26 17:02:29 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2021-05-07 15:07:43 +02:00
|
|
|
it('Back up Secret Recovery Phrase from backup reminder', async function () {
|
2021-04-26 17:02:29 +02:00
|
|
|
await withFixtures(
|
|
|
|
{
|
|
|
|
dapp: true,
|
2022-10-28 10:42:12 +02:00
|
|
|
fixtures: new FixtureBuilder({ onboarding: true }).build(),
|
2021-04-26 17:02:29 +02:00
|
|
|
ganacheOptions,
|
|
|
|
title: this.test.title,
|
|
|
|
failOnConsoleError: false,
|
|
|
|
dappPath: 'send-eth-with-private-key-test',
|
|
|
|
},
|
|
|
|
async ({ driver }) => {
|
|
|
|
await driver.navigate();
|
2023-04-14 18:51:13 +02:00
|
|
|
// agree to terms of use
|
|
|
|
await driver.clickElement('[data-testid="onboarding-terms-checkbox"]');
|
2021-04-26 17:02:29 +02:00
|
|
|
|
2023-01-13 17:25:01 +01:00
|
|
|
// welcome
|
|
|
|
await driver.clickElement('[data-testid="onboarding-create-wallet"]');
|
2021-04-26 17:02:29 +02:00
|
|
|
|
2023-01-13 17:25:01 +01:00
|
|
|
// metrics
|
|
|
|
await driver.clickElement('[data-testid="metametrics-no-thanks"]');
|
2022-07-22 22:39:48 +02:00
|
|
|
|
2023-01-13 17:25:01 +01:00
|
|
|
// create password
|
2021-04-26 17:02:29 +02:00
|
|
|
await driver.fill(
|
2023-01-13 17:25:01 +01:00
|
|
|
'[data-testid="create-password-new"]',
|
2021-04-26 17:02:29 +02:00
|
|
|
'correct horse battery staple',
|
|
|
|
);
|
|
|
|
await driver.fill(
|
2023-01-13 17:25:01 +01:00
|
|
|
'[data-testid="create-password-confirm"]',
|
2021-04-26 17:02:29 +02:00
|
|
|
'correct horse battery staple',
|
|
|
|
);
|
2023-01-13 17:25:01 +01:00
|
|
|
await driver.clickElement('[data-testid="create-password-terms"]');
|
|
|
|
await driver.clickElement('[data-testid="create-password-wallet"]');
|
|
|
|
|
|
|
|
// secure wallet later
|
|
|
|
await driver.clickElement('[data-testid="secure-wallet-later"]');
|
|
|
|
await driver.clickElement(
|
|
|
|
'[data-testid="skip-srp-backup-popover-checkbox"]',
|
|
|
|
);
|
|
|
|
await driver.clickElement('[data-testid="skip-srp-backup"]');
|
2021-04-26 17:02:29 +02:00
|
|
|
|
2023-01-13 17:25:01 +01:00
|
|
|
// complete
|
|
|
|
await driver.clickElement('[data-testid="onboarding-complete-done"]');
|
2021-04-26 17:02:29 +02:00
|
|
|
|
2023-01-13 17:25:01 +01:00
|
|
|
// pin extension
|
|
|
|
await driver.clickElement('[data-testid="pin-extension-next"]');
|
|
|
|
await driver.clickElement('[data-testid="pin-extension-done"]');
|
2021-04-26 17:02:29 +02:00
|
|
|
|
2023-01-13 17:25:01 +01:00
|
|
|
// open account menu
|
2023-06-01 23:14:38 +02:00
|
|
|
await driver.clickElement('[data-testid="account-menu-icon"]');
|
2021-04-26 17:02:29 +02:00
|
|
|
await driver.clickElement(
|
2023-06-01 23:14:38 +02:00
|
|
|
'.multichain-account-list-item--selected [data-testid="account-list-item-menu-button"]',
|
2021-04-26 17:02:29 +02:00
|
|
|
);
|
2023-06-01 23:14:38 +02:00
|
|
|
await driver.clickElement('[data-testid="account-list-menu-details"');
|
2021-04-26 17:02:29 +02:00
|
|
|
|
|
|
|
// gets the current accounts address
|
2023-06-01 23:14:38 +02:00
|
|
|
const address = await driver.findElement(
|
|
|
|
'.qr-code .multichain-address-copy-button',
|
|
|
|
);
|
2021-10-13 19:54:48 +02:00
|
|
|
const publicAddress = await address.getText();
|
2021-04-26 17:02:29 +02:00
|
|
|
|
|
|
|
// wait for account modal to be visible
|
2023-07-05 14:57:02 +02:00
|
|
|
const accountModal = await driver.findVisibleElement('.mm-modal');
|
|
|
|
await driver.clickElement('.mm-modal button[aria-label="Close"]');
|
2021-04-26 17:02:29 +02:00
|
|
|
|
|
|
|
// wait for account modal to be removed from DOM
|
|
|
|
await accountModal.waitForElementState('hidden');
|
|
|
|
|
|
|
|
// send to current account from dapp with different provider
|
|
|
|
const windowHandles = await driver.getAllWindowHandles();
|
|
|
|
const extension = windowHandles[0];
|
|
|
|
|
|
|
|
// switched to Dapp
|
2023-05-05 15:56:08 +02:00
|
|
|
await openDapp(driver);
|
2021-04-26 17:02:29 +02:00
|
|
|
|
|
|
|
// sends eth to the current account
|
|
|
|
await driver.fill('#address', publicAddress);
|
|
|
|
await driver.clickElement('#send');
|
|
|
|
|
|
|
|
await driver.waitForSelector(
|
|
|
|
{ css: '#success', text: 'Success' },
|
|
|
|
{ timeout: 15000 },
|
|
|
|
);
|
|
|
|
|
|
|
|
// switch to extension
|
|
|
|
await driver.switchToWindow(extension);
|
|
|
|
|
|
|
|
// should have the correct amount of eth
|
|
|
|
let currencyDisplay = await driver.waitForSelector({
|
|
|
|
css: '.currency-display-component__text',
|
|
|
|
text: '1',
|
|
|
|
});
|
|
|
|
let balance = await currencyDisplay.getText();
|
|
|
|
assert.strictEqual(balance, '1');
|
|
|
|
|
2021-05-07 15:07:43 +02:00
|
|
|
// backs up the Secret Recovery Phrase
|
2021-04-26 17:02:29 +02:00
|
|
|
// should show a backup reminder
|
|
|
|
const backupReminder = await driver.findElements({
|
|
|
|
xpath:
|
2021-06-17 20:43:25 +02:00
|
|
|
"//div[contains(@class, 'home-notification__text') and contains(text(), 'Backup your Secret Recovery Phrase to keep your wallet and funds secure')]",
|
2021-04-26 17:02:29 +02:00
|
|
|
});
|
|
|
|
assert.equal(backupReminder.length, 1);
|
|
|
|
|
|
|
|
// should take the user to the seedphrase backup screen
|
|
|
|
await driver.clickElement('.home-notification__accept-button');
|
|
|
|
|
2021-05-07 15:07:43 +02:00
|
|
|
// reveals the Secret Recovery Phrase
|
2023-01-13 17:25:01 +01:00
|
|
|
await driver.clickElement('[data-testid="secure-wallet-recommended"]');
|
|
|
|
await driver.clickElement('[data-testid="recovery-phrase-reveal"]');
|
|
|
|
const chipTwo = await (
|
|
|
|
await driver.findElement('[data-testid="recovery-phrase-chip-2"]')
|
|
|
|
).getText();
|
|
|
|
const chipThree = await (
|
|
|
|
await driver.findElement('[data-testid="recovery-phrase-chip-3"]')
|
|
|
|
).getText();
|
|
|
|
const chipSeven = await (
|
|
|
|
await driver.findElement('[data-testid="recovery-phrase-chip-7"]')
|
|
|
|
).getText();
|
|
|
|
await driver.clickElement('[data-testid="recovery-phrase-next"]');
|
2021-04-26 17:02:29 +02:00
|
|
|
|
2021-05-07 15:07:43 +02:00
|
|
|
// can retype the Secret Recovery Phrase
|
2023-01-13 17:25:01 +01:00
|
|
|
await driver.fill('[data-testid="recovery-phrase-input-2"]', chipTwo);
|
|
|
|
await driver.fill('[data-testid="recovery-phrase-input-3"]', chipThree);
|
|
|
|
await driver.fill('[data-testid="recovery-phrase-input-7"]', chipSeven);
|
|
|
|
await driver.clickElement('[data-testid="recovery-phrase-confirm"]');
|
2021-04-26 17:02:29 +02:00
|
|
|
|
|
|
|
// should have the correct amount of eth
|
|
|
|
currencyDisplay = await driver.waitForSelector({
|
|
|
|
css: '.currency-display-component__text',
|
|
|
|
text: '1',
|
|
|
|
});
|
|
|
|
balance = await currencyDisplay.getText();
|
|
|
|
|
|
|
|
assert.strictEqual(balance, '1');
|
|
|
|
|
|
|
|
// should not show a backup reminder
|
|
|
|
await driver.assertElementNotPresent('.backup-notification');
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|