1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

[E2E] Restore tests (#16298)

* add restore test

* rename spec
This commit is contained in:
Peter Yinusa 2022-10-31 09:48:04 +00:00 committed by GitHub
parent 17af3bb11e
commit 88a6f3787c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 96 additions and 2 deletions

View File

@ -0,0 +1,50 @@
{
"addressBook": {
"addressBook": {
"0x539": {
"0x0c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb": {
"address": "0x0c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb",
"chainId": "0x539",
"isEns": false,
"memo": "",
"name": "Test Account"
}
}
}
},
"preferences": {
"advancedGasFee": null,
"currentLocale": "en",
"dismissSeedBackUpReminder": true,
"featureFlags": {
"showIncomingTransactions": true
},
"forgottenPassword": false,
"frequentRpcListDetail": [
{
"chainId": "0x539",
"nickname": "Localhost 8545",
"rpcPrefs": {},
"rpcUrl": "http://localhost:8545",
"ticker": "ETH"
}
],
"infuraBlocked": false,
"ipfsGateway": "dweb.link",
"knownMethodData": {},
"ledgerTransportType": "webhid",
"openSeaEnabled": false,
"preferences": {
"hideZeroBalanceTokens": false,
"showFiatInTestnets": false,
"showTestNetworks": false,
"useNativeCurrencyAsPrimaryCurrency": true
},
"theme": "light",
"useBlockie": false,
"useCollectibleDetection": false,
"useNonceField": false,
"usePhishDetect": true,
"useTokenDetection": false
}
}

View File

@ -1,5 +1,6 @@
const { strict: assert } = require('assert'); const { strict: assert } = require('assert');
const { promises: fs } = require('fs'); const { promises: fs } = require('fs');
const path = require('path');
const { const {
convertToHexValue, convertToHexValue,
withFixtures, withFixtures,
@ -36,7 +37,14 @@ const backupExists = async () => {
} }
}; };
describe('Backup', function () { const restoreFile = path.join(
__dirname,
'..',
'restore',
'MetaMaskUserData.json',
);
describe('Backup and Restore', function () {
const ganacheOptions = { const ganacheOptions = {
accounts: [ accounts: [
{ {
@ -46,7 +54,7 @@ describe('Backup', function () {
}, },
], ],
}; };
it('should create backup for the account', async function () { it('should backup the account settings', async function () {
await withFixtures( await withFixtures(
{ {
fixtures: new FixtureBuilder().build(), fixtures: new FixtureBuilder().build(),
@ -79,4 +87,40 @@ describe('Backup', function () {
}, },
); );
}); });
it('should restore the account settings', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder().build(),
ganacheOptions,
title: this.test.title,
},
async ({ driver }) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
// Restore
await driver.clickElement('.account-menu__icon');
await driver.clickElement({ text: 'Settings', tag: 'div' });
await driver.clickElement({ text: 'Advanced', tag: 'div' });
const restore = await driver.findElement('#restore-file');
await restore.sendKeys(restoreFile);
// Dismiss success message
await driver.waitForSelector({
css: '.actionable-message__message',
text: 'Your data has been restored successfully',
});
await driver.clickElement({ text: 'Dismiss', tag: 'button' });
// Verify restore
await driver.clickElement({ text: 'Contacts', tag: 'div' });
const recipient = await driver.findElement('[data-testid="recipient"]');
assert.ok(
/Test\sAccount\s*0x0c54...AaFb/u.test(await recipient.getText()),
);
},
);
});
}); });