1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

[e2e] [MV3] Fix Custom RPC e2e test failures for MV3 build (#16599)

* Wait until element is not present

* Change selector network ticker

* Wait for loading overlay to disappear
This commit is contained in:
seaona 2022-11-21 20:04:03 +01:00 committed by GitHub
parent c87a4f5968
commit ff25d44d98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 12 deletions

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures, largeDelayMs } = require('../helpers');
const { convertToHexValue, withFixtures } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('Stores custom RPC history', function () {
@ -30,8 +30,7 @@ describe('Stores custom RPC history', function () {
const rpcUrl = `http://127.0.0.1:${port}`;
const networkName = 'Secondary Ganache Testnet';
await driver.delay(largeDelayMs);
await driver.waitForElementNotPresent('.loading-overlay');
await driver.clickElement('.network-display');
await driver.clickElement({ text: 'Add network', tag: 'button' });
@ -87,8 +86,7 @@ describe('Stores custom RPC history', function () {
// duplicate network
const duplicateRpcUrl = 'https://mainnet.infura.io/v3/';
await driver.delay(largeDelayMs);
await driver.waitForElementNotPresent('.loading-overlay');
await driver.clickElement('.network-display');
await driver.clickElement({ text: 'Add network', tag: 'button' });
@ -132,8 +130,7 @@ describe('Stores custom RPC history', function () {
const newRpcUrl = 'http://localhost:8544';
const duplicateChainId = '1';
await driver.delay(largeDelayMs);
await driver.waitForElementNotPresent('.loading-overlay');
await driver.clickElement('.network-display');
await driver.clickElement({ text: 'Add network', tag: 'button' });
@ -181,8 +178,7 @@ describe('Stores custom RPC history', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.delay(largeDelayMs);
await driver.waitForElementNotPresent('.loading-overlay');
await driver.clickElement('.network-display');
await driver.clickElement({ text: 'Ethereum Mainnet', tag: 'span' });
@ -221,7 +217,7 @@ describe('Stores custom RPC history', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.delay(largeDelayMs);
await driver.waitForElementNotPresent('.loading-overlay');
await driver.clickElement('.network-display');
// only recent 3 are found and in correct order (most recent at the top)
@ -270,7 +266,7 @@ describe('Stores custom RPC history', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.delay(largeDelayMs);
await driver.waitForElementNotPresent('.loading-overlay');
await driver.clickElement('.network-display');
await driver.clickElement({ text: 'Add network', tag: 'button' });

View File

@ -1,6 +1,12 @@
const { promises: fs } = require('fs');
const { strict: assert } = require('assert');
const { until, error: webdriverError, By, Key } = require('selenium-webdriver');
const {
By,
Condition,
error: webdriverError,
Key,
until,
} = require('selenium-webdriver');
const cssToXPath = require('css-to-xpath');
/**
@ -33,6 +39,14 @@ function wrapElementWithAPI(element, driver) {
return element;
}
until.elementIsNotPresent = function elementIsNotPresent(locator) {
return new Condition(`Element not present`, function (driver) {
return driver.findElements(By.css(locator)).then(function (elements) {
return elements.length === 0;
});
});
};
/**
* For Selenium WebDriver API documentation, see:
* https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html
@ -170,6 +184,10 @@ class Driver {
}, this.timeout);
}
async waitForElementNotPresent(element) {
return await this.driver.wait(until.elementIsNotPresent(element));
}
async quit() {
await this.driver.quit();
}