droboticflow/tests/frontend/template-settings.test.mjs

86 lines
2.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",
maxConcurrentRuns: 2,
nodeTimeoutSeconds: 12,
runTimeoutSeconds: 34,
maxRetryAttempts: 1,
retryBackoffSeconds: 56,
schedule: {
interval: 90,
sourcePath: "oss://incoming/videos",
},
nodes: [{ id: "node-1" }],
edges: [{ id: "edge-1" }],
});
assert.deepEqual(payload, {
name: "视频审核模板 实例",
description: "template description",
type: "streaming",
maxConcurrentRuns: 2,
nodeTimeoutSeconds: 12,
runTimeoutSeconds: 34,
maxRetryAttempts: 1,
retryBackoffSeconds: 56,
schedule: {
interval: 90,
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",
maxConcurrentRuns: 3,
nodeTimeoutSeconds: 22,
runTimeoutSeconds: 44,
maxRetryAttempts: 2,
retryBackoffSeconds: 11,
schedule: {
interval: 30,
sourcePath: "oss://stream",
},
nodes: [{ id: "node-a" }],
edges: [],
},
{
name: "实时监听模板",
description: "template description",
},
);
assert.deepEqual(payload, {
name: "实时监听模板",
description: "template description",
type: "streaming",
maxConcurrentRuns: 3,
nodeTimeoutSeconds: 22,
runTimeoutSeconds: 44,
maxRetryAttempts: 2,
retryBackoffSeconds: 11,
schedule: {
interval: 30,
sourcePath: "oss://stream",
},
nodes: [{ id: "node-a" }],
edges: [],
});
});