mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
4346d7f2c1
A help icon on every screen opens a panel with the screen's overview, its sub-screens, task guides with a framed picture per step, search across guides and the wiki, and a switch to any other screen's help. Guides exist for the dashboard, Vacay, Atlas, Collections, Journey (list, journal, studio), Settings (all tabs), Admin (all tabs) and the trip frame; the trip's own screens are in progress. Pictures are produced by Playwright (client/e2e/help), texts in all 23 languages.
45 lines
1.7 KiB
JavaScript
45 lines
1.7 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))
|
|
const dbFile = path.join(here, '.tmp', 'e2e.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.
|
|
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))
|