mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-22 01:44:24 +01:00
Parallelize playwright tests
- allow running with multiple workers (tested with up to four workers locally which
didn't show signs of flakiness)
- prevent race condition with webauthn tests (running them in parallel
on the same user could prevent another test from logging in)
- fix flakiness on CI action status (Chromium sometimes needs a long
time to fill the href field, firefox is always faster)
This reverts commit e8585eff5c
.
This commit is contained in:
parent
83e9e9230a
commit
3695f5d096
|
@ -11,18 +11,14 @@ export default {
|
||||||
testDir: './tests/e2e/',
|
testDir: './tests/e2e/',
|
||||||
testMatch: /.*\.test\.e2e\.js/, // Match any .test.e2e.js files
|
testMatch: /.*\.test\.e2e\.js/, // Match any .test.e2e.js files
|
||||||
|
|
||||||
/**
|
// you can adjust this value locally to match your machine's power,
|
||||||
* Only run one test at a time, running multiple could lead to a inconsistent
|
// or pass `--workers x` to playwright
|
||||||
* database state.
|
workers: process.env.CI ? 1 : 2,
|
||||||
*/
|
|
||||||
fullyParallel: false,
|
|
||||||
workers: 1,
|
|
||||||
|
|
||||||
/* Maximum time one test can run for. */
|
/* Maximum time one test can run for. */
|
||||||
timeout: 30 * 1000,
|
timeout: 30 * 1000,
|
||||||
|
|
||||||
expect: {
|
expect: {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum time expect() should wait for the condition to be met.
|
* Maximum time expect() should wait for the condition to be met.
|
||||||
* For example in `await expect(locator).toHaveText();`
|
* For example in `await expect(locator).toHaveText();`
|
||||||
|
@ -34,7 +30,7 @@ export default {
|
||||||
forbidOnly: Boolean(process.env.CI),
|
forbidOnly: Boolean(process.env.CI),
|
||||||
|
|
||||||
/* Retry on CI only */
|
/* Retry on CI only */
|
||||||
retries: process.env.CI ? 2 : 0,
|
retries: process.env.CI ? 1 : 0,
|
||||||
|
|
||||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||||
reporter: process.env.CI ? 'list' : [['list'], ['html', {outputFolder: 'tests/e2e/reports/', open: 'never'}]],
|
reporter: process.env.CI ? 'list' : [['list'], ['html', {outputFolder: 'tests/e2e/reports/', open: 'never'}]],
|
||||||
|
|
|
@ -16,6 +16,6 @@ test('Correct link and tooltip', async ({browser}, workerInfo) => {
|
||||||
|
|
||||||
const repoStatus = page.locator('.dashboard-repos .repo-owner-name-list > li:nth-child(1) > a:nth-child(2)');
|
const repoStatus = page.locator('.dashboard-repos .repo-owner-name-list > li:nth-child(1) > a:nth-child(2)');
|
||||||
|
|
||||||
await expect(repoStatus).toHaveAttribute('href', '/user2/test_workflows/actions');
|
await expect(repoStatus).toHaveAttribute('href', '/user2/test_workflows/actions', {timeout: 10000});
|
||||||
await expect(repoStatus).toHaveAttribute('data-tooltip-content', 'Failure');
|
await expect(repoStatus).toHaveAttribute('data-tooltip-content', 'Failure');
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,12 +6,12 @@ import {expect} from '@playwright/test';
|
||||||
import {test, login_user, load_logged_in_context} from './utils_e2e.js';
|
import {test, login_user, load_logged_in_context} from './utils_e2e.js';
|
||||||
|
|
||||||
test.beforeAll(async ({browser}, workerInfo) => {
|
test.beforeAll(async ({browser}, workerInfo) => {
|
||||||
await login_user(browser, workerInfo, 'user2');
|
await login_user(browser, workerInfo, 'user40');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('WebAuthn register & login flow', async ({browser}, workerInfo) => {
|
test('WebAuthn register & login flow', async ({browser}, workerInfo) => {
|
||||||
test.skip(workerInfo.project.name !== 'chromium', 'Uses Chrome protocol');
|
test.skip(workerInfo.project.name !== 'chromium', 'Uses Chrome protocol');
|
||||||
const context = await load_logged_in_context(browser, workerInfo, 'user2');
|
const context = await load_logged_in_context(browser, workerInfo, 'user40');
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
|
|
||||||
// Register a security key.
|
// Register a security key.
|
||||||
|
@ -45,7 +45,7 @@ test('WebAuthn register & login flow', async ({browser}, workerInfo) => {
|
||||||
response = await page.goto('/user/login');
|
response = await page.goto('/user/login');
|
||||||
await expect(response?.status()).toBe(200);
|
await expect(response?.status()).toBe(200);
|
||||||
|
|
||||||
await page.getByLabel('Username or email address').fill('user2');
|
await page.getByLabel('Username or email address').fill('user40');
|
||||||
await page.getByLabel('Password').fill('password');
|
await page.getByLabel('Password').fill('password');
|
||||||
await page.getByRole('button', {name: 'Sign in'}).click();
|
await page.getByRole('button', {name: 'Sign in'}).click();
|
||||||
await page.waitForURL(`${workerInfo.project.use.baseURL}/user/webauthn`);
|
await page.waitForURL(`${workerInfo.project.use.baseURL}/user/webauthn`);
|
||||||
|
|
Loading…
Reference in a new issue