fix: stabilize auth identity, record operations, and workflow diagnostics
This commit is contained in:
1 parent
c74fdda7da
commit
7ec369f77e
36 files changed
+1021
-337
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { diffWorkflowJobs } from "./services.js";
|
||||
import type { WorkflowJobDetail, WorkflowTaskExecution } from "./types.js";
|
||||
|
||||
const job = { id: "job", status: "COMPLETED" } as WorkflowJobDetail;
|
||||
const node = (id: string, loop: string, status = "COMPLETED", value = 1): WorkflowTaskExecution => ({ id, name: "edit", type: "code", status, currentLoopPath: loop, inputs: { value } });
|
||||
|
||||
describe("workflow diff execution identities", () => {
|
||||
it("compares every loop instance rather than only the first task name", () => {
|
||||
const result = diffWorkflowJobs(job, [node("a0", "0"), node("a1", "1", "FAILED", 2)], job, [node("b0", "0"), node("b1", "1", "COMPLETED", 3)]);
|
||||
expect(result.nodes).toHaveLength(2);
|
||||
expect(result.summary.divergedNodesCount).toBe(1);
|
||||
expect(result.summary.statusDiffCount).toBe(1);
|
||||
expect(result.nodes.find(n => n.diverged)?.currentLoopPath).toBe("1");
|
||||
});
|
||||
it("preserves repeated attempts and identifies missing instances", () => {
|
||||
const result = diffWorkflowJobs(job, [node("a0", "0"), node("a1", "0", "FAILED")], job, [node("b0", "0")]);
|
||||
expect(result.nodes).toHaveLength(2);
|
||||
expect(result.summary.divergedNodesCount).toBe(1);
|
||||
});
|
||||
it("uses the parent task path when repeated names occur in different branches", () => {
|
||||
const tree = (prefix: string, value: number): WorkflowTaskExecution[] => [
|
||||
{ id: prefix + "left", name: "left", type: "condition", status: "COMPLETED", children: [node(prefix + "a", "0")] },
|
||||
{ id: prefix + "right", name: "right", type: "condition", status: "COMPLETED", children: [node(prefix + "b", "0", "COMPLETED", value)] },
|
||||
];
|
||||
const result = diffWorkflowJobs(job, tree("a", 1), job, tree("b", 2));
|
||||
expect(result.nodes).toHaveLength(4);
|
||||
expect(result.summary.divergedNodesCount).toBe(1);
|
||||
});
|
||||
it("counts output-only changes, including the singular output wire format", () => {
|
||||
const result = diffWorkflowJobs(job, [{ ...node("a", "0"), output: { value: 1 } }], job, [{ ...node("b", "0"), output: { value: 2 } }]);
|
||||
expect(result.summary.divergedNodesCount).toBe(1);
|
||||
expect(result.nodes[0]?.outputsDiff).toEqual([{ field: "value", from: 1, to: 2 }]);
|
||||
});
|
||||
it("resolves flat parentId relationships even when siblings change order", () => {
|
||||
const tree = (prefix: string, reversed: boolean): WorkflowTaskExecution[] => {
|
||||
const children = [
|
||||
{ ...node(prefix + "childA", "0", "COMPLETED", 1), parentId: prefix + "left" },
|
||||
{ ...node(prefix + "childB", "0", "COMPLETED", 2), parentId: prefix + "right" },
|
||||
];
|
||||
return [...(reversed ? children.reverse() : children), { id: prefix + "left", name: "left", type: "condition", status: "COMPLETED" }, { id: prefix + "right", name: "right", type: "condition", status: "COMPLETED" }];
|
||||
};
|
||||
const result = diffWorkflowJobs(job, tree("a", false), job, tree("b", true));
|
||||
expect(result.summary.divergedNodesCount).toBe(0);
|
||||
expect(result.nodes).toHaveLength(4);
|
||||
});
|
||||
it("does not discard scalar output changes", () => {
|
||||
const result = diffWorkflowJobs(job, [{ ...node("a", "0"), output: 1 }], job, [{ ...node("b", "0"), output: 2 }]);
|
||||
expect(result.summary.divergedNodesCount).toBe(1);
|
||||
expect(result.nodes[0]?.outputsDiff).toEqual([{ field: "$value", from: 1, to: 2 }]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user