Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,11 @@ jobs:
name: Browser Journeys (${{ matrix.part }}/8)
runs-on: ubuntu-latest
# A part aims for 10 minutes or less. One hung once (2026-10-31) and would have held its machine
# for GitHub's default six hours. Playwright's own limit (playwright.config.ts globalTimeout, 25
# minutes) ends a hung run first, as a failure, so its report is still kept; this one catches a
# hang outside the tests.
timeout-minutes: 30
# for GitHub's default six hours. Playwright's own limit (playwright.config.ts globalTimeout, 16
# minutes) ends a hung run first, as a failure, so its report is still kept; the run step's own
# 18 minutes stop one Playwright itself froze in (2026-11-22: 28 minutes silent, cancelling did
# nothing), and this one a hang outside the tests. It was 30, with Playwright's at 25 (8n4).
timeout-minutes: 22
strategy:
# Every part runs to the end, so one failure never hides another's.
fail-fast: false
Expand Down Expand Up @@ -242,12 +243,30 @@ jobs:

- name: Run the journeys
working-directory: ./e2e
# Enforced by GitHub's runner, not by Playwright: a part whose Playwright froze still ends here (8n4).
timeout-minutes: 18
# The frontend built once and served whole (playwright.config.ts E2E_BUILT), not file by file by the dev
# server: with the boot no longer played in every fresh tab (tests/helpers.ts skipBoot), a third of the time.
env:
E2E_BUILT: '1'
run: npx playwright test --shard=${{ matrix.part }}/8 --fully-parallel

# How long each journey took (8n4, e2e/timings.js): the slowest ten on the run's summary page, and every test's time
# kept for 30 days, so the parts can be shared out by time. Passed or failed, so a slow failure shows too.
- name: Time the journeys
if: always()
working-directory: ./e2e
run: node timings.js results/report.json ${{ matrix.part }} results/timings-part-${{ matrix.part }}.json >> "$GITHUB_STEP_SUMMARY"

- name: Keep the journeys' times
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-timings-${{ matrix.part }}
path: e2e/results/timings-part-${{ matrix.part }}.json
if-no-files-found: ignore
retention-days: 30

# What failed and why: screenshots, a trace of every step, and the HTML report, one per part.
- name: Keep the report of a failed run
if: failure()
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ frontend/src/*.bak
e2e/test-results/
e2e/playwright-report/
e2e/.built/
e2e/results/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Under the hood

- **The browser journeys' times on CI, and a hang caught sooner.** Each of the eight parts now lists its slowest ten tests on the run's summary page and keeps every test's time for 30 days, so the parts can later be shared out by time rather than by count. A frozen part now fails at 16 to 18 minutes rather than sitting for up to 30, and the frontend server no longer logs a harmless error with a stack trace every time a browser window closes.
- **What a shop buys, on the server.** Each kind of shop, the app's and a game's own, can buy WHAT IT SELLS (as every shop always has) or ANYTHING: a Fence or a pawn shop takes every priced thing at its building's buyback rate, and the shop window's SELL list offers it all. Carried by the system file. The builder's BUYS setting comes with the game's own shops on FEATURES.
- **A game's own kinds of shop, on the server.** A system can now make shops of its own (an Apothecary, a Fence), each with a name and on or off, carried by the system file. An item type's SOLD AT can tick them, a building can be one, and it sells the types that tick it at their prices. Off, or in a game that doesn't make it, a building set to it is no shop. The builder's SOLD AT, + NEW SHOP and the BUILDING TYPE list come next.
- **PLAYERS CHANGE GEAR, on the server.** A table setting (on to start) for systems with their own item types: switched off, the server keeps every column of a player's gear lines as it was saved, and a thing a player adds comes without column values, while their names, counts and where they carry things still change. The GM can always change them. The GAME tab's switch and the sheet's side come next.
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ CITY_NET/
│ ├── npc_rolls.test.js # Rolling from an NPC's sheet: the GM from any NPC, a player from the friendly NPC given to them, the log naming the NPC; anyone else ignored
│ ├── npc_attacks.test.js # Attacking as an NPC in CWN, Shadowrun and Cyberpunk RED: its own sheet, wounds and position, the GM for any NPC and a controller for theirs, the log naming both
│ ├── e2e_names.test.js # Each browser journey's system and player names its own: on CI, tests sharing a database and a name clash
│ ├── e2e_timings.test.js # The journeys' times on CI (8n4, e2e/timings.js): every test, in describe blocks too, slowest first with its tries added; the summary table with failures and retries said, only the slowest ten; run as CI runs it, and a part with no report not failing the step
│ ├── readme_structure.test.js # This tree held to the files on disk: every backend and frontend source and test file named in its own folder, and no line naming a file that has gone. Reads the tree by indentation into full paths
│ ├── system_isolation.test.js # The CWN work kept out of the other systems where rolls are resolved and sheets written, so widening the shared engine has to be deliberate (the browser half is in components/__tests__/systemIsolation.test.tsx)
│ ├── bank_own_account.test.js # The bank's player handlers acting on the sender's own account only, where they used to act on whatever name the message carried; the ordinary cases unchanged
Expand Down Expand Up @@ -1440,6 +1441,7 @@ CITY_NET/
│ │ │ └── setup.ts # Loaded before every frontend test: Testing Library's DOM matchers
│ │ ├── __tests__/
│ │ │ ├── App.smoke.test.tsx # The app mounts without throwing and draws the sidebar and canvas area, so a broken import or a crash on first render fails here; says its theme where an open sheet tab hears it (8s1a)
│ │ │ ├── viteLogger.test.ts # The dev and preview servers' logger (8n4, vite.config.ts): a closed browser's EPIPE and ECONNRESET on the socket's proxy dropped, every other error still said
│ │ │ ├── SheetSurfaces.test.tsx # The standalone tab and SHEET.EXE are one sheet (8s1a): the same play props (those still to come named with their piece), each action on the tab sent as the window's, refusals and recovery reaching it, in the theme and following it, signed in after a refresh, CONNECTION LOST, only own rolls; IMPORT where the system can import on both and IMPORT.EXE from the tab, what the GM gives said on the tab (8s1b); LEVEL_UP.EXE and NEW_CHARACTER.EXE opening on the tab (8s1c); every prop the window gives, the tab gives too, none left to come, the asks of the main window and the vehicle badge on the tab (8s1d); the vitals strip on both, each with its own sign-in (8s3b); FIRE (onGearCount) on both (8a4b)
│ │ │ ├── BattleMapScene.test.tsx # Which loader a map goes to — the whole of the animated-map change, and previously uncovered since the app smoke test mocks the scene away. A loop must not reach `useLoader`, which suspends with nothing above it to catch that
│ │ │ ├── battleMapMedia.test.ts # Still or loop, including the trap where the last dot is in the query string rather than the filename
Expand Down Expand Up @@ -1503,10 +1505,11 @@ CITY_NET/
│ ├── COVERAGE.md # Every option a GM can set in the builder, its server tests, and the browser test proving it at the table (AT THE TABLE / BUILDER ONLY / GAP), with the gaps in the order Phase 7 closes them; updated by every piece that adds or changes an option
│ ├── README.md # How to install and run the journeys, read a failure, and write a new one
│ ├── package.json # Playwright's test runner, and nothing else
│ ├── playwright.config.ts # Starts both servers (Secure Mode on, a temp database, the test GM), one worker, the installed Chrome locally or Playwright's Chromium in CI; with E2E_BUILT=1 (CI) the frontend built once into e2e/.built and served by vite preview rather than file by file
│ ├── playwright.config.ts # Starts both servers (Secure Mode on, a temp database, the test GM), one worker, the installed Chrome locally or Playwright's Chromium in CI; with E2E_BUILT=1 (CI) the frontend built once into e2e/.built and served by vite preview rather than file by file; on CI a whole part stops at 16 minutes, and a JSON report is written for timings.js (8n4)
│ ├── fixtures/
│ │ └── emberline.citysys # A random system from the test generator, exported as the builder does: the file INSTALL A FILE is given in builder-clicks
│ ├── cleanup.ts # Before a run, the throwaway databases earlier runs left in the temp folder
│ ├── timings.js # How long each journey took on CI (8n4): Playwright's JSON report read into every test's time over its tries, slowest first; the slowest ten as a table on the run's summary page, every test's time kept as the part's file; a part with no report says so
│ └── tests/
│ ├── helpers.ts # Signing in as the GM or a player, the GAME tab, the builder past its tour, a rail button (pointer moved off after), a builder page; a tab of an open character sheet (sheetTab); a running system and an approved player through the API; skipBoot, each tab started as one that has played the boot sequence
│ ├── acceleration-notice.spec.ts # HARDWARE ACCELERATION IS OFF: a browser offering only slow drawing is told how to turn acceleration on, and DISMISS keeps it gone after a reload; SYSTEM_INFO's MAP SLOW? holds the steps, and WARN ME, off since DISMISS, brings it back
Expand Down
94 changes: 94 additions & 0 deletions backend/__tests__/e2e_timings.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* How long each browser journey took on CI (8n4, e2e/timings.js): Playwright's JSON report read into every test's time,
* slowest first, retries counted in; the slowest ten as a table for the run's summary page; and a part that wrote no
* report says so without failing the step.
*/

import { describe, it, expect } from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import { execFileSync } from 'child_process';
import { createRequire } from 'module';
import { fileURLToPath } from 'url';

const SCRIPT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'e2e', 'timings.js');
const { rowsOf, summaryOf, clock, SHOWN } = createRequire(import.meta.url)(SCRIPT);

const spec = (file, line, title, durations, status = 'expected') => ({ title, file, line, tests: [{ status, results: durations.map((duration, retry) => ({ duration, retry })) }] });
const REPORT = {
suites: [
{ title: 'a.spec.ts', file: 'a.spec.ts', specs: [spec('a.spec.ts', 8, 'quick one', [3400])],
// A describe block inside the file: its tests are found too.
// Each spec names its own file, as Playwright's do.
suites: [{ title: 'in a block', specs: [spec('a.spec.ts', 30, 'slow | piped', [61000])] }] },
{ title: 'b.spec.ts', file: 'b.spec.ts', specs: [spec('b.spec.ts', 12, 'flaky one', [120000, 9500], 'flaky'), spec('b.spec.ts', 50, 'broken one', [8000, 7000], 'unexpected')] },
],
};

describe('the times', () => {
it('every test, in blocks too, slowest first, its tries added together and counted', () => {
expect(rowsOf(REPORT)).toEqual([
{ file: 'b.spec.ts', line: 12, title: 'flaky one', seconds: 129.5, tries: 2, outcome: 'flaky' },
{ file: 'a.spec.ts', line: 30, title: 'slow | piped', seconds: 61, tries: 1, outcome: 'expected' },
{ file: 'b.spec.ts', line: 50, title: 'broken one', seconds: 15, tries: 2, outcome: 'unexpected' },
{ file: 'a.spec.ts', line: 8, title: 'quick one', seconds: 3.4, tries: 1, outcome: 'expected' },
]);
expect(rowsOf({})).toEqual([]);
});

it('as a person reads a duration', () => {
expect(clock(42.4)).toBe('42s');
expect(clock(231)).toBe('3m 51s');
expect(clock(60)).toBe('1m 0s');
});
});

describe('the summary page', () => {
it('the part, its tests and their time; the slowest as a table, a failure and a retry said', () => {
const text = summaryOf(rowsOf(REPORT), 5);
expect(text.split('\n')).toEqual([
'### Browser Journeys, part 5: 4 tests, 3m 29s of testing',
'',
'The slowest 4:',
'',
'| SECONDS | TRIES | TEST |',
'|---:|---:|---|',
'| 129.5 | 2 | b.spec.ts:12 flaky one (passed on a retry) |',
'| 61.0 | 1 | a.spec.ts:30 slow \\| piped |',
'| 15.0 | 2 | b.spec.ts:50 broken one **FAILED** |',
'| 3.4 | 1 | a.spec.ts:8 quick one |',
'',
]);
});

it('only the slowest ten; a part with none says so', () => {
expect(SHOWN).toBe(10);
const many = { suites: [{ file: 'm.spec.ts', specs: Array.from({ length: 14 }, (_, n) => spec('m.spec.ts', n + 1, `t${n}`, [1000 * (n + 1)])) }] };
const text = summaryOf(rowsOf(many), 2);
expect(text).toContain('14 tests');
expect(text).toContain('The slowest 10:');
expect(text.split('\n').filter((l) => l.startsWith('| ') && !l.startsWith('| SECONDS'))).toHaveLength(10);
expect(summaryOf(rowsOf({ suites: [{ file: 'o.spec.ts', specs: [spec('o.spec.ts', 3, 'only', [2000])] }] }), 4)).toContain('part 4: 1 test, 2s of testing');
expect(summaryOf([], 3)).toBe('### Browser Journeys, part 3: 0 tests, 0s of testing\n\nNo tests ran.\n');
});
});

describe('run on CI', () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'e2e-timings-'));

it('prints the table and writes every test\'s time to the part\'s file', () => {
const report = path.join(dir, 'report.json');
const out = path.join(dir, 'timings-part-5.json');
fs.writeFileSync(report, JSON.stringify(REPORT));
const printed = execFileSync(process.execPath, [SCRIPT, report, '5', out], { encoding: 'utf8' });
expect(printed).toBe(summaryOf(rowsOf(REPORT), 5));
expect(JSON.parse(fs.readFileSync(out, 'utf8'))).toEqual({ part: 5, tests: rowsOf(REPORT) });
});

it('a part that wrote no report says so, and the step still passes', () => {
const printed = execFileSync(process.execPath, [SCRIPT, path.join(dir, 'none.json'), '7', path.join(dir, 'x.json')], { encoding: 'utf8' });
expect(printed).toBe('### Browser Journeys, part 7: no report was written\n');
expect(fs.existsSync(path.join(dir, 'x.json'))).toBe(false);
});
});
14 changes: 10 additions & 4 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ npx playwright test --debug
```

- In CI the same files, and an HTML report, are attached to the run as an artifact, one per part
(**e2e-report-1** to **e2e-report-4**), downloadable from the run's summary page on GitHub.
(**e2e-report-1** to **e2e-report-8**), downloadable from the run's summary page on GitHub.

## In CI

Expand All @@ -114,9 +114,15 @@ two runs in a row, add a part. A last job named **Browser Journeys**
passes only when all eight did, so the check keeps its name. On a developer's machine nothing changes:
one machine, files in order.

A part that hangs fails after 25 minutes (Playwright's `globalTimeout`, CI only), with its report
kept; the job itself stops at 30 (`timeout-minutes`), for a hang outside the tests. Either way,
**Re-run failed jobs** runs just that part again.
A part that hangs fails after 16 minutes (Playwright's `globalTimeout`, CI only), with its report
kept. If Playwright itself freezes, as a GitHub runner did on 2026-11-22 (28 minutes silent, Cancel
doing nothing), the run step stops at 18 (its own `timeout-minutes`, enforced by the runner), and the
job at 22 for a hang outside the tests. Either way, **Re-run failed jobs** runs just that part again.

Every part, passed or failed, writes how long each test took (`timings.js`, from Playwright's JSON
report): the slowest ten as a table on the run's summary page, and every test's time as an artifact,
**e2e-timings-1** to **e2e-timings-8**, kept 30 days. The parts are shared out by count today; these
times are what sharing them out by time will use.

## Writing a journey

Expand Down
13 changes: 8 additions & 5 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ export default defineConfig({
// Two minutes: CI runs about four times slower than a desktop, and tests of 15 s here took past
// one minute there (builder-dice, the bell, the journey, the clicks sweep; 2026-10-24 to 10-27).
timeout: 120_000,
// A whole CI part, at most 25 minutes (a part took 12 to 21 by 2026-11-18, before E2E_BUILT and skipBoot): a hung run then fails, with its
// report kept, well before the job's own 30-minute limit (ci.yml) cancels it with none. No limit
// on a developer's machine, where the whole suite takes about 27 minutes.
globalTimeout: process.env.CI ? 25 * 60_000 : 0,
reporter: process.env.CI ? [['list'], ['html', { open: 'never' }]] : 'list',
// A whole CI part, at most 16 minutes (8n4; parts took 4 to 12 by 2026-11-22, with E2E_BUILT and skipBoot): a hung run
// then fails, with its report kept, before the run step's own 18-minute limit (ci.yml) stops it with none. It was 25,
// and on 2026-11-22 a part sat silent for 28 minutes on a frozen runner until it was cancelled. No limit on a developer's
// machine, where the whole suite takes about 27 minutes.
globalTimeout: process.env.CI ? 16 * 60_000 : 0,
// On CI also a JSON report, which timings.js turns into the slowest ten on the run's summary page and a file of every
// test's time (8n4).
reporter: process.env.CI ? [['list'], ['html', { open: 'never' }], ['json', { outputFile: 'results/report.json' }]] : 'list',
use: {
baseURL: `http://127.0.0.1:${FRONTEND_PORT}`,
viewport: { width: 1366, height: 820 },
Expand Down
Loading
Loading