Files
Oxicloud/tests/e2e/playwright.config.ts
T
Edouard Vanbelle ed99b08e62 feat(DPoP): UI: bcast events to support multi tab
add also playwright test with the multi tab
2026-08-09 01:56:07 +02:00

80 lines
2.9 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test';
import * as path from 'path';
import { loadEnv } from './load-env';
const startScript = path.join(__dirname, 'start-server.sh');
const commonEnv = loadEnv(path.join(__dirname, '../common/server.env'));
console.log(`starting playwright with env BUILD_TARGET=${process.env.BUILD_TARGET ?? "debug"}`);
const workspace=process.env.GITHUB_WORKSPACE ?? path.join(__dirname, '../..');
export default defineConfig({
testDir: './scenarios',
fullyParallel: false,
forbidOnly: !!process.env.CI,
retries: 0,
workers: 1,
reporter: process.env.CI ? [['line'], ['github'], ['html']] : [ ['list'], ['html']],
globalSetup: require.resolve('./global-setup'),
globalTeardown: require.resolve('./global-teardown'),
use: {
// 127.0.0.1, not `localhost`: the server binds IPv4 (127.0.0.1:8087) and
// on CI runners `localhost` resolves to ::1 (IPv6) first, so requests get
// ECONNREFUSED and the webServer readiness check below times out.
baseURL: 'http://127.0.0.1:8087',
trace: 'on-first-retry',
headless: true,
// take a screenshot on failure
screenshot: 'only-on-failure',
// Tile/file rows expose a `data-testid` of the item name (kept only in e2e
// builds via VITE_E2E); makes getByTestId + codegen prefer stable selectors.
testIdAttribute: 'data-testid',
},
expect: {
toHaveScreenshot: { maxDiffPixelRatio: 0.01 },
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
webServer: {
command: process.env.BUILD_TARGET
? `bash "${startScript}" "${workspace}/target/${process.env.BUILD_TARGET}/oxicloud"`
: `bash "${startScript}" cargo run`,
// Poll the dedicated readiness probe, not `/`: `/ready` returns 200 as soon
// as the DB pool is live, whereas `/` depends on the SPA build being present
// and can 404 (Playwright only treats 2xx/3xx/400-403 as "ready").
url: 'http://127.0.0.1:8087/ready',
timeout: 600_000,
reuseExistingServer: false,
cwd: '../..',
stdout: 'inherit',
stderr: 'inherit',
env: {
...commonEnv,
OXICLOUD_SERVER_PORT: '8087',
OXICLOUD_STORAGE_PATH: './tests/e2e/storage',
// Verbose startup so a CI webServer-readiness timeout shows where the
// server stalls (DB connect, migrations, bind) instead of nothing.
RUST_LOG: 'info,oxicloud=debug,sqlx=warn,tower_http=info',
// OPAQUE + DPoP are inherited from `../common/server.env`:
// OXICLOUD_AUTH_OPAQUE_MODE=migrate (Phase 2 silent-migration
// on first legacy login, Phase 4 refusal thereafter)
// OXICLOUD_DPOP_MODE=required (verify every proof; unbound
// sessions still exempt per Gate 5 design)
// Testing under the production shape catches breakage where the
// SPA's fetch interceptor or the migration hook regresses in
// ways that only surface in a real browser + real crypto.
},
},
});