M9: 초보자 도움 틀 — 30초 규칙 요약 카드, 게임 중 [?] 지금 할 수 있는 것, 오목 내용

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-06 03:04:24 +09:00
parent c27cb0a11a
commit 57753a037c
10 changed files with 390 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
/** Beginner help (docs/07 §5) for every game: 3 summary cards, and help text on every view of a random game. */
import { describe, expect, test } from 'bun:test';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { GAMES } from '@bg/games';
import { GAME_UI } from './registry';
import { assertCleanText, eachView, seatIds, usersOf } from './help-kit.test-util';
const IDS = Object.keys(GAME_UI);
test('모든 게임에 도움말이 있어요', () => {
expect(IDS).toHaveLength(26);
for (const id of IDS) {
const src = readFileSync(join(import.meta.dir, id, 'index.tsx'), 'utf8');
expect(src, id).toMatch(/\bquickStart,/);
expect(src, id).toMatch(/\bhelpNow,/);
}
});
describe.each(IDS)('%s', (id) => {
test('30초 요약 카드 3장', async () => {
const { quickStart } = await import(`./${id}/quick`);
expect(quickStart).toHaveLength(3);
for (const c of quickStart) {
expect(c.pic).toBeTruthy();
expect(c.alt.length).toBeGreaterThan(4);
expect(c.title.length).toBeGreaterThan(1);
expect(c.title.length).toBeLessThanOrEqual(20);
expect(c.text.length).toBeGreaterThan(10);
expect(c.text.length).toBeLessThanOrEqual(110);
}
});
test('무작위 한 판의 모든 화면(각 자리 + 관전)에서 지금 할 수 있는 것', async () => {
const { helpNow } = await import(`./${id}/help`);
const def = GAMES[id]!;
const range = def.playersFor?.(def.defaultOptions) ?? { min: def.minPlayers, max: def.maxPlayers };
const n = Math.min(range.max, Math.max(range.min, 3));
const users = usersOf(seatIds(n));
let count = 0;
eachView(id, n, (view, who) => {
assertCleanText(helpNow(view, who, users), `${id} viewer=${who}`);
count++;
});
expect(count).toBeGreaterThan(n);
});
});