feat(task-023): bind workflow templates into demo flow
This commit is contained in:
@@ -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