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,53 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { alphabet, BOARD_SIZE, centre, premiumGrid, tileValue } from './premiums';
|
||||
|
||||
// Parity with scrabble-solver/rules/rules.go: english/russian share standardBoard
|
||||
// (centre is a double word); erudit shares the geometry but a non-doubling centre.
|
||||
describe('premium layout', () => {
|
||||
it('is a 15x15 grid with TW corners', () => {
|
||||
const g = premiumGrid('english');
|
||||
expect(g.length).toBe(BOARD_SIZE);
|
||||
expect(g[0].length).toBe(BOARD_SIZE);
|
||||
for (const [r, c] of [
|
||||
[0, 0],
|
||||
[0, 14],
|
||||
[14, 0],
|
||||
[14, 14],
|
||||
]) {
|
||||
expect(g[r][c]).toBe('TW');
|
||||
}
|
||||
});
|
||||
|
||||
it('doubles the centre for standard variants but not for erudit', () => {
|
||||
expect(centre('english')).toEqual({ row: 7, col: 7 });
|
||||
expect(premiumGrid('english')[7][7]).toBe('DW');
|
||||
expect(premiumGrid('russian')[7][7]).toBe('DW');
|
||||
expect(centre('erudit')).toEqual({ row: 7, col: 7 });
|
||||
expect(premiumGrid('erudit')[7][7]).toBe('');
|
||||
});
|
||||
|
||||
it('keeps the standard premium counts', () => {
|
||||
const flat = premiumGrid('english').flat();
|
||||
const count = (p: string) => flat.filter((x) => x === p).length;
|
||||
expect(count('TW')).toBe(8);
|
||||
expect(count('TL')).toBe(12);
|
||||
expect(count('DL')).toBe(24);
|
||||
expect(count('DW')).toBe(17); // 16 double-word squares + the centre
|
||||
});
|
||||
});
|
||||
|
||||
describe('tile values', () => {
|
||||
it('scores letters per variant and zero for a blank', () => {
|
||||
expect(tileValue('english', 'A')).toBe(1);
|
||||
expect(tileValue('english', 'Q')).toBe(10);
|
||||
expect(tileValue('english', '?')).toBe(0);
|
||||
expect(tileValue('russian', 'Ф')).toBe(10);
|
||||
expect(tileValue('erudit', 'Ё')).toBe(0);
|
||||
});
|
||||
|
||||
it('exposes the full alphabet for the blank chooser', () => {
|
||||
expect(alphabet('english')).toHaveLength(26);
|
||||
expect(alphabet('russian')).toHaveLength(33);
|
||||
expect(alphabet('erudit')).toHaveLength(33);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user