Add <cast-tray>: renders scenario.cast (name + one-line note) with each NPC secret behind a tap-to-reveal so spoilers stay off-screen at the table. Wired into the shell as the 'cast' tool with a 👥 rail chip; reveal state is ephemeral component state. Now the 57 ported NPCs are visible in a running session. tests/components/cast-tray.test.js + gm-shell-cast.test.js. 141 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
1.6 KiB
JavaScript
43 lines
1.6 KiB
JavaScript
import { describe, it, expect, beforeEach } from 'vitest';
|
|
import '../../src/components/gm-shell.js';
|
|
import afterimage from '../../src/scenarios/afterimage.js';
|
|
|
|
describe('<gm-shell> cast tray', () => {
|
|
let el;
|
|
beforeEach(() => {
|
|
localStorage.clear();
|
|
document.body.innerHTML = '';
|
|
el = document.createElement('gm-shell');
|
|
el.now = () => 0;
|
|
document.body.appendChild(el);
|
|
el.loadScenario(afterimage);
|
|
});
|
|
|
|
it('mounts a hidden cast-tray fed from the scenario cast', () => {
|
|
const tray = el.querySelector('cast-tray');
|
|
expect(tray).not.toBe(null);
|
|
expect(tray.hidden).toBe(true);
|
|
expect(tray.cast.length).toBe(afterimage.cast.length);
|
|
});
|
|
|
|
it('open-tool cast reveals the cast-tray', () => {
|
|
el.dispatchEvent(new CustomEvent('open-tool', { detail: { tool: 'cast' }, bubbles: true }));
|
|
expect(el.querySelector('cast-tray').hidden).toBe(false);
|
|
});
|
|
|
|
it('opening the cast tray hides the other trays', () => {
|
|
el.dispatchEvent(new CustomEvent('open-tool', { detail: { tool: 'clues' }, bubbles: true }));
|
|
el.dispatchEvent(new CustomEvent('open-tool', { detail: { tool: 'cast' }, bubbles: true }));
|
|
expect(el.querySelector('clue-net').hidden).toBe(true);
|
|
expect(el.querySelector('cast-tray').hidden).toBe(false);
|
|
});
|
|
|
|
it('the rail exposes a cast chip that emits open-tool', () => {
|
|
const rail = el.querySelector('director-rail');
|
|
let tool = null;
|
|
el.addEventListener('open-tool', (e) => { tool = e.detail.tool; });
|
|
rail.querySelector('[data-role=open-cast]').click();
|
|
expect(tool).toBe('cast');
|
|
});
|
|
});
|