mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:30:43 +00:00
test: update compaction token test contexts
This commit is contained in:
@@ -53,6 +53,7 @@ function createCompactionContext(params: {
|
||||
},
|
||||
getCompactionCount: () => compactionCount,
|
||||
noteCompactionTokensAfter: vi.fn(),
|
||||
getLastCompactionTokensAfter: vi.fn(() => undefined),
|
||||
} as unknown as EmbeddedPiSubscribeContext;
|
||||
}
|
||||
|
||||
@@ -144,5 +145,6 @@ describe("handleCompactionEnd", () => {
|
||||
});
|
||||
|
||||
expect(await readCompactionCount(storePath, sessionKey)).toBe(2);
|
||||
expect(ctx.noteCompactionTokensAfter).toHaveBeenCalledWith(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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" } });
|
||||
|
||||
Reference in New Issue
Block a user