feat(task-023): bind workflow templates into demo flow
This commit is contained in:
@@ -30,6 +30,32 @@ const detail = {
|
||||
updated_at: "2026-05-21T00:00:00Z",
|
||||
},
|
||||
target_site: { name: "Demo Site" },
|
||||
workflow_template_snapshot: {
|
||||
id: "workflow-1",
|
||||
name: "Demo workflow",
|
||||
slug: "demo-workflow",
|
||||
version: 2,
|
||||
stage_summary: [
|
||||
{
|
||||
id: "stage-2",
|
||||
stable_key: "draft",
|
||||
display_name: "Draft assembly",
|
||||
position: 2,
|
||||
owner_role: "EDITOR",
|
||||
runner_profile_key: "draft-agent",
|
||||
requires_human_approval: false,
|
||||
},
|
||||
{
|
||||
id: "stage-1",
|
||||
stable_key: "intake",
|
||||
display_name: "Intake",
|
||||
position: 1,
|
||||
owner_role: "EDITOR",
|
||||
runner_profile_key: "intake-agent",
|
||||
requires_human_approval: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
timeline: [
|
||||
{
|
||||
id: "2",
|
||||
@@ -131,5 +157,11 @@ const summary = buildDetailSummary(detail, {
|
||||
assert.equal(summary.viewerRole, "EDITOR");
|
||||
assert.equal(summary.viewerEmail, "editor@example.com");
|
||||
assert.equal(summary.targetSite, "Demo Site");
|
||||
assert.equal(summary.workflowTemplate.name, "Demo workflow");
|
||||
assert.equal(summary.workflowTemplate.version, 2);
|
||||
assert.deepEqual(
|
||||
summary.workflowTemplate.stages.map((stage) => stage.stableKey),
|
||||
["intake", "draft"],
|
||||
);
|
||||
assert.equal(summary.timeline.length, 2);
|
||||
assert.equal(summary.jobDetails.length, 1);
|
||||
|
||||
@@ -23,9 +23,29 @@ new Function("exports", compiled.outputText)(moduleExports);
|
||||
|
||||
const validateArticleDraft = moduleExports.validateArticleDraft;
|
||||
const initialDraft = moduleExports.initialDraft;
|
||||
const buildCreateArticlePayload = moduleExports.buildCreateArticlePayload;
|
||||
const buildWorkflowTemplateOptions = moduleExports.buildWorkflowTemplateOptions;
|
||||
|
||||
const activeWorkflow = {
|
||||
id: "workflow-1",
|
||||
name: "Demo workflow",
|
||||
slug: "demo-workflow",
|
||||
description: "Demo workflow",
|
||||
status: "ACTIVE",
|
||||
version: 2,
|
||||
created_by: "admin",
|
||||
updated_by: "admin",
|
||||
created_at: "2026-05-22T00:00:00Z",
|
||||
updated_at: "2026-05-22T00:00:00Z",
|
||||
stages: [
|
||||
{ id: "stage-1" },
|
||||
{ id: "stage-2" },
|
||||
],
|
||||
};
|
||||
|
||||
const draft = {
|
||||
targetSiteId: "",
|
||||
workflowTemplateId: "",
|
||||
briefDescription: "Keep this text intact",
|
||||
workingTitle: "",
|
||||
contentType: "longform_guide",
|
||||
@@ -43,3 +63,27 @@ assert.equal(
|
||||
|
||||
const fallbackDraft = initialDraft([]);
|
||||
assert.equal(fallbackDraft.contentType, "longform_guide", "default content type preserved");
|
||||
|
||||
const workflowDraft = initialDraft(
|
||||
[{ id: "site-1" }],
|
||||
[activeWorkflow, { ...activeWorkflow, id: "workflow-archived", status: "ARCHIVED" }],
|
||||
);
|
||||
assert.equal(workflowDraft.workflowTemplateId, "workflow-1");
|
||||
|
||||
assert.deepEqual(buildWorkflowTemplateOptions([activeWorkflow]), [
|
||||
{
|
||||
id: "workflow-1",
|
||||
label: "Demo workflow v2",
|
||||
version: 2,
|
||||
stageCount: 2,
|
||||
},
|
||||
]);
|
||||
|
||||
assert.equal(
|
||||
buildCreateArticlePayload({
|
||||
...workflowDraft,
|
||||
briefDescription: "Brief",
|
||||
primaryKeyword: "workflow",
|
||||
}).workflow_template_id,
|
||||
"workflow-1",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user