Skip to content

Commit

Permalink
wallet-ext: add auto lock e2e test (MystenLabs#9264)
Browse files Browse the repository at this point in the history
## Description 

* update auto lock interval to 1 minute
* wait 1 minute
* set app is in background
* check wallet is locked

Note this test only runs on CI (when CI env variable is `true`) since it
takes at least 1 minute to finish.

part of APPS-330
  • Loading branch information
pchrysochoidis authored Mar 24, 2023
1 parent 69200b1 commit 53c339b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function AutoLockTimerSelector() {
step="1"
actionDisabled="auto"
actionText="Save"
placeholder="Auto lock minutes"
/>
</Form>
</Formik>
Expand Down
24 changes: 24 additions & 0 deletions apps/wallet/tests/lock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,27 @@ test('wallet unlock', async ({ page, context, extensionUrl }) => {
await page.getByRole('button', { name: /Unlock Wallet/ }).click();
await expect(page.getByTestId('coin-page')).toBeVisible();
});

test('wallet auto-lock', async ({ page, extensionUrl }) => {
test.skip(
process.env.CI !== 'true',
'Runs only on CI since it takes at least 1 minute to complete'
);
test.setTimeout(65 * 1000);
await createWallet(page, extensionUrl);
await page.getByTestId('menu').click();
await page.getByText(/Auto-lock/).click();
await page.getByPlaceholder(/Auto lock minutes/i).fill('1');
await page.getByRole('button', { name: /Save/i }).click();
await page.getByText(/Auto lock updated/i);
await page.evaluate(() => {
Object.defineProperty(document, 'visibilityState', {
value: 'hidden',
});
document.dispatchEvent(new Event('visibilitychange'));
});
await page.waitForTimeout(60 * 1000);
await expect(
page.getByRole('button', { name: /Unlock Wallet/ })
).toBeVisible();
});

0 comments on commit 53c339b

Please sign in to comment.