tests: cover agent sequencing, tick watchdog, presence fingerprint
This commit is contained in:
23
src/infra/agent-events.test.ts
Normal file
23
src/infra/agent-events.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { emitAgentEvent, onAgentEvent } from "./agent-events.js";
|
||||
|
||||
describe("agent-events sequencing", () => {
|
||||
test("maintains monotonic seq per runId", async () => {
|
||||
const seen: Record<string, number[]> = {};
|
||||
const stop = onAgentEvent((evt) => {
|
||||
const list = seen[evt.runId] ?? [];
|
||||
seen[evt.runId] = list;
|
||||
list.push(evt.seq);
|
||||
});
|
||||
|
||||
emitAgentEvent({ runId: "run-1", stream: "job", data: {} });
|
||||
emitAgentEvent({ runId: "run-1", stream: "job", data: {} });
|
||||
emitAgentEvent({ runId: "run-2", stream: "job", data: {} });
|
||||
emitAgentEvent({ runId: "run-1", stream: "job", data: {} });
|
||||
|
||||
stop();
|
||||
|
||||
expect(seen["run-1"]).toEqual([1, 2, 3]);
|
||||
expect(seen["run-2"]).toEqual([1]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user