File size: 1,413 Bytes
6f07329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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: [] },
		});
	});
});