Skip to content
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ Here's how to run the test suite:

- E2E test environment variables

| Variable | Description |
| :------------------------ | :---------------------------------------------------------------- |
| ``GITEA_TEST_E2E_DEBUG`` | When set, show Gitea server output |
| ``GITEA_TEST_E2E_FLAGS`` | Additional flags passed to Playwright, for example ``--ui`` |
| Variable | Description |
| :-------------------------------- | :---------------------------------------------------------- |
| ``GITEA_TEST_E2E_DEBUG`` | When set, show Gitea server output |
| ``GITEA_TEST_E2E_FLAGS`` | Additional flags passed to Playwright, for example ``--ui`` |
| ``GITEA_TEST_E2E_TIMEOUT_FACTOR`` | Timeout multiplier (default: 3 on CI, 1 locally) |

## Translation

Expand Down
11 changes: 7 additions & 4 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import {env} from 'node:process';
import {defineConfig, devices} from '@playwright/test';

const timeoutFactor = Number(env.GITEA_TEST_E2E_TIMEOUT_FACTOR) || 1;
const timeout = 5000 * timeoutFactor;

export default defineConfig({
testDir: './tests/e2e/',
outputDir: './tests/e2e-output/',
testMatch: /.*\.test\.ts/,
forbidOnly: Boolean(env.CI),
reporter: 'list',
timeout: env.CI ? 12000 : 6000,
timeout: 2 * timeout,
expect: {
timeout: env.CI ? 6000 : 3000,
timeout,
},
use: {
baseURL: env.GITEA_TEST_E2E_URL?.replace?.(/\/$/g, ''),
locale: 'en-US',
actionTimeout: env.CI ? 6000 : 3000,
navigationTimeout: env.CI ? 12000 : 6000,
actionTimeout: timeout,
navigationTimeout: 2 * timeout,
},
projects: [
{
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e/events.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {env} from 'node:process';
import {test, expect} from '@playwright/test';
import {loginUser, baseUrl, apiUserHeaders, apiCreateUser, apiDeleteUser, apiCreateRepo, apiCreateIssue, apiStartStopwatch} from './utils.ts';

const timeoutFactor = Number(env.GITEA_TEST_E2E_TIMEOUT_FACTOR) || 1;

// These tests rely on a short EVENT_SOURCE_UPDATE_TIME in the e2e server config.
test.describe('events', () => {
test('notification count', async ({page, request}) => {
Expand All @@ -23,7 +26,7 @@ test.describe('events', () => {
await apiCreateIssue(request, owner, repoName, {title: 'events notification test', headers: apiUserHeaders(commenter)});

// Wait for the notification badge to appear via server event
await expect(badge).toBeVisible({timeout: 15000});
await expect(badge).toBeVisible({timeout: 15000 * timeoutFactor});

Comment thread
silverwind marked this conversation as resolved.
// Cleanup
await Promise.all([apiDeleteUser(request, commenter), apiDeleteUser(request, owner)]);
Expand Down
10 changes: 10 additions & 0 deletions tools/test-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,20 @@ GITEA_TEST_E2E_EMAIL="$GITEA_TEST_E2E_USER@$GITEA_TEST_E2E_DOMAIN"
--must-change-password=false \
--admin

# timeout multiplier, CI runners are slower
if [ -z "${GITEA_TEST_E2E_TIMEOUT_FACTOR:-}" ]; then
if [ -n "${CI:-}" ]; then
GITEA_TEST_E2E_TIMEOUT_FACTOR=3
else
GITEA_TEST_E2E_TIMEOUT_FACTOR=1
fi
fi

export GITEA_TEST_E2E_URL="$E2E_URL"
export GITEA_TEST_E2E_DOMAIN
export GITEA_TEST_E2E_USER
export GITEA_TEST_E2E_PASSWORD
export GITEA_TEST_E2E_EMAIL
export GITEA_TEST_E2E_TIMEOUT_FACTOR

pnpm exec playwright test "$@"
Loading