Task 008 implement boundary questions loop
This commit is contained in:
@@ -59,5 +59,5 @@ const rows = buildDashboardRows(
|
||||
|
||||
assert.equal(rows.length, 1, "one row should be built");
|
||||
assert.equal(rows[0].targetSiteName, "Editorial site", "target site name should map");
|
||||
assert.equal(rows[0].nextAction, "Create plan", "next action should match status mapping");
|
||||
assert.equal(rows[0].nextAction, "Run boundary questions", "next action should match status mapping");
|
||||
assert.equal(rows[0].assignedEditor, "Unassigned", "missing editor id should render Unassigned");
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import ts from "typescript";
|
||||
|
||||
const testDir = path.dirname(fileURLToPath(import.meta.url));
|
||||
const sourcePath = path.resolve(
|
||||
testDir,
|
||||
"../src/features/boundary-questions/model.ts",
|
||||
);
|
||||
const source = readFileSync(sourcePath, "utf8");
|
||||
const compiled = ts.transpileModule(source, {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
|
||||
});
|
||||
|
||||
const moduleExports = {};
|
||||
new Function("exports", compiled.outputText)(moduleExports);
|
||||
|
||||
const { buildBoundaryQuestionRows, validateRequiredAnswers } = moduleExports;
|
||||
|
||||
const rows = buildBoundaryQuestionRows([
|
||||
{
|
||||
id: "11111111-1111-1111-1111-111111111111",
|
||||
article_id: "22222222-2222-2222-2222-222222222222",
|
||||
sort_order: 1,
|
||||
category: "audience",
|
||||
question: "Audience?",
|
||||
answer: "",
|
||||
is_required: true,
|
||||
created_at: "2026-05-21T00:00:00Z",
|
||||
updated_at: "2026-05-21T00:00:00Z",
|
||||
},
|
||||
{
|
||||
id: "33333333-3333-3333-3333-333333333333",
|
||||
article_id: "22222222-2222-2222-2222-222222222222",
|
||||
sort_order: 2,
|
||||
category: "visual_expectations",
|
||||
question: "Visuals?",
|
||||
answer: "",
|
||||
is_required: false,
|
||||
created_at: "2026-05-21T00:00:00Z",
|
||||
updated_at: "2026-05-21T00:00:00Z",
|
||||
},
|
||||
]);
|
||||
|
||||
assert.equal(rows[0].stateLabel, "Required");
|
||||
assert.equal(rows[1].stateLabel, "Optional");
|
||||
|
||||
const errors = validateRequiredAnswers(rows);
|
||||
assert.equal(errors["11111111-1111-1111-1111-111111111111"], "Required answer");
|
||||
assert.equal(errors["33333333-3333-3333-3333-333333333333"], undefined);
|
||||
Reference in New Issue
Block a user