import { readFileSync, readdirSync } from 'node:fs'; import { describe, expect, it } from 'vitest'; import { boardData } from '../src/board.js'; import { expandLayers } from '../src/manifest.js'; import { placeholders } from '../src/placeholders.js'; import { clone, readManifest, readStyle, root } from './fixtures.js'; const manifest = readManifest(); const data = boardData(manifest, readStyle()); const stand = placeholders(manifest); const page = readFileSync(`${root}tools/art-prep/board/index.html`, 'utf8'); describe('the board data', () => { it('has the shape the board page reads', () => { for (const a of data.assets) { expect(a).toMatchObject({ id: expect.any(String), width: expect.any(Number), height: expect.any(Number), prompt: expect.any(String) }); expect(Array.isArray(a.usedBy) && Array.isArray(a.checks) && Array.isArray(a.attach)).toBe(true); if (a.type === 'spritesheet') { expect(a.cells).toHaveLength((a.grid?.cols ?? 0) * (a.grid?.rows ?? 0)); for (const c of a.cells ?? []) expect(c).toMatchObject({ id: expect.any(String), width: expect.any(Number), height: expect.any(Number), prompt: expect.any(String) }); } } expect(data.checklist).toHaveLength(13); expect(data.assets.every((a) => Number.isInteger(a.phase))).toBe(true); }); it('every card says its phase, so a Phase 3 picture is never mistaken for a Phase 1 one', () => { expect(page).toContain('`Phase ${a.phase} · sprite sheet'); expect(page).toContain('`Phase ${a.phase} · ${a.type}'); }); it('every kind in the manifest has a group on the board page, or its cards would never show', () => { for (const type of new Set(data.assets.map((a) => a.type))) expect(page).toContain(`{ type: '${type}',`); }); it('the page takes the product name from @rosea/schema, never spells it', () => { expect(page).toContain('