mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Improve downloads tests (#17995)
This commit is contained in:
parent
abff49561d
commit
f46ce9f2bd
@ -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',
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
@ -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',
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user