forked from longtao.wu/droboticflow
124 lines
3.1 KiB
JavaScript
124 lines
3.1 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { buildTemplatePayload, buildWorkflowFromTemplate } from "../../src/lib/templates.js";
|
|
|
|
test("buildWorkflowFromTemplate preserves workflow-level execution config", () => {
|
|
const payload = buildWorkflowFromTemplate({
|
|
name: "视频审核模板",
|
|
description: "template description",
|
|
type: "streaming",
|
|
kind: "scan",
|
|
executionScope: "production",
|
|
scanConfig: {
|
|
dataSource: "BOS",
|
|
accessKeyId: "ak-copy",
|
|
secretAccessKey: "sk-copy",
|
|
},
|
|
maxConcurrentRuns: 2,
|
|
nodeTimeoutSeconds: 12,
|
|
runTimeoutSeconds: 34,
|
|
maxRetryAttempts: 1,
|
|
retryBackoffSeconds: 56,
|
|
schedule: {
|
|
mode: "every_hours",
|
|
interval: 90,
|
|
intervalHours: 4,
|
|
anchorAt: "2026-04-21T10:15:00Z",
|
|
sourcePath: "oss://incoming/videos",
|
|
},
|
|
nodes: [{ id: "node-1" }],
|
|
edges: [{ id: "edge-1" }],
|
|
});
|
|
|
|
assert.deepEqual(payload, {
|
|
name: "视频审核模板 实例",
|
|
description: "template description",
|
|
type: "streaming",
|
|
kind: "scan",
|
|
executionScope: "production",
|
|
scanConfig: {
|
|
dataSource: "BOS",
|
|
accessKeyId: "ak-copy",
|
|
secretAccessKey: "sk-copy",
|
|
},
|
|
maxConcurrentRuns: 2,
|
|
nodeTimeoutSeconds: 12,
|
|
runTimeoutSeconds: 34,
|
|
maxRetryAttempts: 1,
|
|
retryBackoffSeconds: 56,
|
|
schedule: {
|
|
mode: "every_hours",
|
|
interval: 90,
|
|
intervalHours: 4,
|
|
anchorAt: "2026-04-21T10:15:00Z",
|
|
sourcePath: "oss://incoming/videos",
|
|
},
|
|
nodes: [{ id: "node-1" }],
|
|
edges: [{ id: "edge-1" }],
|
|
});
|
|
});
|
|
|
|
test("buildTemplatePayload carries workflow-level config into templates", () => {
|
|
const payload = buildTemplatePayload(
|
|
{
|
|
name: "实时监听工作流",
|
|
description: "workflow description",
|
|
type: "streaming",
|
|
kind: "scan",
|
|
scanConfig: {
|
|
dataSource: "BOS",
|
|
accessKeyId: "ak-template",
|
|
secretAccessKey: "sk-template",
|
|
},
|
|
maxConcurrentRuns: 3,
|
|
nodeTimeoutSeconds: 22,
|
|
runTimeoutSeconds: 44,
|
|
maxRetryAttempts: 2,
|
|
retryBackoffSeconds: 11,
|
|
schedule: {
|
|
mode: "every_days_at_time",
|
|
interval: 30,
|
|
dayInterval: 2,
|
|
timeOfDay: "18:30",
|
|
timezone: "Asia/Shanghai",
|
|
sourcePath: "oss://stream",
|
|
},
|
|
nodes: [{ id: "node-a" }],
|
|
edges: [],
|
|
},
|
|
{
|
|
name: "实时监听模板",
|
|
description: "template description",
|
|
},
|
|
);
|
|
|
|
assert.deepEqual(payload, {
|
|
name: "实时监听模板",
|
|
description: "template description",
|
|
type: "streaming",
|
|
kind: "scan",
|
|
executionScope: "production",
|
|
scanConfig: {
|
|
dataSource: "BOS",
|
|
accessKeyId: "ak-template",
|
|
secretAccessKey: "sk-template",
|
|
},
|
|
maxConcurrentRuns: 3,
|
|
nodeTimeoutSeconds: 22,
|
|
runTimeoutSeconds: 44,
|
|
maxRetryAttempts: 2,
|
|
retryBackoffSeconds: 11,
|
|
schedule: {
|
|
mode: "every_days_at_time",
|
|
interval: 30,
|
|
dayInterval: 2,
|
|
timeOfDay: "18:30",
|
|
timezone: "Asia/Shanghai",
|
|
sourcePath: "oss://stream",
|
|
},
|
|
nodes: [{ id: "node-a" }],
|
|
edges: [],
|
|
});
|
|
});
|