Files
noitu/web/playwright.config.js
T
tiennm99 e162574556 test(e2e): drive both modes through a real browser
Twenty-one Playwright specs against the real binary serving the real bundle: a
bot game with its rejections, an online game across two browser contexts, and
the reconnect path. The server plays against the fixture dictionary, so nothing
here downloads the upstream release.

Every wait is on a state the server produced — the turn indicator, the required
syllable, a word appearing in the chain — never a sleep. Moves are chosen by
reading the same wordlist the server has rather than scripting a fixed
sequence, because the bot is entitled to pick a different reply.

Two things that do not work are recorded where the next person will look.
Offline emulation does not cut a loopback socket, so a test that went offline
kept playing happily. Routing the socket cuts it for real, but the close does
not reliably reach the server, so the grace window never starts: those tests
take the page away instead.
2026-09-05 14:18:18 +07:00

56 lines
1.7 KiB
JavaScript

import { defineConfig, devices } from '@playwright/test';
const PORT = 4173;
/**
* CI installs Playwright's own Chromium. Some machines cannot reach that
* download, so a locally installed browser can be used instead by setting
* PLAYWRIGHT_CHANNEL=chrome (or msedge). Both drive the same engine.
*/
const channel = process.env.PLAYWRIGHT_CHANNEL;
export default defineConfig({
testDir: './e2e',
// A whole game per test, including a bot that deliberately pauses to think.
timeout: 60_000,
expect: { timeout: 10_000 },
fullyParallel: false,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: 1,
reporter: process.env.CI ? [['github'], ['list']] : [['list']],
use: {
baseURL: `http://localhost:${PORT}`,
trace: 'retain-on-failure',
...devices['Desktop Chrome'],
...(channel ? { channel } : {})
},
projects: [{ name: 'chromium' }],
// The real binary, serving the real built frontend, against the fixture
// dictionary. Nothing here downloads the 179 MB upstream release.
webServer: {
command: 'go run ./cmd/noitu-server',
cwd: '../server',
url: `http://localhost:${PORT}/healthz`,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
stdout: 'pipe',
stderr: 'pipe',
env: {
NOITU_ADDR: `:${PORT}`,
NOITU_DB_PATH: '../data/fixture.db',
NOITU_WEB_DIR: '../web/build',
// Long enough that no test races the turn clock. Timeout behaviour
// has its own server-side test; here it would only cause flakes.
NOITU_TURN_LIMIT: '120s',
// Long enough that a client which notices a dead socket on its own
// liveness check still has time to come back, and short enough to
// wait out in the forfeit test.
NOITU_GRACE: '25s'
}
}
});