mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +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 downloadsFolder = `${process.cwd()}/test-artifacts/downloads`;
|
||||||
|
|
||||||
const backupExists = async () => {
|
const getBackupJson = async () => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
|
||||||
const prependZero = (num, maxLength) => {
|
const prependZero = (num, maxLength) => {
|
||||||
@ -31,9 +31,10 @@ const backupExists = async () => {
|
|||||||
try {
|
try {
|
||||||
const backup = `${downloadsFolder}/${userDataFileName}`;
|
const backup = `${downloadsFolder}/${userDataFileName}`;
|
||||||
await fs.access(backup);
|
await fs.access(backup);
|
||||||
return true;
|
const contents = await fs.readFile(backup);
|
||||||
|
return JSON.parse(contents.toString());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -78,12 +79,17 @@ describe('Backup and Restore', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Verify download
|
// Verify download
|
||||||
let fileExists;
|
let info;
|
||||||
await driver.wait(async () => {
|
await driver.wait(async () => {
|
||||||
fileExists = await backupExists();
|
info = await getBackupJson();
|
||||||
return fileExists === true;
|
return info !== null;
|
||||||
}, 10000);
|
}, 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 downloadsFolder = `${process.cwd()}/test-artifacts/downloads`;
|
||||||
|
|
||||||
const stateLogsExist = async () => {
|
const getStateLogsJson = async () => {
|
||||||
try {
|
try {
|
||||||
const stateLogs = `${downloadsFolder}/MetaMask state logs.json`;
|
const stateLogs = `${downloadsFolder}/MetaMask state logs.json`;
|
||||||
await fs.access(stateLogs);
|
await fs.access(stateLogs);
|
||||||
return true;
|
const contents = await fs.readFile(stateLogs);
|
||||||
|
return JSON.parse(contents.toString());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -53,12 +54,19 @@ describe('State logs', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Verify download
|
// Verify download
|
||||||
let fileExists;
|
let info;
|
||||||
await driver.wait(async () => {
|
await driver.wait(async () => {
|
||||||
fileExists = await stateLogsExist();
|
info = await getStateLogsJson();
|
||||||
return fileExists === true;
|
return info !== null;
|
||||||
}, 10000);
|
}, 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