From 5d84bbd52576331f39cd527e7817df71f7b6a7ba Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 31 Oct 2026 23:44:39 +0100 Subject: [PATCH] test: run e2e tests in WebKit on macOS (#40140) WebKit was removed from the e2e tests in https://github.com/go-gitea/gitea/pull/37315 because Linux WebKit kept crashing. `make test-e2e` on macOS now also runs WebKit, which does not show these crashes there. CI stays on Linux, because macOS runners would need about an extra GB of cache storage. 1. The bot account test clicks the user type dropdown, Safari only moves Tab focus between text fields 1. On macOS, Playwright runs with a single libuv thread, concurrent `getaddrinfo` lookups of `localhost` there sporadically stall for 5s --------- Signed-off-by: silverwind --- Makefile | 2 +- playwright.config.ts | 9 ++++++++- tests/e2e/admin.test.ts | 5 ++--- tools/test-e2e.sh | 5 +++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 45253944181..9a70f903a89 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ SHELLCHECK_IMAGE ?= docker.io/koalaman/shellcheck:v0.11.0@sha256:61862eba1fcf09a CONTAINER_RUNTIME ?= $(shell hash docker >/dev/null 2>&1 && echo docker || echo podman) -PLAYWRIGHT_BROWSERS ?= chromium firefox +PLAYWRIGHT_BROWSERS ?= chromium firefox $(if $(filter Darwin,$(shell uname -s 2>/dev/null)),webkit) PLAYWRIGHT_FLAGS ?= HAS_GO := $(shell hash $(GO) > /dev/null 2>&1 && echo yes) diff --git a/playwright.config.ts b/playwright.config.ts index 7b384b03258..4e52b123037 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,4 +1,4 @@ -import {env} from 'node:process'; +import {env, platform} from 'node:process'; import {defineConfig, devices} from '@playwright/test'; const timeoutFactor = Number(env.GITEA_TEST_E2E_TIMEOUT_FACTOR) || 1; @@ -41,5 +41,12 @@ export default defineConfig({ }, }, }, + ...(platform === 'darwin' ? [{ // webkit on linux is unstable + name: 'webkit', + use: { + ...devices['Desktop Safari'], + permissions: ['clipboard-read'], + }, + }] : []), ], }); diff --git a/tests/e2e/admin.test.ts b/tests/e2e/admin.test.ts index bc1ab6f4673..60cf9fe6a58 100644 --- a/tests/e2e/admin.test.ts +++ b/tests/e2e/admin.test.ts @@ -1,14 +1,13 @@ import {env} from 'node:process'; import {test, expect} from '@playwright/test'; -import {login, randomString} from './utils.ts'; +import {clickDropdownItem, login, randomString} from './utils.ts'; test('create a bot and manage its access token', async ({page, request}) => { const botName = `e2e-bot-${randomString(8)}`; await login(page); await page.goto('/-/admin/users/new'); await page.getByLabel('Username').fill(botName); - await page.getByLabel('Username').press('Tab'); - await page.getByRole('option', {name: 'Bot'}).click(); + await clickDropdownItem(page, page.getByRole('combobox').filter({hasText: 'Bot'}), 'Bot'); await page.getByLabel('Email Address').fill(`${botName}@${env.GITEA_TEST_E2E_DOMAIN}`); await page.getByRole('button', {name: 'Create User Account'}).click(); await page.waitForURL(/\/-\/admin\/users\/\d+$/); diff --git a/tools/test-e2e.sh b/tools/test-e2e.sh index 0b45575274a..d7d083d5b3b 100755 --- a/tools/test-e2e.sh +++ b/tools/test-e2e.sh @@ -190,6 +190,11 @@ export GITEA_TEST_E2E_PASSWORD export GITEA_TEST_E2E_EMAIL export GITEA_TEST_E2E_TIMEOUT_FACTOR +# concurrent localhost lookups on macOS sporadically stall for 5s +if [ "$(uname -s)" = "Darwin" ]; then + export UV_THREADPOOL_SIZE=1 +fi + if [ "$PLAYWRIGHT_MODE" = "container" ]; then export PW_TEST_CONNECT_WS_ENDPOINT="ws://127.0.0.1:${PLAYWRIGHT_SERVER_PORT}/" fi