forked from longtao.wu/droboticflow
Include the accumulated workflow scheduling, run history, subtree rerun, operator UI, deployment, data asset, object storage, database browser, and documentation changes currently in the worktree.
127 lines
3.3 KiB
JavaScript
127 lines
3.3 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
buildSelectedNodeEnvRows,
|
|
getWorkflowRunActionState,
|
|
isWorkflowSettingsLocked,
|
|
} from "../../src/lib/workflow-editor.js";
|
|
|
|
test("completed workflows cannot be run manually again", () => {
|
|
const action = getWorkflowRunActionState({
|
|
isTemplate: false,
|
|
isReadOnly: true,
|
|
workflowStatus: "completed",
|
|
activeRunStatus: "",
|
|
isExecuting: false,
|
|
});
|
|
|
|
assert.equal(action.disabled, true);
|
|
assert.equal(action.reason, "completed");
|
|
assert.equal(action.label, "已成功运行");
|
|
});
|
|
|
|
test("active runs take precedence over readonly button labels", () => {
|
|
const action = getWorkflowRunActionState({
|
|
isTemplate: false,
|
|
isReadOnly: true,
|
|
workflowStatus: "running",
|
|
activeRunStatus: "running",
|
|
isExecuting: false,
|
|
});
|
|
|
|
assert.equal(action.disabled, true);
|
|
assert.equal(action.reason, "running");
|
|
assert.equal(action.label, "工作流运行中");
|
|
});
|
|
|
|
test("workflow status running also disables the run action", () => {
|
|
const action = getWorkflowRunActionState({
|
|
isTemplate: false,
|
|
isReadOnly: false,
|
|
workflowStatus: "running",
|
|
activeRunStatus: "",
|
|
isExecuting: false,
|
|
});
|
|
|
|
assert.equal(action.disabled, true);
|
|
assert.equal(action.reason, "running");
|
|
});
|
|
|
|
test("active run status overrides stale completed workflow status", () => {
|
|
const action = getWorkflowRunActionState({
|
|
isTemplate: false,
|
|
isReadOnly: false,
|
|
workflowStatus: "completed",
|
|
activeRunStatus: "running",
|
|
isExecuting: false,
|
|
});
|
|
|
|
assert.equal(action.disabled, true);
|
|
assert.equal(action.reason, "running");
|
|
assert.equal(action.label, "工作流运行中");
|
|
});
|
|
|
|
test("workflow settings lock while an active run is still in flight", () => {
|
|
assert.equal(
|
|
isWorkflowSettingsLocked({
|
|
isReadOnly: false,
|
|
workflowStatus: "completed",
|
|
activeRunStatus: "running",
|
|
}),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test("workflow settings lock for readonly and completed workflows", () => {
|
|
assert.equal(
|
|
isWorkflowSettingsLocked({
|
|
isReadOnly: false,
|
|
workflowStatus: "completed",
|
|
}),
|
|
true,
|
|
);
|
|
assert.equal(
|
|
isWorkflowSettingsLocked({
|
|
isReadOnly: true,
|
|
workflowStatus: "draft",
|
|
}),
|
|
true,
|
|
);
|
|
assert.equal(
|
|
isWorkflowSettingsLocked({
|
|
isReadOnly: false,
|
|
workflowStatus: "draft",
|
|
}),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("node env rows include inherited workflow envs but keep node overrides first", () => {
|
|
const rows = buildSelectedNodeEnvRows({
|
|
nodeHyperparams: [
|
|
{ key: "GLOBAL_ENV", value: "node-level" },
|
|
{ key: "NODE_ONLY", value: "yes" },
|
|
],
|
|
workflowHyperparams: [
|
|
{ key: "GLOBAL_ENV", value: "workflow-level" },
|
|
{ key: "WORKFLOW_ONLY", value: "shared" },
|
|
],
|
|
systemRows: [{ key: "WORKFLOW_CURRENT_RUN_TIMESTAMP", value: "2026-04-22T10:00:00+08:00", source: "system" }],
|
|
});
|
|
|
|
assert.deepEqual(
|
|
rows.map((item) => ({ key: item.key, value: item.value, source: item.source })),
|
|
[
|
|
{ key: "GLOBAL_ENV", value: "node-level", source: "custom" },
|
|
{ key: "NODE_ONLY", value: "yes", source: "custom" },
|
|
{ key: "WORKFLOW_ONLY", value: "shared", source: "workflow" },
|
|
{
|
|
key: "WORKFLOW_CURRENT_RUN_TIMESTAMP",
|
|
value: "2026-04-22T10:00:00+08:00",
|
|
source: "system",
|
|
},
|
|
],
|
|
);
|
|
});
|