chat-ui-agent-demo / src /lib /components /agent /agentQueueMutations.test.ts
Mike0021's picture
deploy: production agent journey fixes
6f07329 verified
Raw History Blame Contribute Delete
1.41 kB
import { describe, expect, it } from "vitest";
import {
agentQueueMatchesSnapshot,
captureAgentQueueMutationTarget,
createAgentQueueReplacement,
} from "./agentQueueMutations";
describe("Agent queue mutation targets", () => {
it("keeps an edit bound to the item and snapshot captured when editing began", () => {
const target = captureAgentQueueMutationTarget(
{ steering: ["Original item"], followUp: ["Run tests"] },
"steering",
0
);
if (!target) throw new Error("expected queue target");
expect(
agentQueueMatchesSnapshot(
{ steering: ["Concurrent item", "Original item"], followUp: ["Run tests"] },
target.expected
)
).toBe(false);
expect(createAgentQueueReplacement(target, "edit", "Edited original")).toEqual({
expected: { steering: ["Original item"], followUp: ["Run tests"] },
replacement: { steering: ["Edited original"], followUp: ["Run tests"] },
});
});
it("removes the captured item without consulting a later reordered queue", () => {
const target = captureAgentQueueMutationTarget(
{ steering: ["Keep first", "Remove second"], followUp: [] },
"steering",
1
);
if (!target) throw new Error("expected queue target");
expect(createAgentQueueReplacement(target, "remove")).toEqual({
expected: { steering: ["Keep first", "Remove second"], followUp: [] },
replacement: { steering: ["Keep first"], followUp: [] },
});
});
});