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
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ jobs:
shell: pwsh
run: scripts/offline-check.ps1 -Mode MissingRuntime

# After the smoke and WebView2 steps so an axe failure does not skip their evidence.
- name: Accessibility in Edge (axe, colour contrast on)
working-directory: src/Ui
run: npm run test:a11y

- name: Upload smoke report
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ BenchmarkDotNet.Artifacts/
# UI
node_modules/
src/Ui/dist/
src/Ui/.vitest/
*.tsbuildinfo

# Local data and secrets
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ npm run build --prefix src/Ui # must precede the .NET build; the shell copi
dotnet build TomeStack.slnx -c Release
dotnet test TomeStack.slnx -c Release
npm run test:e2e --prefix src/Ui # after the .NET build: UI flow (Vitest + Testing Library) against the real DevHost
npm run test:a11y --prefix src/Ui # after the .NET build: axe with colour contrast in Edge against the DevHost (4.1)
scripts/smoke.ps1 -Exe src/DesktopShell/bin/Release/net10.0-windows/TomeStack.exe # Windows GUI smoke (checks the report)
scripts/single-instance-check.ps1 -Exe src/DesktopShell/bin/Release/net10.0-windows/TomeStack.exe # two processes on one data folder (M2.1)
```
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

### Added
- **Accessibility check in CI, two contrast fixes:** `npm run test:a11y` runs axe, colour contrast included, in the installed Edge against the DevHost, in light and dark, over home, each builder step and each sheet tab, plus home in each named theme. Serious and critical violations fail it, and it now runs in CI. It found two low-contrast spots, both fixed without changing any colour: the "Offline" tag in the header now sits on the page colour, and in the dark theme the sheet's status-bar buttons (Hit points, Armor Class, Initiative, Speed) now sit on the page colour instead of the browser's grey button face.
- **Tests only:** the UI flow tests in `src/Ui/e2e/` are split by feature (the 69 tests of `flow.e2e.tsx` into eight files, the 13 of `forms.e2e.tsx` into two, shared helpers in `helpers.tsx`); no test changed and no file is over 800 lines. The e2e files now run one after another against the shared DevHost. No app change.
- **Release assets:** each release now includes two CycloneDX software bills of materials, `tomestack-X.Y.Z-nuget.cdx.json` (the .NET packages) and `tomestack-X.Y.Z-npm.cdx.json` (the UI's npm runtime packages). They are listed in `SHA256SUMS` and attested like the installer (D101). No app change.
- **Content schema 13: creation guides and packs, engine only (D97, D98, [ADR-024](decisions/ADR-024-content-v13.md)):** content can now carry a creation guide for a class or background (starting equipment as picks and options, and primary abilities) and packs (an item that lists what it contains). The change adds the format, validation, kit expansion and a catalogue lookup; the bundled guides and gear are listed below. The one change a player can see is in saving for an older TomeStack. Characters never pin a guide. Saving for an older TomeStack leaves guides out, drops what a pack contains, and turns plain gear that release does not have into a custom item (the save is blocked if that would pass 50 custom items, if a quantity is outside 1 to 9,999, or if an item's name is blank or over 80 characters). A source pack or campaign pack that would hold only guides cannot be saved for an older TomeStack; a library backup is unaffected. Older versions refuse v13 content.
Expand Down
3 changes: 2 additions & 1 deletion docs/features/accessibility-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Status key: ✅ verified (how) · 🔧 found and fixed in this change · ⚠️
- Blockers are listed ("Blocks accepting") beside the disabled "Accept as a draft", and "Accept as reference" stays available.
- A keyboard-only and Narrator pass of the review screen is an owner check (items 15 and 3).

- Automated: axe on three components (`src/Ui/src/test/axe.ts`, axe-core in jsdom, colour contrast off because jsdom has no layout): the summary bar with a roll result, the import review's detail view with its confirm ticks, and the homebrew studio's effect editor open on a toggle. Manual rows unchanged; contrast and High Contrast stay manual checks.
- Automated: axe on three components (`src/Ui/src/test/axe.ts`, axe-core in jsdom, colour contrast off because jsdom has no layout): the summary bar with a roll result, the import review's detail view with its confirm ticks, and the homebrew studio's effect editor open on a toggle. Also automated (item 125): `npm run test:a11y` runs axe with colour contrast on in the installed Edge against the DevHost, over every screen in light and dark and home in each named theme, and it runs in CI (the `gui` job). Manual rows unchanged; High Contrast stays a manual check.

## Checklist

Expand Down Expand Up @@ -152,6 +152,7 @@ Status key: ✅ verified (how) · 🔧 found and fixed in this change · ⚠️
| 122 | Discard confirm on Cancel (Wave 3 Group 8) | 2.1.1, 2.4.3, 3.3.4, 4.1.2 | ✅ **Passed 2026-11-17, by the owner** (Narrator announces the question when it opens). Vitest: Cancel opens an inline `role="alertdialog"` labelled by its question ("Discard this character?", "this level-up?" or "these changes?", then "Your picks will be lost."). Focus moves to "Keep editing"; Esc means Keep editing and focus returns to Cancel; "Discard" leaves. |
| 123 | Level-up class picker (Wave 3 Group 10) | 1.3.1, 1.4.1, 3.3.2, 4.1.2, 4.1.3 | ✅ **Passed 2026-11-17, by the owner** (Narrator reads each radio with what it gives, the select's label, and the warning when a class is picked). Vitest and e2e: "Class to gain a level in" is a `fieldset` with a `legend` holding one radio per class ("{Name} {level} — what you get: …") and "Another class…"; the select it opens is labelled "Class to start". The prerequisite warning ("{Name} — needs … You can still take it.") is a polite live region (`aria-live="polite"`), in words, not colour alone. Next is never natively disabled and never blocked by the warning; when it waits (no class chosen, or a campaign exception reason is missing) it is `aria-disabled` with a linked reason. |
| 124 | "New at level n" and "Earlier choices" on the level-up choices step (Wave 3 Group 10) | 1.3.1, 4.1.2 | ✅ **Passed 2026-11-17, by the owner** (Narrator reads the heading and the disclosure's state; Enter and Space open and close it). Vitest: "New at level n" is an `h3` placed before the new choices; "Earlier choices" is a native `details` with a `summary`, closed at first, holding the choices the saved character already had that are resolved now and carry no replace offer (open choices and replace offers stay under "New at level n"). Enter and Space are native to `summary` but jsdom does not model them. |
| 125 | Automated axe in Edge (4.1) | 1.4.3, 1.4.11, 4.1.2 | 🔧 **Automated** (`npm run test:a11y`: every screen, light and dark, plus home in each named theme, colour contrast on, serious and critical fail). Vitest browser mode in the installed Edge against the real DevHost: home (empty and with a character), each builder step, each sheet tab; also asserts the skip link shows an outline when focused and that `main` takes focus with none. It runs in CI after the e2e step (the `gui` job). Two contrast failures it found are fixed by giving the header's "Offline" tag and the sheet status-bar buttons the page colour as background (no token changed). **Owner check:** High Contrast (forced colours) stays manual; axe cannot see it. |

## Manual keyboard walkthrough

Expand Down
26 changes: 26 additions & 0 deletions src/Ui/a11y/axe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Real-browser axe run (4.1): every rule on, including color-contrast, which jsdom cannot compute. `serious` and
// `critical` violations fail; `moderate` and `minor` are only warned. axe is global state, so runs are awaited one by one.
import axe from 'axe-core';

type Result = axe.Result;

function describeNode(violation: Result, node: Result['nodes'][number]): string {
const target = `${node.target.join(' ')} ${node.html.slice(0, 140).replace(/\s+/g, ' ')}`;
if (violation.id !== 'color-contrast') return target;
const data = node.any.find((c) => c.id === 'color-contrast')?.data as
| { fgColor?: string; bgColor?: string; contrastRatio?: number; expectedContrastRatio?: string }
| undefined;
return data ? `${target} (fg ${data.fgColor}, bg ${data.bgColor}, ratio ${data.contrastRatio}, needs ${data.expectedContrastRatio})` : target;
}

function lines(violations: Result[]): string[] {
return violations.map((v) => `- [${v.impact}] ${v.id}: ${v.help}\n ${v.nodes.map((n) => describeNode(v, n)).join('\n ')}`);
}

export async function expectNoSeriousAxe(root: Element, label: string): Promise<void> {
const results = await axe.run(root);
const blocking = results.violations.filter((v) => v.impact === 'serious' || v.impact === 'critical');
const minor = results.violations.filter((v) => v.impact !== 'serious' && v.impact !== 'critical');
if (minor.length > 0) console.warn(`axe (${label}): ${minor.length} moderate/minor violation(s)\n${lines(minor).join('\n')}`);
if (blocking.length > 0) throw new Error(`axe (${label}): ${blocking.length} serious/critical violation(s)\n${lines(blocking).join('\n')}`);
}
82 changes: 82 additions & 0 deletions src/Ui/a11y/devhostProxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Vite middleware for the accessibility run (4.1). The browser page is served by Vite, so its `/api/command` calls land
// here; Node forwards them to the DevHost with the token and no Origin header (the DevHost only allows port 5173 and
// answers no CORS preflight). The token stays in Node and never reaches the page.
import type { IncomingMessage, ServerResponse } from 'node:http';
import type { Plugin } from 'vite';

const maxBody = 1024 * 1024;

class TooLarge extends Error {}

function readBody(req: IncomingMessage): Promise<Buffer> {
return new Promise((done, fail) => {
const chunks: Buffer[] = [];
let size = 0;
let settled = false;
const settle = (action: () => void): void => {
if (settled) return;
settled = true;
action();
};
req.on('data', (chunk: Buffer) => {
if (settled) return; // over the cap: the rest is read and dropped, never buffered
size += chunk.length;
if (size > maxBody) {
chunks.length = 0;
settle(() => fail(new TooLarge()));
return;
}
chunks.push(chunk);
});
req.on('end', () => settle(() => done(Buffer.concat(chunks))));
req.on('error', (error) => settle(() => fail(error)));
req.on('close', () => settle(() => fail(new Error('Request closed before its body ended.'))));
});
}

function reply(res: ServerResponse, status: number, body: string): void {
res.statusCode = status;
res.setHeader('Content-Type', 'application/json');
res.end(body);
}

/** `projectName` picks the DevHost that project's globalSetup started (env keys written by e2e/devhost.setup.ts). */
export function devhostProxy(projectName: string): Plugin {
return {
name: 'tomestack-devhost-proxy',
configureServer(server) {
server.middlewares.use('/api/command', (req, res, next) => {
if (req.method !== 'POST' || (req.url !== '/' && req.url !== '')) return next();
void (async () => {
const base = process.env[`TOMESTACK_E2E_DEVHOST_URL_${projectName}`];
const token = process.env[`TOMESTACK_E2E_DEVHOST_TOKEN_${projectName}`];
if (!base || !token) {
reply(res, 503, JSON.stringify({ error: `DevHost for project ${projectName} is not running: its TOMESTACK_E2E_DEVHOST_* variables are unset (run through vitest.a11y.config.ts).` }));
return;
}
if (!/^application\/json\s*(;|$)/i.test(req.headers['content-type'] ?? '')) {
reply(res, 415, JSON.stringify({ error: 'Content-Type must be application/json.' }));
return;
}
try {
const body = await readBody(req);
const upstream = await fetch(`${base}/api/command`, {
method: 'POST',
headers: { 'X-TomeStack-Token': token, 'Content-Type': 'application/json' },
body: new Uint8Array(body),
});
reply(res, upstream.status, await upstream.text());
} catch (error) {
if (error instanceof TooLarge) {
// Reply first, then close once the reply is flushed, so the client sees the 413 and not a reset.
res.setHeader('Connection', 'close');
res.once('finish', () => req.destroy());
reply(res, 413, JSON.stringify({ error: 'Request body over 1 MB.' }));
}
else reply(res, 502, JSON.stringify({ error: `DevHost proxy failed: ${error instanceof Error ? error.message : String(error)}` }));
}
})();
});
},
};
}
Loading
Loading