-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto logout after specific time (#6558)
* Add i18n strings * Finish Auto timeout * Fix linter * Fix copies * Add unit test to Advanced Tab component * Add back actions and container * Add basic test to ensure container completeness * No zero, fix linters * restrict negative in input
- Loading branch information
1 parent
0497d20
commit 56ed189
Showing
9 changed files
with
188 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
ui/app/pages/settings/advanced-tab/tests/advanced-tab-component.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react' | ||
import assert from 'assert' | ||
import sinon from 'sinon' | ||
import { shallow } from 'enzyme' | ||
import AdvancedTab from '../advanced-tab.component' | ||
import TextField from '../../../../components/ui/text-field' | ||
|
||
describe('AdvancedTab Component', () => { | ||
it('should render correctly', () => { | ||
const root = shallow( | ||
<AdvancedTab />, | ||
{ | ||
context: { | ||
t: s => `_${s}`, | ||
}, | ||
} | ||
) | ||
|
||
assert.equal(root.find('.settings-page__content-row').length, 8) | ||
}) | ||
|
||
it('should update autoLogoutTimeLimit', () => { | ||
const setAutoLogoutTimeLimitSpy = sinon.spy() | ||
const root = shallow( | ||
<AdvancedTab | ||
setAutoLogoutTimeLimit={setAutoLogoutTimeLimitSpy} | ||
/>, | ||
{ | ||
context: { | ||
t: s => `_${s}`, | ||
}, | ||
} | ||
) | ||
|
||
const autoTimeout = root.find('.settings-page__content-row').last() | ||
const textField = autoTimeout.find(TextField) | ||
|
||
textField.props().onChange({ target: { value: 1440 } }) | ||
assert.equal(root.state().autoLogoutTimeLimit, 1440) | ||
|
||
autoTimeout.find('button').simulate('click') | ||
assert.equal(setAutoLogoutTimeLimitSpy.args[0][0], 1440) | ||
}) | ||
}) |
46 changes: 46 additions & 0 deletions
46
ui/app/pages/settings/advanced-tab/tests/advanced-tab-container.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import assert from 'assert' | ||
import { mapStateToProps, mapDispatchToProps } from '../advanced-tab.container' | ||
|
||
const defaultState = { | ||
appState: { | ||
warning: null, | ||
}, | ||
metamask: { | ||
featureFlags: { | ||
sendHexData: false, | ||
advancedInlineGas: false, | ||
}, | ||
preferences: { | ||
autoLogoutTimeLimit: 0, | ||
showFiatInTestnets: false, | ||
useNativeCurrencyAsPrimaryCurrency: true, | ||
}, | ||
}, | ||
} | ||
|
||
describe('AdvancedTab Container', () => { | ||
it('should map state to props correctly', () => { | ||
const props = mapStateToProps(defaultState) | ||
const expected = { | ||
warning: null, | ||
sendHexData: false, | ||
advancedInlineGas: false, | ||
showFiatInTestnets: false, | ||
autoLogoutTimeLimit: 0, | ||
} | ||
|
||
assert.deepEqual(props, expected) | ||
}) | ||
|
||
it('should map dispatch to props correctly', () => { | ||
const props = mapDispatchToProps(() => 'mockDispatch') | ||
|
||
assert.ok(typeof props.setHexDataFeatureFlag === 'function') | ||
assert.ok(typeof props.setRpcTarget === 'function') | ||
assert.ok(typeof props.displayWarning === 'function') | ||
assert.ok(typeof props.showResetAccountConfirmationModal === 'function') | ||
assert.ok(typeof props.setAdvancedInlineGasFeatureFlag === 'function') | ||
assert.ok(typeof props.setShowFiatConversionOnTestnetsPreference === 'function') | ||
assert.ok(typeof props.setAutoLogoutTimeLimit === 'function') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters