1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Auto lock e2e (#14624)

* add auto lock e2e test

* fix console errors
This commit is contained in:
PeterYinusa 2022-05-10 17:57:11 +01:00 committed by GitHub
parent 55e88a0e8e
commit f47d02b72a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 4 deletions

View File

@ -0,0 +1,46 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
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: '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);
// Set Auto Lock Timer
await driver.clickElement('.account-menu__icon');
await driver.clickElement({ text: 'Settings', tag: 'div' });
await driver.clickElement({ text: 'Advanced', tag: 'div' });
const sixSecsInMins = '.1';
await driver.fill(
'[data-testid="advanced-setting-auto-lock"] input',
sixSecsInMins,
);
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);
},
);
});
});

View File

@ -67,5 +67,5 @@ UserPreferencedCurrencyDisplay.propTypes = {
PropTypes.string,
PropTypes.number,
]),
showFiat: PropTypes.boolean,
showFiat: PropTypes.bool,
};

View File

@ -375,7 +375,7 @@ export default class AdvancedTab extends PureComponent {
renderAutoLockTimeLimit() {
const { t } = this.context;
const { lockTimeError } = this.state;
const { autoLockTimeLimit, setAutoLockTimeLimit } = this.props;
const { setAutoLockTimeLimit } = this.props;
return (
<div
@ -396,7 +396,6 @@ export default class AdvancedTab extends PureComponent {
id="autoTimeout"
placeholder="5"
value={this.state.autoLockTimeLimit}
defaultValue={autoLockTimeLimit}
onChange={(e) => this.handleLockChange(e.target.value)}
error={lockTimeError}
fullWidth

View File

@ -38,7 +38,7 @@ export const mapStateToProps = (state) => {
const {
showFiatInTestnets,
showTestNetworks,
autoLockTimeLimit,
autoLockTimeLimit = 0,
} = getPreferences(state);
const userHasALedgerAccount = doesUserHaveALedgerAccount(state);