Stage 7 (wip): tests + UI CI
- Vitest units: board replay, placement machine, premium parity, i18n key parity, FlatBuffers codec round-trips (19 tests) - Playwright smoke (mock transport): guest -> lobby -> board -> place tile -> preview - ui-test.yaml workflow: check/unit/build + bundle-size budget (67.5KB gzip < 100KB) + chromium e2e - gateway transcode tests for games.list (seat display_name), pass, hint - backend integration test for game.ListForAccount
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { lastPlayTiles, replay } from './board';
|
||||
import type { MoveRecord } from './model';
|
||||
|
||||
function play(tiles: { row: number; col: number; letter: string; blank: boolean }[]): MoveRecord {
|
||||
return {
|
||||
player: 0,
|
||||
action: 'play',
|
||||
dir: 'H',
|
||||
mainRow: tiles[0].row,
|
||||
mainCol: tiles[0].col,
|
||||
tiles,
|
||||
words: [],
|
||||
count: 0,
|
||||
score: 0,
|
||||
total: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const pass: MoveRecord = {
|
||||
player: 1,
|
||||
action: 'pass',
|
||||
dir: '',
|
||||
mainRow: 0,
|
||||
mainCol: 0,
|
||||
tiles: [],
|
||||
words: [],
|
||||
count: 0,
|
||||
score: 0,
|
||||
total: 0,
|
||||
};
|
||||
|
||||
describe('board replay', () => {
|
||||
it('places play tiles and ignores non-play moves', () => {
|
||||
const moves = [
|
||||
play([
|
||||
{ row: 7, col: 7, letter: 'A', blank: false },
|
||||
{ row: 7, col: 8, letter: 'B', blank: true },
|
||||
]),
|
||||
pass,
|
||||
play([{ row: 8, col: 7, letter: 'C', blank: false }]),
|
||||
];
|
||||
const b = replay(moves);
|
||||
expect(b[7][7]?.letter).toBe('A');
|
||||
expect(b[7][8]?.blank).toBe(true);
|
||||
expect(b[8][7]?.letter).toBe('C');
|
||||
expect(b[0][0]).toBeNull();
|
||||
expect(b.length).toBe(15);
|
||||
expect(b[0].length).toBe(15);
|
||||
});
|
||||
|
||||
it('lastPlayTiles returns the most recent play, skipping passes', () => {
|
||||
const moves = [play([{ row: 7, col: 7, letter: 'A', blank: false }]), pass];
|
||||
expect(lastPlayTiles(moves)).toHaveLength(1);
|
||||
expect(lastPlayTiles([pass])).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user