feat: implement final approval gate workflow and checklist
This commit is contained in:
@@ -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/final-approval/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 { buildFinalApprovalViewModel } = moduleExports;
|
||||
|
||||
const viewModel = buildFinalApprovalViewModel({
|
||||
article_id: "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
|
||||
draft_version: 3,
|
||||
requested_draft_version: 2,
|
||||
can_approve: false,
|
||||
completed_items: ["Plan followed", "Evidence reviewed"],
|
||||
blockers: [
|
||||
"Final approval requires latest draft version 3.",
|
||||
"Required publishing settings are missing: content path.",
|
||||
],
|
||||
items: [
|
||||
{
|
||||
key: "exact_draft_version",
|
||||
title: "Exact draft version selected",
|
||||
completed: false,
|
||||
blocker: "Final approval requires latest draft version 3.",
|
||||
},
|
||||
{
|
||||
key: "plan_followed",
|
||||
title: "Plan followed",
|
||||
completed: true,
|
||||
blocker: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
assert.equal(viewModel.canApprove, false);
|
||||
assert.equal(viewModel.draftVersion, 3);
|
||||
assert.equal(viewModel.requestedDraftVersion, 2);
|
||||
assert.equal(viewModel.completedItems.length, 2);
|
||||
assert.equal(viewModel.blockers.length, 2);
|
||||
assert.equal(viewModel.items.length, 2);
|
||||
assert.equal(viewModel.items[0].completed, false);
|
||||
assert.equal(viewModel.items[1].completed, true);
|
||||
Reference in New Issue
Block a user