import assert from 'node:assert/strict'; import test from 'node:test'; import { createElement } from 'react'; import { renderToStaticMarkup } from 'react-dom/server'; import { FreeformFactPreview } from '../components/truthtrance'; const base = { scope: 'fact' as const, target: 'target', leaderName: (id: string) => id, locationName: (id: string) => id, playerName: (id: string) => id }; const preview = (scope: 'fact' | 'currentTurn', text: string) => renderToStaticMarkup(createElement(FreeformFactPreview, { ...base, scope, text })); void test('the editor previews v6 knowledge and physical force facts only for current facts', () => { const prediction = preview('fact', 'Did you predict Harkonnen?'); assert.match(prediction, /Recognized freeform question/); assert.match(prediction, /your recorded Bene Gesserit prediction names Harkonnen/); const forces = preview('fact', 'Do you have at least 3 forces in your reserves?'); assert.match(forces, /Recognized freeform question/); assert.match(forces, /currently have at least 3 physical forces in your reserves/); const forecast = preview('fact', 'Is your storm forecast exactly 3?'); assert.match(forecast, /Recognized freeform question/); assert.match(forecast, /storm card currently known to you as Fremen shows exactly 3 sectors/); const spice = preview('fact', 'Is the next Spice Blow a sandworm?'); assert.match(spice, /Recognized freeform question/); assert.match(spice, /next Spice Card currently known to you as Atreides is a sandworm/); for (const text of ['Did you predict Harkonnen?', 'Do you have at least 3 forces in your reserves?']) { const manual = preview('currentTurn', text); assert.match(manual, /not automatically interpreted/); assert.doesNotMatch(manual, /Recognized freeform question/); } });