Present public plans in physical attacker/defender order with exact force dials, played leader portraits and printed strength, readable used-card faces and direct inspectors. Keep Cheap Heroes, printed Worthless category, empty slots and late rescue defense distinct. Preserve Banker, native bonus, KH, Stone Burner, Poison Tooth and Diplomat details rather than treating printed values as scores. Mount one shared display after the main grid so every viewer retains access while another seat owns a post-reveal choice. Keyboard links focus the display and pending controls. Render nothing before public revelation, select exact used identities from the authorized projection, and consume no private insight or hands. No game rule, saved field, endpoint, AI strategy or release gate changes. Five new cases cover genuine sealed/revealed actions, stable order, used-card privacy, JSON immutability, fractional dials, hero/Worthless/late/empty slots and both seats during a real Diplomat decision. All28 related focused cases passed before final rule-link adapter changes; types, lint, all 5017 offline tests and production build pass on the final stable source. First broad run caught plain rules-page anchors; next/link and test aliases correct this. Independent privacy/layout review and final follow-up found no material issues. No API/auth/persistence changes; HTTP tests and full game samples not repeated. Browser QA creates a fresh human Emperor/Easy Harkonnen lobby with genuine setup, then explicitly stages a conserved battle. Normal engine actions choose battle and seal the opponent plan; human browser action seals dial2, Captain Aramsham, Slip Tip and Shield. Public display absent beforehand and shows correct both plans afterward. Leader/opponent-card inspection, Escape/focus return, internal help, keyboard section links and refresh preserve the pending decision. At390x844, client/scrollWidth375, stacked panels299px, rules16px and controls44px; normal viewport restores1265px and two560.5px plans without horizontal overflow. Screenshot capture timed out; full visual/screen-reader acceptance remains open. All 1579 opening games, 3347 saved seats and auxiliary rows remain identical. One isolated QA game adds one seat and one entry receipt. Its room remains unchanged after human seal through inspection/help/refresh, and its saved seat remains unchanged. SQLite integrity and foreign keys pass. No server restart, migration, reset, recurring automation or calibration. Record Basic Moritani plus the full Leader Skills deck as the next concrete integration target, requiring coordinated profile guards and real Terror/death/ revival continuations. Existing rulings and mode gates stay explicit; the later Tleilaxu revival-offer ordering issue remains a gated integration dependency. Private evidence: 20260921-revealed-plans. Verified source tree: 8d5496cdea0076aa1cdab4590e95fcaa677c9d2d8513190c2ce9ac6c90bb9196
100 lines
5.9 KiB
TypeScript
100 lines
5.9 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { readFileSync } from 'node:fs';
|
|
import { registerHooks } from 'node:module';
|
|
import { createElement } from 'react';
|
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { applyAction, viewGame, type Game } from '../game/engine';
|
|
import { baseDeck } from '../game/cards';
|
|
import { leaderSkillBattle } from './leader-skill-battle-fixture';
|
|
import { takeBattleCard, diplomatDefenseGame, revealDiplomatPlans } from './diplomat-defense-fixture';
|
|
const aliases = registerHooks({ resolve(specifier, context, next) {
|
|
return next(specifier === 'next/image' ? 'vinext/shims/image' : specifier === 'next/link' ? 'vinext/shims/link' : specifier, context);
|
|
}, load(url, context, next) {
|
|
if (!url.endsWith('.module.css')) return next(url, context);
|
|
const css = readFileSync(new URL(url), 'utf8');
|
|
const classes = Object.fromEntries([...css.matchAll(/\.([a-zA-Z_][\w-]*)/g)].map(m => [m[1], m[1]]));
|
|
return { format: 'module', source: `export default ${JSON.stringify(classes)}`, shortCircuit: true };
|
|
} });
|
|
const { GameTable } = await import('../components/game-table');
|
|
const { RevealedBattle } = await import('../components/revealed-battle');
|
|
const { RevealedPlanPieces } = await import('../components/revealed-plan-pieces');
|
|
aliases.deregister();
|
|
const render = (g: Game, player: string) => renderToStaticMarkup(createElement(RevealedBattle, { game: viewGame(g, player) }));
|
|
|
|
void test('public plan pieces stay absent before both real plans are revealed, including for their owners', () => {
|
|
let g = leaderSkillBattle({ skill: 'warmaster', unsealed: true, hide: false, advanced: true });
|
|
const weapon = takeBattleCard(g, 'd', 'poison');
|
|
for (const p of g.players) assert.equal(render(g, p.id), '');
|
|
g = applyAction(g, 'd', { type: 'battlePlan', dial: .5, support: 0, leader: 'guild-1', weapon: weapon.id });
|
|
assert.ok(!g.battle!.revealed);
|
|
for (const p of g.players) assert.equal(render(g, p.id), '');
|
|
});
|
|
|
|
void test('actual revealed plans show physical faces in attacker/defender order and never include unplayed cards', () => {
|
|
let g = leaderSkillBattle({ skill: 'warmaster', unsealed: true, hide: false, advanced: true });
|
|
const ownWeapon = takeBattleCard(g, 'a', 'projectile');
|
|
const secret = takeBattleCard(g, 'a', 'lasgun');
|
|
const otherWeapon = takeBattleCard(g, 'd', 'poison');
|
|
const otherDefense = takeBattleCard(g, 'd', 'snooper');
|
|
g = applyAction(g, 'd', { type: 'battlePlan', dial: .5, support: 0, leader: 'guild-1', weapon: otherWeapon.id, defense: otherDefense.id });
|
|
g = applyAction(g, 'a', { type: 'battlePlan', dial: 1, support: 1, leader: 'emperor-1', weapon: ownWeapon.id });
|
|
assert.ok(g.battle!.revealed);
|
|
const before = JSON.stringify(g);
|
|
for (const p of g.players) {
|
|
const html = render(g, p.id);
|
|
assert.ok(html.indexOf('aria-label="Attacker plan"') < html.indexOf('aria-label="Defender plan"'));
|
|
assert.equal((html.match(/aria-label="Revealed force dial"/g) ?? []).length, 2);
|
|
assert.match(html, /<dd>0.5<\/dd>/);
|
|
for (const card of [ownWeapon, otherWeapon, otherDefense]) assert.ok(html.includes(`Inspect card: ${card.name}`));
|
|
assert.ok(!html.includes(`Inspect card: ${secret.name}`));
|
|
assert.match(html, /aria-label="Defense in original plan: None"/);
|
|
assert.match(html, /Printed strength/);
|
|
assert.match(html, /Inspect leader: Captain Aramsham/);
|
|
assert.match(html, /emperor/);
|
|
assert.match(html, /href="\/rules\?topic=battle#battle"/);
|
|
assert.doesNotMatch(html, /type="range"|type="number"|Seal battle plan|Your private status/);
|
|
assert.equal(render(JSON.parse(before), p.id), html);
|
|
}
|
|
assert.equal(JSON.stringify(g), before);
|
|
});
|
|
|
|
void test('Cheap Hero, Worthless-slot use and late defense retain printed faces and explicit slot labels', () => {
|
|
const cards = baseDeck();
|
|
const hero = cards.find(c => c.kind === 'hero')!;
|
|
const worthless = cards.find(c => c.kind === 'worthless')!;
|
|
const defense = cards.find(c => c.kind === 'snooper')!;
|
|
// Presentation-only: rules for late defense and physical slot legality have engine tests.
|
|
const html = renderToStaticMarkup(createElement(RevealedPlanPieces, { dial: 0, leaderCard: hero, weapon: worthless, lateDefense: defense }));
|
|
assert.ok(html.includes(`aria-label="Leader: ${hero.name}"`));
|
|
assert.ok(html.includes(`aria-label="Weapon: ${worthless.name}"`));
|
|
assert.match(html, /Weapon · Worthless/);
|
|
assert.match(html, /Defense in original plan: None/);
|
|
assert.ok(html.includes(`aria-label="Added after reveal: ${defense.name}"`));
|
|
assert.ok(html.includes(`Inspect card: ${hero.name}`));
|
|
assert.doesNotMatch(html, /Inspect leader:/);
|
|
});
|
|
|
|
void test('an empty revealed plan has clear empty slots and no invented leader or card inspector', () => {
|
|
const html = renderToStaticMarkup(createElement(RevealedPlanPieces, { dial: 0 }));
|
|
for (const label of ['Leader', 'Weapon', 'Defense in original plan']) assert.ok(html.includes(`aria-label="${label}: None"`));
|
|
assert.doesNotMatch(html, /Inspect card:|Inspect leader:|Added after reveal/);
|
|
});
|
|
|
|
void test('both seats retain one shared public plan display while an owned post-reveal choice is pending', () => {
|
|
const game = revealDiplomatPlans(diplomatDefenseGame());
|
|
assert.equal(game.decision?.kind, 'diplomatDefense');
|
|
const before = JSON.stringify(game);
|
|
for (const player of game.players) {
|
|
const html = renderToStaticMarkup(createElement(GameTable, { game: viewGame(game, player.id), busy: true,
|
|
send: async () => { assert.fail('Public inspection must not submit an action.'); }, onExit() {},
|
|
}));
|
|
assert.equal((html.match(/aria-label="Revealed battle plans"/g) ?? []).length, 1);
|
|
assert.equal((html.match(/aria-label="Attacker plan"/g) ?? []).length, 1);
|
|
assert.equal((html.match(/aria-label="Defender plan"/g) ?? []).length, 1);
|
|
assert.match(html, /href="#revealed-battle-plans"/);
|
|
assert.match(html, /href="#table-decisions"/);
|
|
}
|
|
assert.equal(JSON.stringify(game), before);
|
|
});
|