/
deka
/
buffer
Обзор
Документация
Войти
/
deka
/
buffer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
tests/prompt-smoke-layout.test.mjs
50 строк
2 KB
Maksim Ratnikov
Drop JSON-input workflow; text-only generation is the contract
08 май 2026, 10:22
08 май 2026, 10:22
238874c
Код
Авторство
О чём код?
import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; const prompt = readFileSync("prompts/wiki-layout-reference.md", "utf8"); const textPrompt = readFileSync("prompts/text-to-wiki-layout.md", "utf8"); const labHtml = readFileSync("lab/wiki-clipboard-lab.html", "utf8"); const match = prompt.match(/```json renderable-smoke-layout\n([\s\S]*?)\n```/); assert.ok(match, "prompt must contain a renderable-smoke-layout JSON block"); assert.ok(textPrompt.length > 0, "text prompt must exist as the single generation entrypoint"); assert.match(labHtml, /function renderLayoutJson/, "lab must own layout rendering"); assert.match(labHtml, /function renderLayoutBlocks/, "lab must expose layout block rendering"); assert.match(labHtml, /data-type="tableOfContent"/, "lab renderer must support TOC"); assert.match(labHtml, /data-type="tabs"/, "lab renderer must support tabs"); assert.match(labHtml, /data-type="uiButton"/, "lab renderer must support buttons"); const layout = JSON.parse(match[1]); assert.equal(layout.$schema, "wiki-layout-v1"); assert.ok(Array.isArray(layout.blocks), "smoke layout must contain blocks"); assert.equal(layout.blocks[0]?.type, "heading", "smoke layout must start with heading"); assert.equal(layout.blocks[0]?.slice, true, "first heading must be slice-enabled"); function visitTabs(blocks) { for (const block of blocks ?? []) { if (block.type === "blocksGrid") { assert.ok((block.columns ?? []).length <= 3, "blocksGrid must not exceed 3 columns"); } if (block.type === "tabs") { for (const tab of block.tabs ?? []) { for (const nested of tab.blocks ?? []) { assert.notEqual(nested.type, "heading", `tab ${tab.label} must not contain headings`); } visitTabs(tab.blocks); } } visitTabs(block.blocks); for (const column of block.columns ?? []) { visitTabs(column); } } } visitTabs(layout.blocks); const serialized = JSON.stringify(layout); assert.match(serialized, /"type":"toc"|"type":"tableOfContent"/, "smoke layout must include TOC"); assert.match(serialized, /"type":"tabs"/, "smoke layout must include tabs"); assert.match(serialized, /"type":"uiButton"/, "smoke layout must include buttons"); console.log("prompt smoke layout test passed");