mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
[e2e] Enabling/Disabling token conversion on testnets (#14649)
* E2e test for advanced settings: show conversion on test networks * Lint fix * Complete testnet conversion for all testnets * Lint fixes * Add custom error messages for each assert * Removed delays * Fix testcase * Test only local network * Mock API response for ETH USD price rate * Remove unnecessary awaits * Lint fix * FindElement by its text on secondary currency * Add missing awat for getText
This commit is contained in:
parent
092189cb5b
commit
86f02e4fd5
@ -205,6 +205,18 @@ async function setupMocking(server, testSpecificMock) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await server
|
||||||
|
.forGet('https://min-api.cryptocompare.com/data/price')
|
||||||
|
.withQuery({ fsym: 'ETH', tsyms: 'USD' })
|
||||||
|
.thenCallback(() => {
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
json: {
|
||||||
|
USD: '1700',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
testSpecificMock(server);
|
testSpecificMock(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
72
test/e2e/tests/advanced-settings.spec.js
Normal file
72
test/e2e/tests/advanced-settings.spec.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
const { strict: assert } = require('assert');
|
||||||
|
const { convertToHexValue, withFixtures } = require('../helpers');
|
||||||
|
|
||||||
|
describe('Advanced Settings', function () {
|
||||||
|
const ganacheOptions = {
|
||||||
|
accounts: [
|
||||||
|
{
|
||||||
|
secretKey:
|
||||||
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
||||||
|
balance: convertToHexValue(25000000000000000000),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
it('should show conversion on test network when activated', async function () {
|
||||||
|
await withFixtures(
|
||||||
|
{
|
||||||
|
dapp: true,
|
||||||
|
fixtures: 'imported-account',
|
||||||
|
ganacheOptions,
|
||||||
|
title: this.test.title,
|
||||||
|
},
|
||||||
|
async ({ driver }) => {
|
||||||
|
await driver.navigate();
|
||||||
|
await driver.fill('#password', 'correct horse battery staple');
|
||||||
|
await driver.press('#password', driver.Key.ENTER);
|
||||||
|
|
||||||
|
await driver.clickElement('.account-menu__icon');
|
||||||
|
await driver.clickElement({ text: 'Settings', tag: 'div' });
|
||||||
|
await driver.clickElement({ text: 'Advanced', tag: 'div' });
|
||||||
|
|
||||||
|
await driver.clickElement(
|
||||||
|
'[data-testid="advanced-setting-show-testnet-conversion"] label',
|
||||||
|
);
|
||||||
|
|
||||||
|
await driver.clickElement(
|
||||||
|
'.settings-page__header__title-container__close-button',
|
||||||
|
);
|
||||||
|
|
||||||
|
const secondaryCurrency = await driver.findElement(
|
||||||
|
'[data-testid="eth-overview__secondary-currency"] .currency-display-component__suffix',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await secondaryCurrency.getText(),
|
||||||
|
'USD',
|
||||||
|
`Secondary currency is not present`,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show conversion on test network when deactivated', async function () {
|
||||||
|
await withFixtures(
|
||||||
|
{
|
||||||
|
dapp: true,
|
||||||
|
fixtures: 'imported-account',
|
||||||
|
ganacheOptions,
|
||||||
|
title: this.test.title,
|
||||||
|
},
|
||||||
|
async ({ driver }) => {
|
||||||
|
await driver.navigate();
|
||||||
|
await driver.fill('#password', 'correct horse battery staple');
|
||||||
|
await driver.press('#password', driver.Key.ENTER);
|
||||||
|
|
||||||
|
const secondaryCurrency = await driver.isElementPresent(
|
||||||
|
'[data-testid="eth-overview__secondary-currency"]',
|
||||||
|
);
|
||||||
|
assert.equal(secondaryCurrency, false, `Secondary currency is present`);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user