mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
a9085a8e31
* Mock token import * Add mocks, improve stability * Update LavaMoat policies The policies became outdated recently due to undetected conflicts between PRs. * Use veryLargeDelayMs, refactoring Co-authored-by: Mark Stacey <markjstacey@gmail.com>
71 lines
2.1 KiB
JavaScript
71 lines
2.1 KiB
JavaScript
const FixtureBuilder = require('../fixture-builder');
|
|
const { veryLargeDelayMs } = require('../helpers');
|
|
|
|
const ganacheOptions = {
|
|
accounts: [
|
|
{
|
|
secretKey:
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
balance: 25000000000000000000,
|
|
},
|
|
],
|
|
};
|
|
|
|
const withFixturesOptions = {
|
|
fixtures: new FixtureBuilder().build(),
|
|
ganacheOptions,
|
|
};
|
|
|
|
const loadSwaps = async (driver) => {
|
|
await driver.navigate();
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
await driver.clickElement(
|
|
'.wallet-overview__buttons .icon-button:nth-child(3)',
|
|
);
|
|
};
|
|
|
|
const buildQuote = async (driver, options) => {
|
|
await driver.fill('input[placeholder*="0"]', options.amount);
|
|
await driver.delay(veryLargeDelayMs); // Need an extra delay after typing an amount.
|
|
await driver.clickElement(
|
|
'[class="dropdown-search-list__closed-primary-label dropdown-search-list__select-default"]',
|
|
);
|
|
await driver.wait(async () => {
|
|
const tokens = await driver.findElements('.searchable-item-list__item');
|
|
return tokens.length > 1;
|
|
});
|
|
await driver.clickElement('.searchable-item-list__labels');
|
|
await driver.clickElement('.dropdown-input-pair__to');
|
|
await driver.clickElement('input[data-testid="search-list-items"]');
|
|
await driver.fill(
|
|
'input[data-testid="search-list-items"]',
|
|
options.swapTo || options.swapToContractAddress,
|
|
);
|
|
if (options.swapTo) {
|
|
await driver.wait(async () => {
|
|
const tokenNames = await driver.findElements(
|
|
'.searchable-item-list__primary-label',
|
|
);
|
|
if (tokenNames.length === 0) {
|
|
return false;
|
|
}
|
|
const tokenName = await tokenNames[0].getText();
|
|
return tokenName === options.swapTo;
|
|
});
|
|
}
|
|
if (options.swapToContractAddress) {
|
|
await driver.waitForSelector({
|
|
css: '.searchable-item-list__item button.btn-primary',
|
|
text: 'Import',
|
|
});
|
|
}
|
|
await driver.clickElement('.searchable-item-list__primary-label');
|
|
};
|
|
|
|
module.exports = {
|
|
withFixturesOptions,
|
|
loadSwaps,
|
|
buildQuote,
|
|
};
|