forked from longtao.wu/droboticflow
73 lines
1.7 KiB
JavaScript
73 lines
1.7 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
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",
|
|
isExecuting: false,
|
|
activeRunInFlight: 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",
|
|
isExecuting: false,
|
|
activeRunInFlight: true,
|
|
});
|
|
|
|
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",
|
|
isExecuting: false,
|
|
activeRunInFlight: false,
|
|
});
|
|
|
|
assert.equal(action.disabled, true);
|
|
assert.equal(action.reason, "running");
|
|
});
|
|
|
|
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,
|
|
);
|
|
});
|