diff --git a/test/e2e/tests/backup-restore.spec.js b/test/e2e/tests/backup-restore.spec.js index 1310abd53..767e3fbcc 100644 --- a/test/e2e/tests/backup-restore.spec.js +++ b/test/e2e/tests/backup-restore.spec.js @@ -10,7 +10,7 @@ const FixtureBuilder = require('../fixture-builder'); const downloadsFolder = `${process.cwd()}/test-artifacts/downloads`; -const backupExists = async () => { +const getBackupJson = async () => { const date = new Date(); const prependZero = (num, maxLength) => { @@ -31,9 +31,10 @@ const backupExists = async () => { try { const backup = `${downloadsFolder}/${userDataFileName}`; await fs.access(backup); - return true; + const contents = await fs.readFile(backup); + return JSON.parse(contents.toString()); } catch (e) { - return false; + return null; } }; @@ -78,12 +79,17 @@ describe('Backup and Restore', function () { }); // Verify download - let fileExists; + let info; await driver.wait(async () => { - fileExists = await backupExists(); - return fileExists === true; + info = await getBackupJson(); + return info !== null; }, 10000); - assert.equal(fileExists, true); + assert.notEqual(info, null); + // Verify Json + assert.equal( + info?.preferences?.frequentRpcListDetail[0].chainId, + '0x539', + ); }, ); }); diff --git a/test/e2e/tests/state-logs.spec.js b/test/e2e/tests/state-logs.spec.js index 9b82b0a00..2f33af584 100644 --- a/test/e2e/tests/state-logs.spec.js +++ b/test/e2e/tests/state-logs.spec.js @@ -9,13 +9,14 @@ const FixtureBuilder = require('../fixture-builder'); const downloadsFolder = `${process.cwd()}/test-artifacts/downloads`; -const stateLogsExist = async () => { +const getStateLogsJson = async () => { try { const stateLogs = `${downloadsFolder}/MetaMask state logs.json`; await fs.access(stateLogs); - return true; + const contents = await fs.readFile(stateLogs); + return JSON.parse(contents.toString()); } catch (e) { - return false; + return null; } }; @@ -53,12 +54,19 @@ describe('State logs', function () { }); // Verify download - let fileExists; + let info; await driver.wait(async () => { - fileExists = await stateLogsExist(); - return fileExists === true; + info = await getStateLogsJson(); + return info !== null; }, 10000); - assert.equal(fileExists, true); + assert.notEqual(info, null); + // Verify Json + assert.equal( + info?.metamask?.identities[ + '0x5cfe73b6021e818b776b421b1c4db2474086a7e1' + ].address, + '0x5cfe73b6021e818b776b421b1c4db2474086a7e1', + ); }, ); });