mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-28 23:06:37 +01:00
bd12ea733a
The autolock field on the Settings screen — the field that allows users to set the duration that MetaMask will wait for until automatically locking — does not always accept decimal numbers. This breaks the e2e test for this feature as it attempts to set this field to "0.1". More specifically, the React component responsible for this field passes whatever the user inputs through the `Number` function immediately and then uses this to repopulate the input. Therefore, if the user enters "3" followed by a ".", `Number("3.")` will be called. This evaluates to the number 3, and "3" becomes the new value of the field. As a result, the "." can never be typed. Curiously, this behavior only happens in Firefox; Chrome seems to keep the "." in the input field when it's typed. This happens because `onChange` event doesn't seem to get fired until a number is typed *after* the ".". This may be due to underlying differences in the DOM between Chrome and Firefox. Regardless, always passing the input through `Number` creates other odd behavior, such as the fact that the input can never be cleared (because `Number("")` evaluates to 0). This commit solves these problems by saving the "raw" version of the user's input as well as the normalized version. The raw version is always used to populate the input, whereas the normalized version is saved in state.
57 lines
2.1 KiB
JavaScript
57 lines
2.1 KiB
JavaScript
const { strict: assert } = require('assert');
|
|
const { convertToHexValue, withFixtures } = require('../helpers');
|
|
const FixtureBuilder = require('../fixture-builder');
|
|
|
|
describe('Auto-Lock Timer', function () {
|
|
const ganacheOptions = {
|
|
accounts: [
|
|
{
|
|
secretKey:
|
|
'0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9',
|
|
balance: convertToHexValue(25000000000000000000),
|
|
},
|
|
],
|
|
};
|
|
|
|
it('should automatically lock the wallet once the idle time has elapsed', async function () {
|
|
await withFixtures(
|
|
{
|
|
fixtures: new FixtureBuilder().build(),
|
|
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);
|
|
// Set Auto Lock Timer
|
|
await driver.clickElement(
|
|
'[data-testid="account-options-menu-button"]',
|
|
);
|
|
await driver.clickElement({ text: 'Settings', tag: 'div' });
|
|
await driver.clickElement({ text: 'Advanced', tag: 'div' });
|
|
const sixSecsInMins = '0.1';
|
|
const autoLockTimerInput = await driver.findElement(
|
|
'[data-testid="advanced-setting-auto-lock"] input',
|
|
);
|
|
await driver.scrollToElement(autoLockTimerInput);
|
|
await autoLockTimerInput.fill(10081);
|
|
await driver.waitForSelector({
|
|
css: '#autoTimeout-helper-text',
|
|
text: 'Lock time must be a number between 0 and 10080',
|
|
});
|
|
await autoLockTimerInput.fill(sixSecsInMins);
|
|
await driver.assertElementNotPresent('#autoTimeout-helper-text');
|
|
await driver.clickElement(
|
|
'[data-testid="advanced-setting-auto-lock"] button',
|
|
);
|
|
// Verify the wallet is loccked
|
|
const pageTitle = await driver.findElement('.unlock-page__title');
|
|
const unlockButton = await driver.findElement('.unlock-page button');
|
|
assert.equal(await pageTitle.getText(), 'Welcome back!');
|
|
assert.equal(await unlockButton.isDisplayed(), true);
|
|
},
|
|
);
|
|
});
|
|
});
|