Skip to content

Commit

Permalink
added a new test and minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ost-ptk committed Nov 17, 2023
1 parent f59616e commit 79fd522
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 74 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,10 @@ You should install Redux DevTools browser extension and connect it to Redux DevT

## E2E tests

Write tests into `e2e/tests` folder.
Write tests into `e2e-tests` folder.

There are a few options to run tests:
To run e2e tests, you must use npm script `npm run e2e:chrome:ui:popup` or `e2e:chrome:ui:onboarding`.
Tests are run in UI mode.

1. In docker container
- Run docker and up containers. `docker compose up` or `docker-compose -f docker-compose.arm.yml up` for Apple M processors
- Use npm scripts `npm run test:e2e:{chrome/firefox}:headless:{popup/onboarding}` depends on target browser and tests
- To see what is happening inside the container, open your web browser and navigate to the URL <http://localhost:7900> for Chrome and <http://localhost:7901> for Firefox, enter the password `secret`, and run your test again
2. Locally on computer
- Use npm scripts `npm run test:e2e:chrome` or `npm run test:e2e:firefox` depends on target browser
All information
about how to run and debug tests can be found in [playwright docs](https://playwright.dev/docs/running-tests).
23 changes: 0 additions & 23 deletions docker-compose.arm.yml

This file was deleted.

23 changes: 0 additions & 23 deletions docker-compose.yml

This file was deleted.

27 changes: 9 additions & 18 deletions e2e-tests/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { PLAYGROUND_URL, vaultPassword } from './constants';
export const test = base.extend<{
context: BrowserContext;
extensionId: string;
createPassword: () => Promise<void>;
}>({
// eslint-disable-next-line no-empty-pattern
context: async ({}, use) => {
Expand Down Expand Up @@ -40,20 +39,6 @@ export const test = base.extend<{
const extensionId = background.url().split('/')[2];

await use(extensionId);
},
createPassword: async ({ page }, use) => {
const createPassword = async () => {
await page
.getByPlaceholder('Password', { exact: true })
.fill(vaultPassword);
await page
.getByPlaceholder('Confirm password', { exact: true })
.fill(vaultPassword);
await page.getByTestId('terms-checkbox').click();
await page.getByRole('button', { name: 'Create password' }).click();
};

await use(createPassword);
}
});

Expand All @@ -69,7 +54,7 @@ export const onboarding = test.extend<{
await page.goto(`chrome-extension://${extensionId}/onboarding.html`);
await use(page);
},
createOnboardingPassword: async ({ page, createPassword }, use) => {
createOnboardingPassword: async ({ page }, use) => {
const createOnboardingPassword = async () => {
await onboardingExpect(
page.getByRole('heading', {
Expand All @@ -81,8 +66,14 @@ export const onboarding = test.extend<{

await onboardingExpect(page).toHaveURL(/.*create-vault-password/);

// Create password
await createPassword();
await page
.getByPlaceholder('Password', { exact: true })
.fill(vaultPassword);
await page
.getByPlaceholder('Confirm password', { exact: true })
.fill(vaultPassword);
await page.getByTestId('terms-checkbox').click();
await page.getByRole('button', { name: 'Create password' }).click();
};

await use(createOnboardingPassword);
Expand Down
26 changes: 24 additions & 2 deletions e2e-tests/popup/common/wallet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ popup.describe('Popup UI: lock/unlock/reset wallet', () => {
}
);

popup('should reset wallet', async ({ context, popupPage, extensionId }) => {
await popupPage.goto(`chrome-extension://${extensionId}/popup.html`);
popup('should reset wallet', async ({ context, popupPage }) => {
await popupExpect(
popupPage.getByText('Your wallet is locked')
).toBeVisible();
Expand Down Expand Up @@ -56,4 +55,27 @@ popup.describe('Popup UI: lock/unlock/reset wallet', () => {
})
).toBeVisible();
});

popup(
'should lock wallet for 5 minutes when user types wrong password 5 times',
async ({ popupPage }) => {
await popupExpect(
popupPage.getByText('Your wallet is locked')
).toBeVisible();

await popupPage
.getByPlaceholder('Password', { exact: true })
.fill('wrong password');

for (let i = 0; i < 5; i++) {
await popupPage.getByRole('button', { name: 'Unlock wallet' }).click();
}

await popupExpect(
popupPage.getByRole('heading', {
name: 'Please wait before the next attempt to unlock your wallet'
})
).toBeVisible();
}
);
});

0 comments on commit 79fd522

Please sign in to comment.