test: update compaction token test contexts

This commit is contained in:
Peter Steinberger
2026-04-27 15:17:36 +01:00
parent 467ee701ef
commit 9b4c1f0fa3
2 changed files with 6 additions and 1 deletions

View File

@@ -60,6 +60,7 @@ describe("compaction hook wiring", () => {
incrementCompactionCount: vi.fn(),
getCompactionCount: () => params.compactionCount ?? 0,
noteCompactionTokensAfter: vi.fn(),
getLastCompactionTokensAfter: vi.fn(() => undefined),
...(params.withRetryHooks
? {
noteCompactionRetry: vi.fn(),
@@ -108,7 +109,7 @@ describe("compaction hook wiring", () => {
ctx: ReturnType<typeof createCompactionEndCtx> | Record<string, unknown>,
event: {
willRetry: boolean;
result?: { summary: string };
result?: { summary: string; tokensAfter?: number };
aborted?: boolean;
},
) {
@@ -185,6 +186,7 @@ describe("compaction hook wiring", () => {
expectedSessionKey: "agent:main:web-xyz",
});
expect(ctx.incrementCompactionCount).toHaveBeenCalledTimes(1);
expect(ctx.noteCompactionTokensAfter).toHaveBeenCalledWith(undefined);
expect(ctx.maybeResolveCompactionWait).toHaveBeenCalledTimes(1);
expect(hookMocks.emitAgentEvent).toHaveBeenCalledWith({
runId: "r2",
@@ -253,6 +255,7 @@ describe("compaction hook wiring", () => {
getCompactionCount: () => 1,
incrementCompactionCount: vi.fn(),
noteCompactionTokensAfter: vi.fn(),
getLastCompactionTokensAfter: vi.fn(() => undefined),
};
runCompactionEnd(ctx, { willRetry: false, result: { summary: "compacted" } });