Files
Dune/tests/advanced-preview-controls.test.ts
T
Quintine c5508b727a Expose an explicitly unfinished Advanced preview in normal lobbies
Add room-creation and host lobby rules selectors, readiness reset, explicit
preview start and a persistent warning. Admit the six classic factions,
Tech Tokens with 3+ players and optional Stronghold Cards through genuine
setup. Keep expansion/module gates and complete-rules/publication criteria.

Persist the preview marker and enforce fresh native leaders, unchanged
piece custody and clean runtime/pacing state. Preserve private projections,
JSON continuation, exact room-entry retries and version/CAS protection.
Independent review resolved malformed leader, extra card-zone, missing
required-key and stale bot-deadline admission gaps.

Validation on the shared development tree: types, lint, 5169 offline
tests, build and 50 HTTP tests passed. The tree also contained the
separate deployment task's changes; this commit stages only preview scope.
All 57 base rosters completed real setup with each legal AI profile. Five
normal-preview-start games (2–6 seats) completed 1950 actions and
51 JSON restores without rejected actions; no strategy calibration.

Browser: actual create, host switch/readiness/Stronghold reset, explicit
start, exact private refresh, desktop and mobile warning checked. Retained
dev process stopped; backed up 1,629 saved games, restored server with all
unchanged, and resumed the same traitor choice into Storm. Baseline all-table
preservation retained 1626 rooms and 3442 seats; totals
now 1669 rooms and 3536 seats. No reset or automation.

Preview remains incomplete. Legacy unsupported expansion creation payloads
remain accepted for exact retry compatibility but cannot start. Existing
rules ambiguities and full visual acceptance remain open.
2026-09-21 17:41:35 +10:00

55 lines
2.0 KiB
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import {
RulesetControls,
AdvancedPreviewNotice,
} from '../components/ruleset-controls';
import { createRoomEntry, parseRoomEntry } from '../lib/room-entry';
void test('rules controls identify the unfinished selection before readiness and restrict peer editing', () => {
const render = (advanced: boolean, host: boolean) =>
renderToStaticMarkup(
createElement(RulesetControls, {
advanced,
host,
lobby: true,
onChange() {},
}),
);
assert.match(render(false, true), /value="basic" selected=""/);
const preview = render(true, true);
assert.match(preview, /value="advanced" selected=""/);
assert.match(preview, /Rules and card interactions are still/);
assert.match(preview, /six classic factions/);
assert.match(preview, /Changing rules clears player readiness/);
assert.match(preview, /Switching to Basic removes Stronghold Cards/);
assert.match(render(true, false), /<select disabled=""/);
assert.match(render(true, false), /The host chooses the rules/);
const ongoing = renderToStaticMarkup(
createElement(AdvancedPreviewNotice, { compact: true }),
);
assert.match(ongoing, /Advanced preview/);
assert.match(ongoing, /Some play may need fixes/);
});
void test('an Advanced creation attempt retains the exact selection and proof through a tab retry', () => {
const attempt = createRoomEntry({
name: 'Preview host',
faction: 'fremen',
advanced: true,
expansions: [],
});
const restored = parseRoomEntry(JSON.stringify(attempt));
assert.equal(restored.bodyText, attempt.bodyText);
const body = JSON.parse(restored.bodyText);
assert.equal(body.advanced, true);
assert.deepEqual(body.expansions, []);
assert.equal(body.faction, 'fremen');
assert.equal(
body.entry.sessionToken,
JSON.parse(attempt.bodyText).entry.sessionToken,
);
});