test: add full playwright ui regression coverage
Some checks failed
docker-images / build-and-push (admin, admin, termi-astro-admin, admin/Dockerfile) (push) Successful in 52s
docker-images / build-and-push (backend, backend, termi-astro-backend, backend/Dockerfile) (push) Failing after 13s
docker-images / build-and-push (frontend, frontend, termi-astro-frontend, frontend/Dockerfile) (push) Successful in 32s
ui-regression / playwright-regression (push) Failing after 14m24s

This commit is contained in:
2026-04-02 00:55:34 +08:00
parent 7de4ddc3ee
commit ee0bec4a78
32 changed files with 5100 additions and 336 deletions

View File

@@ -0,0 +1,92 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig, devices } from '@playwright/test'
const mockBaseUrl = 'http://127.0.0.1:5159'
const frontendBaseUrl = 'http://127.0.0.1:4321'
const adminBaseUrl = 'http://127.0.0.1:4322'
const isCi = Boolean(process.env.CI)
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const repoRoot = path.resolve(__dirname, '..')
export default defineConfig({
testDir: './tests',
fullyParallel: false,
workers: 1,
timeout: 60_000,
expect: {
timeout: 12_000,
},
reporter: [['list'], ['html', { open: 'never' }]],
use: {
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
headless: true,
},
projects: [
{
name: 'frontend',
testMatch: /frontend\.spec\.ts/,
use: {
...devices['Desktop Chrome'],
channel: isCi ? undefined : 'msedge',
baseURL: frontendBaseUrl,
},
},
{
name: 'admin',
testMatch: /admin\.spec\.ts/,
use: {
...devices['Desktop Chrome'],
channel: isCi ? undefined : 'msedge',
baseURL: adminBaseUrl,
},
},
],
webServer: [
{
command: 'node ./mock-server.mjs',
cwd: __dirname,
url: `${mockBaseUrl}/__playwright/health`,
reuseExistingServer: !isCi,
stdout: 'pipe',
stderr: 'pipe',
env: {
...process.env,
PLAYWRIGHT_MOCK_PORT: '5159',
PLAYWRIGHT_FRONTEND_ORIGIN: frontendBaseUrl,
PLAYWRIGHT_ADMIN_ORIGIN: adminBaseUrl,
},
},
{
command: 'pnpm dev --host 127.0.0.1 --port 4321',
cwd: path.resolve(repoRoot, 'frontend'),
url: frontendBaseUrl,
reuseExistingServer: !isCi,
stdout: 'pipe',
stderr: 'pipe',
env: {
...process.env,
PUBLIC_API_BASE_URL: `${mockBaseUrl}/api`,
INTERNAL_API_BASE_URL: `${mockBaseUrl}/api`,
PUBLIC_IMAGE_ALLOWED_HOSTS: '127.0.0.1:5159,127.0.0.1',
},
},
{
command: 'pnpm dev --host 127.0.0.1 --port 4322',
cwd: path.resolve(repoRoot, 'admin'),
url: adminBaseUrl,
reuseExistingServer: !isCi,
stdout: 'pipe',
stderr: 'pipe',
env: {
...process.env,
VITE_API_BASE: mockBaseUrl,
VITE_FRONTEND_BASE_URL: frontendBaseUrl,
},
},
],
})