-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: isolate lock wallet test (#1431)
- Closes #1433
- Loading branch information
1 parent
737652b
commit c1d3dd6
Showing
7 changed files
with
174 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"fuels-wallet": patch | ||
--- | ||
|
||
feat: run e2e test of Lock CRX isolated and remove from regular flow to increase its speed |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// biome-ignore lint/style/useNodejsImportProtocol: <explanation> | ||
import { join } from 'path'; | ||
import { defineConfig } from '@playwright/test'; | ||
import { playwrightConfig } from './playwright.config'; | ||
|
||
export default defineConfig({ | ||
...playwrightConfig, | ||
testMatch: join(__dirname, './playwright/crx/lock.test.ts'), | ||
testIgnore: undefined, | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { | ||
getButtonByText, | ||
getByAriaLabel, | ||
getElementByText, | ||
hasText, | ||
reload, | ||
} from '../commons'; | ||
import { WALLET_PASSWORD } from '../mocks'; | ||
|
||
import { test } from './utils'; | ||
|
||
// Increase timeout for this test | ||
// The timeout is set for 2 minutes | ||
// because some tests like reconnect | ||
// can take up to 1 minute before it's reconnected | ||
test.setTimeout(180_000); | ||
|
||
test.describe('Lock FuelWallet after inactivity', () => { | ||
test('should lock the wallet after 1 minute of inactivity (config in .env file)', async ({ | ||
context, | ||
baseURL, | ||
extensionId, | ||
}) => { | ||
// Use a single instance of the page to avoid | ||
// multiple waiting times, and window.fuel checking. | ||
const blankPage = await context.newPage(); | ||
|
||
// Open a blank html in order for the CRX | ||
// to inject fuel on the window. This is required | ||
// because the CRX is injected after load state of | ||
// the page. | ||
await blankPage.goto(new URL('e2e.html', baseURL).href); | ||
|
||
await test.step('Has window.fuel', async () => { | ||
const hasFuel = await blankPage.evaluate(async () => { | ||
// wait for the script to load | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
return typeof window.fuel === 'object'; | ||
}); | ||
expect(hasFuel).toBeTruthy(); | ||
}); | ||
|
||
await test.step('Create wallet', async () => { | ||
const pages = context.pages(); | ||
const [page] = pages.filter((page) => page.url().includes('sign-up')); | ||
await reload(page); | ||
await getElementByText(page, /Create new wallet/i).click(); | ||
|
||
/** Accept terms */ | ||
await hasText(page, /Terms of use Agreement/i); | ||
const agreeCheckbox = getByAriaLabel(page, 'Agree with terms'); | ||
await agreeCheckbox.click(); | ||
await getButtonByText(page, /Next: Seed Phrase/i).click(); | ||
|
||
/** Copy Mnemonic */ | ||
await hasText(page, /Write down seed phrase/i); | ||
await getButtonByText(page, /Copy/i).click(); | ||
const savedCheckbox = getByAriaLabel(page, 'Confirm Saved'); | ||
await savedCheckbox.click(); | ||
await getButtonByText(page, /Next/i).click(); | ||
|
||
/** Confirm Mnemonic */ | ||
await hasText(page, /Confirm phrase/i); | ||
await getButtonByText(page, /Paste/i).click(); | ||
await getButtonByText(page, /Next/i).click(); | ||
|
||
/** Adding password */ | ||
await hasText(page, /Create password for encryption/i); | ||
const passwordInput = getByAriaLabel(page, 'Your Password'); | ||
await passwordInput.fill(WALLET_PASSWORD); | ||
await passwordInput.press('Tab'); | ||
const confirmPasswordInput = getByAriaLabel(page, 'Confirm Password'); | ||
await confirmPasswordInput.fill(WALLET_PASSWORD); | ||
await confirmPasswordInput.press('Tab'); | ||
|
||
await getButtonByText(page, /Next/i).click(); | ||
|
||
/** Account created */ | ||
await hasText(page, /Wallet created successfully/i, 0, 15000); | ||
await page.close(); | ||
}); | ||
|
||
const popupPage = await test.step('Open wallet', async () => { | ||
const page = await context.newPage(); | ||
await page.goto(`chrome-extension://${extensionId}/popup.html`); | ||
await hasText(page, /Assets/i); | ||
return page; | ||
}); | ||
|
||
await test.step('Auto lock fuel wallet', async () => { | ||
await getByAriaLabel(popupPage, 'Accounts').click(); | ||
await popupPage.waitForTimeout(65_000); | ||
await hasText(popupPage, 'Unlock your wallet to continue'); | ||
}); | ||
}); | ||
}); |