mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 05:26:47 +00:00
146fe4a063
The guides of the map, bookings, costs, files, collab, lists, road trip and transports now describe the desktop as it is after the redesign: the bars with their icon buttons and filter popovers, the dialogs with the title in the head band and status and type as pills, the three booking views and the booking detail, the compact note cards, the Costs table. Two guides are new: the booking views (cards, list, timeline, the Trip and Day zoom and the detail) and the Costs table view. Every changed text is translated into every locale, and the Plan tab texts call the bookings tab by the label it shows, Book. Every picture of the thirteen trip screens is taken again against the new layout, on one picture day. Scripts follow the new markup; the Dawarich fixture uploads its recording again when the stored one belongs to another run, and the spare poll gets its vote from a member so its winner shows green. server-launch.mjs skips the server build with E2E_SERVER_PREBUILT, so several recordings on their own port pairs can share one dist.
51 lines
2.1 KiB
JavaScript
51 lines
2.1 KiB
JavaScript
// Boots the TREK backend for the Playwright E2E run against a fresh, isolated
|
|
// SQLite database. The DB file is deleted first so every run starts clean, then
|
|
// the server's own startup seeds a known admin from ADMIN_EMAIL/ADMIN_PASSWORD.
|
|
//
|
|
// The server is built once and launched as a SINGLE node process (not the
|
|
// watch-mode `npm run dev`, which spawns tsc -w + node --watch grandchildren
|
|
// that survive Playwright's teardown and then linger on :3001 with stale DB
|
|
// state). A single child is killed cleanly when Playwright tears the run down.
|
|
import { rmSync } from 'node:fs'
|
|
import { spawn, execSync } from 'node:child_process'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
// The port is in the name, so two runs on two port pairs keep two databases
|
|
// and can render different guide files at the same time.
|
|
const apiPort = process.env.E2E_API_PORT || '3001'
|
|
const dbFile = path.join(here, '.tmp', `e2e-${apiPort}.db`)
|
|
const serverDir = path.join(here, '..', '..', 'server')
|
|
|
|
for (const f of [dbFile, `${dbFile}-wal`, `${dbFile}-shm`]) {
|
|
try { rmSync(f, { force: true }) } catch {}
|
|
}
|
|
|
|
// Build once (no watcher) — the resulting process is a single killable node.
|
|
// Several runs on their own port pairs share one dist, so they build it once
|
|
// beforehand and set E2E_SERVER_PREBUILT: a rebuild under a running server
|
|
// swaps its files mid-flight.
|
|
if (!process.env.E2E_SERVER_PREBUILT) execSync('node scripts/build.mjs', { cwd: serverDir, stdio: 'inherit' })
|
|
|
|
const env = {
|
|
...process.env,
|
|
TREK_DB_FILE: dbFile,
|
|
ADMIN_EMAIL: 'e2e@trek.local',
|
|
ADMIN_PASSWORD: 'E2eTest12345!',
|
|
// playwright.config.ts picks the port; 3001 is the historical default.
|
|
PORT: process.env.E2E_API_PORT || '3001',
|
|
NODE_ENV: 'development',
|
|
}
|
|
|
|
const child = spawn(process.execPath, ['--require', 'tsconfig-paths/register', 'dist/index.js'], {
|
|
cwd: serverDir,
|
|
env,
|
|
stdio: 'inherit',
|
|
})
|
|
const stop = () => { try { child.kill() } catch {} }
|
|
process.on('SIGINT', stop)
|
|
process.on('SIGTERM', stop)
|
|
process.on('exit', stop)
|
|
child.on('exit', code => process.exit(code ?? 0))
|