2021-05-07 21:38:24 +02:00
|
|
|
const { strict: assert } = require('assert');
|
2021-06-15 18:46:09 +02:00
|
|
|
const path = require('path');
|
2020-01-09 04:34:58 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const enLocaleMessages = require('../../app/_locales/en/messages.json');
|
2021-06-15 18:46:09 +02:00
|
|
|
const createStaticServer = require('../../development/create-static-server');
|
2021-02-04 19:15:23 +01:00
|
|
|
const { tinyDelayMs, regularDelayMs, largeDelayMs } = require('./helpers');
|
|
|
|
const { buildWebDriver } = require('./webdriver');
|
|
|
|
const Ganache = require('./ganache');
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const ganacheServer = new Ganache();
|
2021-06-15 18:46:09 +02:00
|
|
|
const dappPort = 8080;
|
2019-12-09 15:40:43 +01:00
|
|
|
|
2018-05-25 03:17:26 +02:00
|
|
|
describe('MetaMask', function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
let driver;
|
2021-06-15 18:46:09 +02:00
|
|
|
let dappServer;
|
2021-02-04 19:15:23 +01:00
|
|
|
let tokenAddress;
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const testSeedPhrase =
|
2021-02-04 19:15:23 +01:00
|
|
|
'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent';
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
this.bail(true);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-06-16 17:12:20 +02:00
|
|
|
let failed = false;
|
|
|
|
|
2018-05-25 03:17:26 +02:00
|
|
|
before(async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
await ganacheServer.start();
|
2021-06-15 18:46:09 +02:00
|
|
|
const dappDirectory = path.resolve(
|
|
|
|
__dirname,
|
|
|
|
'..',
|
|
|
|
'..',
|
|
|
|
'node_modules',
|
|
|
|
'@metamask',
|
|
|
|
'test-dapp',
|
|
|
|
'dist',
|
|
|
|
);
|
|
|
|
dappServer = createStaticServer(dappDirectory);
|
|
|
|
dappServer.listen(dappPort);
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
dappServer.on('listening', resolve);
|
|
|
|
dappServer.on('error', reject);
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
const result = await buildWebDriver();
|
|
|
|
driver = result.driver;
|
|
|
|
await driver.navigate();
|
|
|
|
});
|
2018-11-05 17:50:06 +01:00
|
|
|
|
2018-05-25 03:17:26 +02:00
|
|
|
afterEach(async function () {
|
|
|
|
if (process.env.SELENIUM_BROWSER === 'chrome') {
|
2021-02-04 19:15:23 +01:00
|
|
|
const errors = await driver.checkBrowserForConsoleErrors(driver);
|
2018-05-25 03:17:26 +02:00
|
|
|
if (errors.length) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const errorReports = errors.map((err) => err.message);
|
2020-11-03 00:41:28 +01:00
|
|
|
const errorMessage = `Errors found in browser console:\n${errorReports.join(
|
|
|
|
'\n',
|
2021-02-04 19:15:23 +01:00
|
|
|
)}`;
|
|
|
|
console.error(new Error(errorMessage));
|
2018-05-25 03:17:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this.currentTest.state === 'failed') {
|
2021-06-16 17:12:20 +02:00
|
|
|
failed = true;
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.verboseReportOnFailure(this.currentTest.title);
|
2018-05-25 03:17:26 +02:00
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
|
|
|
after(async function () {
|
2021-06-16 17:12:20 +02:00
|
|
|
if (process.env.E2E_LEAVE_RUNNING === 'true' && failed) {
|
|
|
|
return;
|
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
await ganacheServer.quit();
|
|
|
|
await driver.quit();
|
2021-06-15 18:46:09 +02:00
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
dappServer.close((error) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error);
|
|
|
|
}
|
|
|
|
return resolve();
|
|
|
|
});
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Going through the first time flow', function () {
|
|
|
|
it('clicks the continue button on the welcome screen', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.findElement('.welcome-page__header');
|
|
|
|
await driver.clickElement({
|
|
|
|
text: enLocaleMessages.getStarted.message,
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(largeDelayMs);
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('clicks the "Create New Wallet" option', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Create a Wallet', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(largeDelayMs);
|
|
|
|
});
|
2019-02-27 15:46:41 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.btn-default');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(largeDelayMs);
|
|
|
|
});
|
2019-03-05 16:45:01 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('accepts a secure password', async function () {
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.first-time-flow__form #create-password',
|
2021-04-12 17:32:38 +02:00
|
|
|
'correct horse battery staple',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.first-time-flow__form #confirm-password',
|
2021-04-12 17:32:38 +02:00
|
|
|
'correct horse battery staple',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.first-time-flow__checkbox');
|
2018-06-14 08:52:51 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.first-time-flow__form button');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-06-14 08:52:51 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
let seedPhrase;
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-05-07 15:07:43 +02:00
|
|
|
it('renders the Secret Recovery Phrase intro screen', async function () {
|
2021-04-14 00:29:44 +02:00
|
|
|
await driver.clickElement('.seed-phrase-intro__left button');
|
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
|
|
|
|
2021-05-07 15:07:43 +02:00
|
|
|
it('reveals the Secret Recovery Phrase', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
const byRevealButton =
|
|
|
|
'.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button';
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.findElement(byRevealButton);
|
|
|
|
await driver.clickElement(byRevealButton);
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const revealedSeedPhrase = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.reveal-seed-phrase__secret-words',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
seedPhrase = await revealedSeedPhrase.getText();
|
|
|
|
assert.equal(seedPhrase.split(' ').length, 12);
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({
|
|
|
|
text: enLocaleMessages.next.message,
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
async function clickWordAndWait(word) {
|
|
|
|
await driver.clickElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
`[data-testid="seed-phrase-sorted"] [data-testid="draggable-seed-${word}"]`,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
await driver.delay(tinyDelayMs);
|
2018-08-06 16:11:40 +02:00
|
|
|
}
|
|
|
|
|
2021-05-07 15:07:43 +02:00
|
|
|
it('can retype the Secret Recovery Phrase', async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
const words = seedPhrase.split(' ');
|
2018-06-22 21:36:22 +02:00
|
|
|
|
2019-10-23 19:00:16 +02:00
|
|
|
for (const word of words) {
|
2021-02-04 19:15:23 +01:00
|
|
|
await clickWordAndWait(word);
|
2019-10-23 19:00:16 +02:00
|
|
|
}
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('clicks through the success screen', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.findElement({ text: 'Congratulations', tag: 'div' });
|
|
|
|
await driver.clickElement({
|
|
|
|
text: enLocaleMessages.endOfFlowMessage10.message,
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-28 18:51:41 +02:00
|
|
|
describe("Close the what's new popup", function () {
|
|
|
|
it("should show the what's new popover", async function () {
|
|
|
|
const popoverTitle = await driver.findElement(
|
|
|
|
'.popover-header__title h2',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(await popoverTitle.getText(), "What's new");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should close the what's new popup", async function () {
|
|
|
|
const popover = await driver.findElement('.popover-container');
|
|
|
|
|
|
|
|
await driver.clickElement('[data-testid="popover-close"]');
|
|
|
|
|
|
|
|
await popover.waitForElementState('hidden');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Show account information', function () {
|
|
|
|
it('shows the QR code for the account', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="account-options-menu-button"]');
|
2020-11-03 00:41:28 +01:00
|
|
|
await driver.clickElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'[data-testid="account-options-menu__account-details"]',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.findVisibleElement('.qr-code__wrapper');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-08 17:41:23 +02:00
|
|
|
// wait for permission modal to be visible.
|
2021-04-13 23:36:02 +02:00
|
|
|
const permissionModal = await driver.findVisibleElement('span .modal');
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.account-modal__close');
|
2018-06-11 15:06:15 +02:00
|
|
|
|
2021-04-13 23:36:02 +02:00
|
|
|
// wait for permission modal to be removed from DOM.
|
|
|
|
await permissionModal.waitForElementState('hidden');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-05-07 15:07:43 +02:00
|
|
|
describe('Import Secret Recovery Phrase', function () {
|
2020-02-11 17:51:13 +01:00
|
|
|
it('logs out of the vault', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.account-menu__icon');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const lockButton = await driver.findClickableElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.account-menu__lock-button',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
assert.equal(await lockButton.getText(), 'Lock');
|
|
|
|
await lockButton.click();
|
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-05-07 15:07:43 +02:00
|
|
|
it('imports Secret Recovery Phrase', async function () {
|
2020-11-03 00:41:28 +01:00
|
|
|
const restoreSeedLink = await driver.findClickableElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.unlock-page__link--import',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-05-07 15:07:43 +02:00
|
|
|
assert.equal(
|
|
|
|
await restoreSeedLink.getText(),
|
|
|
|
'import using Secret Recovery Phrase',
|
|
|
|
);
|
2021-02-04 19:15:23 +01:00
|
|
|
await restoreSeedLink.click();
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.import-account__checkbox-container');
|
2020-09-02 17:45:09 +02:00
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill('.import-account__secret-phrase', testSeedPhrase);
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-06-22 19:11:18 +02:00
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
|
|
await driver.fill('#confirm-password', 'correct horse battery staple');
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({
|
|
|
|
text: enLocaleMessages.restore.message,
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('balance renders', async function () {
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '[data-testid="wallet-balance"] .list-item__heading',
|
|
|
|
text: '100 ETH',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-07-05 13:56:37 +02:00
|
|
|
describe('Navigate transactions', function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
let windowHandles;
|
|
|
|
let extension;
|
|
|
|
let popup;
|
|
|
|
let dapp;
|
2020-02-11 17:51:13 +01:00
|
|
|
it('connects the dapp', async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.openNewPage('http://127.0.0.1:8080/');
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Connect', tag: 'button' });
|
2019-11-22 18:03:51 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2019-11-22 18:03:51 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.waitUntilXWindowHandles(3);
|
|
|
|
windowHandles = await driver.getAllWindowHandles();
|
2018-09-27 20:19:09 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
extension = windowHandles[0];
|
2020-11-03 00:41:28 +01:00
|
|
|
dapp = await driver.switchToWindowWithTitle(
|
|
|
|
'E2E Test Dapp',
|
|
|
|
windowHandles,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
popup = windowHandles.find(
|
|
|
|
(handle) => handle !== extension && handle !== dapp,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(popup);
|
2018-06-21 14:19:27 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-09-27 20:19:09 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
|
|
|
await driver.clickElement({ text: 'Connect', tag: 'button' });
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.waitUntilXWindowHandles(2);
|
|
|
|
await driver.switchToWindow(dapp);
|
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('adds multiple transactions', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
const send3eth = await driver.findClickableElement({
|
|
|
|
text: 'Send',
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
await send3eth.click();
|
|
|
|
await driver.delay(largeDelayMs);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
const contractDeployment = await driver.findClickableElement({
|
|
|
|
text: 'Deploy Contract',
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
await contractDeployment.click();
|
|
|
|
await driver.delay(largeDelayMs);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await send3eth.click();
|
|
|
|
await driver.delay(largeDelayMs);
|
|
|
|
await contractDeployment.click();
|
|
|
|
await driver.delay(largeDelayMs);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(extension);
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-07-05 13:56:37 +02:00
|
|
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.transaction-list-item');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(largeDelayMs);
|
|
|
|
});
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('navigates the transactions', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="next-page"]');
|
2020-11-03 00:41:28 +01:00
|
|
|
let navigationElement = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-navigation',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
let navigationText = await navigationElement.getText();
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
navigationText.includes('2'),
|
|
|
|
true,
|
|
|
|
'changed transaction right',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="next-page"]');
|
2020-11-03 00:41:28 +01:00
|
|
|
navigationElement = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-navigation',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
navigationText = await navigationElement.getText();
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
navigationText.includes('3'),
|
|
|
|
true,
|
|
|
|
'changed transaction right',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="next-page"]');
|
2020-11-03 00:41:28 +01:00
|
|
|
navigationElement = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-navigation',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
navigationText = await navigationElement.getText();
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
navigationText.includes('4'),
|
|
|
|
true,
|
|
|
|
'changed transaction right',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="first-page"]');
|
2020-11-03 00:41:28 +01:00
|
|
|
navigationElement = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-navigation',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
navigationText = await navigationElement.getText();
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
navigationText.includes('1'),
|
|
|
|
true,
|
|
|
|
'navigate to first transaction',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="last-page"]');
|
2020-11-03 00:41:28 +01:00
|
|
|
navigationElement = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-navigation',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
navigationText = await navigationElement.getText();
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
navigationText.split('4').length,
|
|
|
|
3,
|
|
|
|
'navigate to last transaction',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="previous-page"]');
|
2020-11-03 00:41:28 +01:00
|
|
|
navigationElement = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-navigation',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
navigationText = await navigationElement.getText();
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
navigationText.includes('3'),
|
|
|
|
true,
|
|
|
|
'changed transaction left',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="previous-page"]');
|
2020-11-03 00:41:28 +01:00
|
|
|
navigationElement = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-navigation',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
navigationText = await navigationElement.getText();
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
navigationText.includes('2'),
|
|
|
|
true,
|
|
|
|
'changed transaction left',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('adds a transaction while confirm screen is in focus', async function () {
|
2020-11-03 00:41:28 +01:00
|
|
|
let navigationElement = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-navigation',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
let navigationText = await navigationElement.getText();
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
navigationText.includes('2'),
|
|
|
|
true,
|
|
|
|
'second transaction in focus',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(dapp);
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Send', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(extension);
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
navigationElement = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-navigation',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
navigationText = await navigationElement.getText();
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
navigationText.includes('2'),
|
|
|
|
true,
|
|
|
|
'correct (same) transaction in focus',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('rejects a transaction', async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(tinyDelayMs);
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Reject', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(largeDelayMs * 2);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const navigationElement = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-navigation',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
await driver.delay(tinyDelayMs);
|
|
|
|
const navigationText = await navigationElement.getText();
|
|
|
|
assert.equal(navigationText.includes('4'), true, 'transaction rejected');
|
|
|
|
});
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('confirms a transaction', async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(tinyDelayMs / 2);
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const navigationElement = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-navigation',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
await driver.delay(tinyDelayMs / 2);
|
|
|
|
const navigationText = await navigationElement.getText();
|
|
|
|
await driver.delay(tinyDelayMs / 2);
|
|
|
|
assert.equal(navigationText.includes('3'), true, 'transaction confirmed');
|
|
|
|
});
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('rejects the rest of the transactions', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Reject 3', tag: 'a' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Reject All', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(largeDelayMs * 2);
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-04-30 16:39:42 +02:00
|
|
|
await driver.wait(async () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const confirmedTxes = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.transaction-list__completed-transactions .transaction-list-item',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-07-05 13:56:37 +02:00
|
|
|
return confirmedTxes.length === 1;
|
2021-02-04 19:15:23 +01:00
|
|
|
}, 10000);
|
|
|
|
});
|
|
|
|
});
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Add a custom token from a dapp', function () {
|
|
|
|
it('creates a new token', async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
let windowHandles = await driver.getAllWindowHandles();
|
|
|
|
const extension = windowHandles[0];
|
|
|
|
const dapp = windowHandles[1];
|
|
|
|
await driver.delay(regularDelayMs * 2);
|
2018-06-21 18:29:20 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(dapp);
|
|
|
|
await driver.delay(regularDelayMs * 2);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Create Token', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
windowHandles = await driver.waitUntilXWindowHandles(3);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const popup = windowHandles[2];
|
|
|
|
await driver.switchToWindow(popup);
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.confirm-detail-row__header-text--edit');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-12-12 15:54:03 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Advanced', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(tinyDelayMs);
|
2018-12-12 15:54:03 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const [gasPriceInput, gasLimitInput] = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.advanced-gas-inputs__gas-edit-row__input',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
assert(gasPriceInput.getAttribute('value'), 20);
|
|
|
|
assert(gasLimitInput.getAttribute('value'), 4700000);
|
2018-12-12 15:54:03 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Save', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-12-12 15:54:03 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(dapp);
|
|
|
|
await driver.delay(tinyDelayMs);
|
2018-06-21 18:29:20 +02:00
|
|
|
|
2021-04-08 17:41:23 +02:00
|
|
|
const tokenContractAddress = await driver.waitForSelector({
|
|
|
|
css: '#tokenAddress',
|
|
|
|
text: '0x',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
tokenAddress = await tokenContractAddress.getText();
|
2018-06-21 18:29:20 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
await driver.closeAllWindowHandlesExcept([extension, dapp]);
|
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
await driver.switchToWindow(extension);
|
|
|
|
await driver.delay(largeDelayMs);
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('clicks on the Add Token button', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement(`[data-testid="home__asset-tab"]`);
|
|
|
|
await driver.clickElement({ text: 'Add Token', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('picks the newly created Test token', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({
|
|
|
|
text: 'Custom Token',
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill('#custom-address', tokenAddress);
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Add Tokens', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('renders the balance for the new token', async function () {
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '.wallet-overview .token-overview__primary-balance',
|
|
|
|
text: '10 TST',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
|
|
|
});
|
2018-06-07 14:37:41 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Send token from inside MetaMask', function () {
|
2018-06-07 14:37:41 +02:00
|
|
|
it('starts to send a transaction', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="eth-overview-send"]');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-06-07 14:37:41 +02:00
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill(
|
2021-04-07 16:57:40 +02:00
|
|
|
'input[placeholder="Search, public address (0x), or ENS"]',
|
2021-04-12 17:32:38 +02:00
|
|
|
'0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
driver.fill('.unit-input__input', '1');
|
2021-04-08 17:41:23 +02:00
|
|
|
});
|
2018-06-07 14:37:41 +02:00
|
|
|
|
2021-04-08 17:41:23 +02:00
|
|
|
it('opens customize gas modal and saves options to continue', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.advanced-gas-options-btn');
|
2018-06-07 14:37:41 +02:00
|
|
|
|
2021-04-13 23:36:02 +02:00
|
|
|
// wait for gas modal to be visible
|
|
|
|
const gasModal = await driver.findVisibleElement('span .modal');
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.findElement('.page-container__title');
|
|
|
|
await driver.clickElement({ text: 'Save', tag: 'button' });
|
2021-04-08 17:41:23 +02:00
|
|
|
// wait for gas modal to be removed from DOM.
|
2021-04-13 23:36:02 +02:00
|
|
|
await gasModal.waitForElementState('hidden');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-06-07 18:53:54 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('transitions to the confirm screen', async function () {
|
2018-06-07 14:37:41 +02:00
|
|
|
// Continue to next screen
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-06-07 14:37:41 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('displays the token transfer data', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Data', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const functionType = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-content__function-type',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const functionTypeText = await functionType.getText();
|
|
|
|
assert.equal(functionTypeText, 'Transfer');
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const tokenAmount = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-summary__title-text',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const tokenAmountText = await tokenAmount.getText();
|
|
|
|
assert.equal(tokenAmountText, '1 TST');
|
2019-06-28 05:52:21 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const confirmDataDiv = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-content__data-box',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const confirmDataText = await confirmDataDiv.getText();
|
2019-03-28 13:23:38 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert(
|
|
|
|
confirmDataText.match(
|
|
|
|
/0xa9059cbb0000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c97/u,
|
|
|
|
),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Details', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2018-06-07 18:53:54 +02:00
|
|
|
it('submits the transaction', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-06-07 14:37:41 +02:00
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector(
|
|
|
|
{
|
2021-05-03 19:51:09 +02:00
|
|
|
css:
|
|
|
|
'.transaction-list__completed-transactions .transaction-list-item__primary-currency',
|
2021-04-08 17:41:23 +02:00
|
|
|
text: '-1 TST',
|
|
|
|
},
|
|
|
|
{ timeout: 10000 },
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-10-31 17:27:22 +01:00
|
|
|
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '.list-item__heading',
|
|
|
|
text: 'Send TST',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2018-06-07 18:53:54 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Send a custom token from dapp', function () {
|
|
|
|
it('sends an already created token', async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
const windowHandles = await driver.getAllWindowHandles();
|
|
|
|
const extension = windowHandles[0];
|
2020-11-03 00:41:28 +01:00
|
|
|
const dapp = await driver.switchToWindowWithTitle(
|
|
|
|
'E2E Test Dapp',
|
|
|
|
windowHandles,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-06-07 18:53:54 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(dapp);
|
|
|
|
await driver.delay(tinyDelayMs);
|
2018-06-07 18:53:54 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Transfer Tokens', tag: 'button' });
|
2018-06-07 18:53:54 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(extension);
|
|
|
|
await driver.delay(largeDelayMs);
|
2018-06-07 18:53:54 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.findElements('.transaction-list__pending-transactions');
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector(
|
|
|
|
{
|
|
|
|
css: '.transaction-list-item__primary-currency',
|
|
|
|
text: '-1.5 TST',
|
|
|
|
},
|
|
|
|
{ timeout: 10000 },
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.clickElement('.transaction-list-item__primary-currency');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-06-27 04:14:38 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const transactionAmounts = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.currency-display-component__text',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const transactionAmount = transactionAmounts[0];
|
|
|
|
assert(await transactionAmount.getText(), '1.5 TST');
|
2021-04-13 23:36:02 +02:00
|
|
|
});
|
2019-07-03 22:33:44 +02:00
|
|
|
|
2021-04-13 23:36:02 +02:00
|
|
|
it('customizes gas', async function () {
|
2018-06-19 17:44:01 +02:00
|
|
|
// Set the gas limit
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.confirm-detail-row__header-text--edit');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2021-04-08 17:41:23 +02:00
|
|
|
// wait for gas modal to be visible
|
2021-04-13 23:36:02 +02:00
|
|
|
const gasModal = await driver.findVisibleElement('span .modal');
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.page-container__tab:nth-of-type(2)');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-06-19 17:44:01 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const [gasPriceInput, gasLimitInput] = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.advanced-gas-inputs__gas-edit-row__input',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-01-24 16:58:47 +01:00
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await gasPriceInput.fill('10');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(50);
|
2020-04-30 05:48:36 +02:00
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await gasLimitInput.fill('60000');
|
Use `AdvancedGasInputs` in `AdvancedTabContent` (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`
The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.
The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.
Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.
The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.
Closes #6872
* Cleanup send components
Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 14:23:15 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(1000);
|
2018-06-27 18:20:44 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.page-container__footer-button');
|
2021-04-08 17:41:23 +02:00
|
|
|
|
2021-04-13 23:36:02 +02:00
|
|
|
// wait for gas modal to be removed from DOM.
|
|
|
|
await gasModal.waitForElementState('hidden');
|
2018-06-19 17:44:01 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const gasFeeInputs = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-detail-row__primary',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const renderedGasFee = await gasFeeInputs[0].getText();
|
|
|
|
assert.equal(renderedGasFee, '0.0006');
|
|
|
|
});
|
2018-06-19 17:44:01 +02:00
|
|
|
|
|
|
|
it('submits the transaction', async function () {
|
2020-11-03 00:41:28 +01:00
|
|
|
const tokenAmount = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-summary__title-text',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const tokenAmountText = await tokenAmount.getText();
|
|
|
|
assert.equal(tokenAmountText, '1.5 TST');
|
2019-06-28 05:52:21 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-06-07 18:53:54 +02:00
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector({
|
2021-05-03 19:51:09 +02:00
|
|
|
css:
|
|
|
|
'.transaction-list__completed-transactions .transaction-list-item__primary-currency',
|
2021-04-08 17:41:23 +02:00
|
|
|
text: '-1.5 TST',
|
|
|
|
});
|
2018-06-08 15:46:47 +02:00
|
|
|
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '.list-item__heading',
|
|
|
|
text: 'Send TST',
|
|
|
|
});
|
2021-05-03 19:51:09 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it('checks balance', async function () {
|
|
|
|
await driver.clickElement({
|
|
|
|
text: 'Assets',
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2021-04-08 17:41:23 +02:00
|
|
|
|
|
|
|
await driver.waitForSelector({
|
2021-05-03 19:51:09 +02:00
|
|
|
css: '.asset-list-item__token-button',
|
2021-04-08 17:41:23 +02:00
|
|
|
text: '7.5 TST',
|
|
|
|
});
|
2021-05-03 19:51:09 +02:00
|
|
|
|
|
|
|
await driver.clickElement({
|
|
|
|
text: 'Activity',
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2018-06-08 15:46:47 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Approves a custom token from dapp', function () {
|
|
|
|
it('approves an already created token', async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
const windowHandles = await driver.getAllWindowHandles();
|
|
|
|
const extension = windowHandles[0];
|
2020-11-03 00:41:28 +01:00
|
|
|
const dapp = await driver.switchToWindowWithTitle(
|
|
|
|
'E2E Test Dapp',
|
|
|
|
windowHandles,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
await driver.closeAllWindowHandlesExcept([extension, dapp]);
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(dapp);
|
|
|
|
await driver.delay(tinyDelayMs);
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Approve Tokens', tag: 'button' });
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(extension);
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2019-01-24 16:58:47 +01:00
|
|
|
await driver.wait(async () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const pendingTxes = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.transaction-list__pending-transactions .transaction-list-item',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
return pendingTxes.length === 1;
|
|
|
|
}, 10000);
|
2018-08-07 10:57:46 +02:00
|
|
|
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
// Selects only the very first transaction list item immediately following the 'Pending' header
|
|
|
|
css:
|
|
|
|
'.transaction-list__pending-transactions .transaction-list__header + .transaction-list-item .list-item__heading',
|
|
|
|
text: 'Approve TST spend limit',
|
|
|
|
});
|
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.transaction-list-item');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('displays the token approval data', async function () {
|
2020-11-03 00:41:28 +01:00
|
|
|
await driver.clickElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-approve-content__view-full-tx-button',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
await driver.delay(regularDelayMs);
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const functionType = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-approve-content__data .confirm-approve-content__small-text',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const functionTypeText = await functionType.getText();
|
|
|
|
assert.equal(functionTypeText, 'Function: Approve');
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const confirmDataDiv = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-approve-content__data__data-block',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const confirmDataText = await confirmDataDiv.getText();
|
2020-11-03 00:41:28 +01:00
|
|
|
assert(
|
|
|
|
confirmDataText.match(
|
|
|
|
/0x095ea7b30000000000000000000000009bc5baf874d2da8d216ae9f137804184ee5afef4/u,
|
|
|
|
),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2021-04-13 23:36:02 +02:00
|
|
|
it('customizes gas', async function () {
|
2021-04-17 00:00:18 +02:00
|
|
|
await driver.clickElement('.confirm-approve-content__small-blue-text');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2021-04-13 23:36:02 +02:00
|
|
|
// wait for gas modal to be visible
|
|
|
|
const gasModal = await driver.findVisibleElement('span .modal');
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.page-container__tab:nth-of-type(2)');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const [gasPriceInput, gasLimitInput] = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.advanced-gas-inputs__gas-edit-row__input',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await gasPriceInput.fill('10');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(50);
|
2020-04-30 05:48:36 +02:00
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await gasLimitInput.fill('60001');
|
Use `AdvancedGasInputs` in `AdvancedTabContent` (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`
The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.
The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.
Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.
The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.
Closes #6872
* Cleanup send components
Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 14:23:15 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(1000);
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.page-container__footer-button');
|
2021-04-08 17:41:23 +02:00
|
|
|
|
2021-04-13 23:36:02 +02:00
|
|
|
// wait for gas modal to be removed from DOM.
|
|
|
|
await gasModal.waitForElementState('hidden');
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const gasFeeInEth = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-approve-content__transaction-details-content__secondary-fee',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
assert.equal(await gasFeeInEth.getText(), '0.0006 ETH');
|
|
|
|
});
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('edits the permission', async function () {
|
2020-11-03 00:41:28 +01:00
|
|
|
const editButtons = await driver.findClickableElements(
|
2021-04-17 00:00:18 +02:00
|
|
|
'.confirm-approve-content__small-blue-text',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-04-17 00:00:18 +02:00
|
|
|
await editButtons[2].click();
|
2019-11-05 16:13:48 +01:00
|
|
|
|
2021-04-08 17:41:23 +02:00
|
|
|
// wait for permission modal to be visible
|
2021-04-13 23:36:02 +02:00
|
|
|
const permissionModal = await driver.findVisibleElement('span .modal');
|
2020-11-03 00:41:28 +01:00
|
|
|
const radioButtons = await driver.findClickableElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.edit-approval-permission__edit-section__radio-button',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
await radioButtons[1].click();
|
2019-11-05 16:13:48 +01:00
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill('input', '5');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
2019-11-05 16:13:48 +01:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Save', tag: 'button' });
|
2019-11-05 16:13:48 +01:00
|
|
|
|
2021-04-08 17:41:23 +02:00
|
|
|
// wait for permission modal to be removed from DOM.
|
2021-04-13 23:36:02 +02:00
|
|
|
await permissionModal.waitForElementState('hidden');
|
2019-11-05 16:13:48 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const permissionInfo = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-approve-content__medium-text',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const amountDiv = permissionInfo[0];
|
|
|
|
assert.equal(await amountDiv.getText(), '5 TST');
|
|
|
|
});
|
2019-09-16 21:35:21 +02:00
|
|
|
|
2018-07-10 17:43:17 +02:00
|
|
|
it('submits the transaction', async function () {
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2018-07-10 17:43:17 +02:00
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
// Select only the heading of the first entry in the transaction list.
|
|
|
|
css:
|
|
|
|
'.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
|
|
|
|
text: 'Approve TST spend limit',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-07-20 19:02:49 +02:00
|
|
|
describe('Transfers a custom token from dapp when no gas value is specified', function () {
|
2020-02-11 17:51:13 +01:00
|
|
|
it('transfers an already created token, without specifying gas', async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
const windowHandles = await driver.getAllWindowHandles();
|
|
|
|
const extension = windowHandles[0];
|
2020-11-03 00:41:28 +01:00
|
|
|
const dapp = await driver.switchToWindowWithTitle(
|
|
|
|
'E2E Test Dapp',
|
|
|
|
windowHandles,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
await driver.closeAllWindowHandlesExcept([extension, dapp]);
|
|
|
|
await driver.delay(regularDelayMs);
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(dapp);
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({
|
|
|
|
text: 'Transfer Tokens Without Gas',
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(extension);
|
|
|
|
await driver.delay(regularDelayMs);
|
2019-05-14 20:14:07 +02:00
|
|
|
|
|
|
|
await driver.wait(async () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const pendingTxes = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.transaction-list__pending-transactions .transaction-list-item',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
return pendingTxes.length === 1;
|
|
|
|
}, 10000);
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '.transaction-list-item__primary-currency',
|
|
|
|
text: '-1.5 TST',
|
|
|
|
});
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.transaction-list-item');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2019-05-14 20:14:07 +02:00
|
|
|
|
|
|
|
it('submits the transaction', async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(largeDelayMs * 2);
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(largeDelayMs * 2);
|
|
|
|
});
|
2019-05-14 20:14:07 +02:00
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
// Select the heading of the first transaction list item in the
|
|
|
|
// completed transaction list with text matching Send TST
|
|
|
|
css:
|
|
|
|
'.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
|
|
|
|
text: 'Send TST',
|
|
|
|
});
|
|
|
|
|
|
|
|
await driver.waitForSelector({
|
2021-05-03 19:51:09 +02:00
|
|
|
css:
|
|
|
|
'.transaction-list__completed-transactions .transaction-list-item:first-child .transaction-list-item__primary-currency',
|
2021-04-08 17:41:23 +02:00
|
|
|
text: '-1.5 TST',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Approves a custom token from dapp when no gas value is specified', function () {
|
|
|
|
it('approves an already created token', async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
const windowHandles = await driver.getAllWindowHandles();
|
|
|
|
const extension = windowHandles[0];
|
2020-11-03 00:41:28 +01:00
|
|
|
const dapp = await driver.switchToWindowWithTitle(
|
|
|
|
'E2E Test Dapp',
|
|
|
|
windowHandles,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
await driver.closeAllWindowHandlesExcept([extension, dapp]);
|
|
|
|
await driver.delay(regularDelayMs);
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(dapp);
|
|
|
|
await driver.delay(tinyDelayMs);
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({
|
|
|
|
text: 'Approve Tokens Without Gas',
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.switchToWindow(extension);
|
|
|
|
await driver.delay(regularDelayMs);
|
2019-05-14 20:14:07 +02:00
|
|
|
|
|
|
|
await driver.wait(async () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const pendingTxes = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.transaction-list__pending-transactions .transaction-list-item',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
return pendingTxes.length === 1;
|
|
|
|
}, 10000);
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
// Selects only the very first transaction list item immediately following the 'Pending' header
|
|
|
|
css:
|
|
|
|
'.transaction-list__pending-transactions .transaction-list__header + .transaction-list-item .list-item__heading',
|
|
|
|
text: 'Approve TST spend limit',
|
|
|
|
});
|
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.transaction-list-item');
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2019-09-16 21:35:21 +02:00
|
|
|
it('shows the correct recipient', async function () {
|
2020-11-03 00:41:28 +01:00
|
|
|
await driver.clickElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-approve-content__view-full-tx-button',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
await driver.delay(regularDelayMs);
|
2019-11-05 16:13:48 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const permissionInfo = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-approve-content__medium-text',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const recipientDiv = permissionInfo[1];
|
|
|
|
assert.equal(await recipientDiv.getText(), '0x2f318C33...C970');
|
|
|
|
});
|
2019-09-16 21:35:21 +02:00
|
|
|
|
2019-05-14 20:14:07 +02:00
|
|
|
it('submits the transaction', async function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(1000);
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-02-04 19:15:23 +01:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
});
|
2019-05-14 20:14:07 +02:00
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2021-04-08 17:41:23 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
css:
|
|
|
|
'.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
|
|
|
|
text: 'Approve TST spend limit',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|