test: complete vitest mock API fixes for callCount and calls access
This commit is contained in:
parent
1de5d5456a
commit
5cf94c296e
7 changed files with 40 additions and 40 deletions
|
|
@ -179,7 +179,7 @@ describe('EventBridge', () => {
|
|||
sessionId: 'sess-1', projectDir: '/test/project', projectName: 'my-project',
|
||||
});
|
||||
await tick();
|
||||
assert.equal(mockFn(channelManager.createProjectChannel).mock.callCount, 1);
|
||||
assert.equal(mockFn(channelManager.createProjectChannel).mock.calls.length, 1);
|
||||
});
|
||||
|
||||
it('logs error and skips when channel creation fails', async () => {
|
||||
|
|
@ -194,7 +194,7 @@ describe('EventBridge', () => {
|
|||
sessionId: 'sess-1', projectDir: '/test/project', projectName: 'my-project',
|
||||
});
|
||||
await tick();
|
||||
assert.ok(mockFn(logger.error).mock.callCount > 0);
|
||||
assert.ok(mockFn(logger.error).mock.calls.length > 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -213,7 +213,7 @@ describe('EventBridge', () => {
|
|||
});
|
||||
await tick();
|
||||
// No errors
|
||||
assert.equal(mockFn(logger.error).mock.callCount, 0);
|
||||
assert.equal(mockFn(logger.error).mock.calls.length, 0);
|
||||
});
|
||||
|
||||
it('filters events based on verbosity', async () => {
|
||||
|
|
@ -239,7 +239,7 @@ describe('EventBridge', () => {
|
|||
event: { type: 'tool_execution_start', name: 'read' } as SdkAgentEvent,
|
||||
});
|
||||
await tick();
|
||||
assert.equal(mockFn(logger.error).mock.callCount, 0);
|
||||
assert.equal(mockFn(logger.error).mock.calls.length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -260,7 +260,7 @@ describe('EventBridge', () => {
|
|||
sessionId: 'sess-1', projectDir: '/test/project', projectName: 'my-project', blocker,
|
||||
});
|
||||
await tick();
|
||||
assert.ok(mockFn(channelManager._channel.createMessageComponentCollector).mock.callCount > 0);
|
||||
assert.ok(mockFn(channelManager._channel.createMessageComponentCollector).mock.calls.length > 0);
|
||||
});
|
||||
|
||||
it('sends DM when dm_on_blocker is configured', async () => {
|
||||
|
|
@ -287,7 +287,7 @@ describe('EventBridge', () => {
|
|||
await tick();
|
||||
|
||||
const usersFetch = (client as unknown as Record<string, { fetch: unknown }>).users.fetch;
|
||||
assert.equal(mockFn(usersFetch).mock.callCount, 1);
|
||||
assert.equal(mockFn(usersFetch).mock.calls.length, 1);
|
||||
});
|
||||
|
||||
it('does not send DM when dm_on_blocker is false', async () => {
|
||||
|
|
@ -310,7 +310,7 @@ describe('EventBridge', () => {
|
|||
await tick();
|
||||
|
||||
const usersFetch = (client as unknown as Record<string, { fetch: unknown }>).users.fetch;
|
||||
assert.equal(mockFn(usersFetch).mock.callCount, 0);
|
||||
assert.equal(mockFn(usersFetch).mock.calls.length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -346,7 +346,7 @@ describe('EventBridge', () => {
|
|||
collector.emit('collect', mockInteraction);
|
||||
await tick();
|
||||
|
||||
assert.equal(mockFn(sessionManager.resolveBlocker).mock.callCount, 1);
|
||||
assert.equal(mockFn(sessionManager.resolveBlocker).mock.calls.length, 1);
|
||||
const args = mockFn(sessionManager.resolveBlocker).mock.calls[0]!;
|
||||
assert.equal(args[0], 'sess-1');
|
||||
assert.equal(args[1], 'true');
|
||||
|
|
@ -382,8 +382,8 @@ describe('EventBridge', () => {
|
|||
collector.emit('collect', mockInteraction);
|
||||
await tick();
|
||||
|
||||
assert.equal(mockFn(sessionManager.resolveBlocker).mock.callCount, 0);
|
||||
assert.equal(mockFn(mockInteraction.reply).mock.callCount, 1);
|
||||
assert.equal(mockFn(sessionManager.resolveBlocker).mock.calls.length, 0);
|
||||
assert.equal(mockFn(mockInteraction.reply).mock.calls.length, 1);
|
||||
});
|
||||
|
||||
it('posts error when resolveBlocker throws', async () => {
|
||||
|
|
@ -417,7 +417,7 @@ describe('EventBridge', () => {
|
|||
collector.emit('collect', mockInteraction);
|
||||
await tick();
|
||||
|
||||
assert.equal(mockFn(mockInteraction.reply).mock.callCount, 1);
|
||||
assert.equal(mockFn(mockInteraction.reply).mock.calls.length, 1);
|
||||
const replyArg = mockFn(mockInteraction.reply).mock.calls[0]![0] as Record<string, unknown>;
|
||||
assert.ok(String(replyArg.content).includes('Failed to resolve'));
|
||||
});
|
||||
|
|
@ -445,7 +445,7 @@ describe('EventBridge', () => {
|
|||
client.emit('messageCreate', msg);
|
||||
await tick();
|
||||
|
||||
assert.equal(mockFn(session.client.steer).mock.callCount, 1);
|
||||
assert.equal(mockFn(session.client.steer).mock.calls.length, 1);
|
||||
assert.equal(mockFn(session.client.steer).mock.calls[0]![0], 'check the test results');
|
||||
});
|
||||
|
||||
|
|
@ -474,7 +474,7 @@ describe('EventBridge', () => {
|
|||
client.emit('messageCreate', msg);
|
||||
await tick();
|
||||
|
||||
assert.equal(mockFn(sessionManager.resolveBlocker).mock.callCount, 1);
|
||||
assert.equal(mockFn(sessionManager.resolveBlocker).mock.calls.length, 1);
|
||||
assert.equal(mockFn(sessionManager.resolveBlocker).mock.calls[0]![1], 'my-api-key-value');
|
||||
});
|
||||
|
||||
|
|
@ -498,7 +498,7 @@ describe('EventBridge', () => {
|
|||
});
|
||||
await tick();
|
||||
|
||||
assert.equal(mockFn(session.client.steer).mock.callCount, 0);
|
||||
assert.equal(mockFn(session.client.steer).mock.calls.length, 0);
|
||||
});
|
||||
|
||||
it('ignores messages in non-project channels', async () => {
|
||||
|
|
@ -516,7 +516,7 @@ describe('EventBridge', () => {
|
|||
});
|
||||
await tick();
|
||||
|
||||
assert.equal(mockFn(session.client.steer).mock.callCount, 0);
|
||||
assert.equal(mockFn(session.client.steer).mock.calls.length, 0);
|
||||
});
|
||||
|
||||
it('ignores messages from unauthorized users', async () => {
|
||||
|
|
@ -539,7 +539,7 @@ describe('EventBridge', () => {
|
|||
});
|
||||
await tick();
|
||||
|
||||
assert.equal(mockFn(session.client.steer).mock.callCount, 0);
|
||||
assert.equal(mockFn(session.client.steer).mock.calls.length, 0);
|
||||
});
|
||||
|
||||
it('posts error when steer fails', async () => {
|
||||
|
|
@ -566,7 +566,7 @@ describe('EventBridge', () => {
|
|||
client.emit('messageCreate', msg);
|
||||
await tick();
|
||||
|
||||
assert.equal(mockFn(msg.reply).mock.callCount, 1);
|
||||
assert.equal(mockFn(msg.reply).mock.calls.length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -591,7 +591,7 @@ describe('EventBridge', () => {
|
|||
event: { type: 'tool_execution_start', name: 'read' } as SdkAgentEvent,
|
||||
});
|
||||
await tick();
|
||||
assert.equal(mockFn(logger.error).mock.callCount, 0);
|
||||
assert.equal(mockFn(logger.error).mock.calls.length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -154,8 +154,8 @@ describe("generateSummary — chunked fallback (#2932)", () => {
|
|||
|
||||
// Assert: should have called completeSimple more than once (chunked)
|
||||
assert.ok(
|
||||
mockComplete.mock.callCount > 1,
|
||||
`Expected multiple calls for chunked summarization, got ${mockComplete.mock.callCount}`,
|
||||
mockComplete.mock.calls.length > 1,
|
||||
`Expected multiple calls for chunked summarization, got ${mockComplete.mock.calls.length}`,
|
||||
);
|
||||
|
||||
// First call should be an initial summary, subsequent should be updates
|
||||
|
|
@ -189,7 +189,7 @@ describe("generateSummary — chunked fallback (#2932)", () => {
|
|||
await generateSummary(messages, model, reserveTokens, undefined, undefined, undefined, undefined, mockComplete);
|
||||
|
||||
assert.equal(
|
||||
mockComplete.mock.callCount,
|
||||
mockComplete.mock.calls.length,
|
||||
1,
|
||||
"Should use single-pass summarization when messages fit in context window",
|
||||
);
|
||||
|
|
|
|||
|
|
@ -317,8 +317,8 @@ describe("TUI Command Flow Tests", { skip: skipReason }, () => {
|
|||
|
||||
console.log("\nNotifications shown:");
|
||||
notifyCalls.forEach((call, i) => {
|
||||
const msg = call.arguments[0];
|
||||
const level = call.arguments[1];
|
||||
const msg = call[0];
|
||||
const level = call[1];
|
||||
console.log(` ${i + 1}. [${level}]: ${String(msg).split("\n")[0]}`);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ describe("Post-execution blocking failure retry bypass", () => {
|
|||
|
||||
// Non-execute-task units should return "continue" immediately
|
||||
assert.equal(result, "continue");
|
||||
assert.equal(pauseAutoMock.mock.callCount, 0);
|
||||
assert.equal(pauseAutoMock.mock.calls.length, 0);
|
||||
});
|
||||
|
||||
test("returns continue when verification passes", async () => {
|
||||
|
|
@ -256,7 +256,7 @@ describe("Post-execution blocking failure retry bypass", () => {
|
|||
|
||||
// When verification passes, should return "continue" and not call pauseAuto
|
||||
assert.equal(result, "continue");
|
||||
assert.equal(pauseAutoMock.mock.callCount, 0);
|
||||
assert.equal(pauseAutoMock.mock.calls.length, 0);
|
||||
|
||||
// Retry state should be cleared
|
||||
assert.equal(s.pendingVerificationRetry, null);
|
||||
|
|
@ -345,7 +345,7 @@ describe("Post-execution blocking failure retry bypass", () => {
|
|||
const result = await runPostUnitVerification(vctx, pauseAutoMock);
|
||||
|
||||
assert.equal(result, "pause");
|
||||
assert.equal(pauseAutoMock.mock.callCount, 1);
|
||||
assert.equal(pauseAutoMock.mock.calls.length, 1);
|
||||
|
||||
const adapter = _getAdapter();
|
||||
const row = adapter
|
||||
|
|
@ -426,7 +426,7 @@ describe("Post-execution retry behavior", () => {
|
|||
|
||||
// When autofix is disabled and verification fails, should pause
|
||||
assert.equal(result, "pause");
|
||||
assert.equal(pauseAutoMock.mock.callCount, 1);
|
||||
assert.equal(pauseAutoMock.mock.calls.length, 1);
|
||||
|
||||
// Should NOT set up a retry
|
||||
assert.equal(s.pendingVerificationRetry, null);
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ describe("Pre-execution fail-closed behavior", () => {
|
|||
|
||||
// With valid tasks, pre-exec should pass and not pause
|
||||
assert.equal(
|
||||
pauseAutoMock.mock.callCount,
|
||||
pauseAutoMock.mock.calls.length,
|
||||
0,
|
||||
"pauseAuto should NOT be called when pre-execution checks pass",
|
||||
);
|
||||
|
|
@ -267,7 +267,7 @@ describe("Pre-execution fail-closed behavior", () => {
|
|||
|
||||
// With a blocking failure, pauseAuto should be called
|
||||
assert.equal(
|
||||
pauseAutoMock.mock.callCount,
|
||||
pauseAutoMock.mock.calls.length,
|
||||
1,
|
||||
"pauseAuto should be called when pre-execution checks fail",
|
||||
);
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ describe("Pre-execution checks → pauseAuto wiring", () => {
|
|||
|
||||
// Verify pauseAuto was called
|
||||
assert.equal(
|
||||
pauseAutoMock.mock.callCount,
|
||||
pauseAutoMock.mock.calls.length,
|
||||
1,
|
||||
"pauseAuto should be called exactly once when pre-execution checks fail with blocking issues",
|
||||
);
|
||||
|
|
@ -360,7 +360,7 @@ describe("Pre-execution checks → pauseAuto wiring", () => {
|
|||
|
||||
// Verify pauseAuto was called (strict mode promotes warnings to blocking)
|
||||
assert.equal(
|
||||
pauseAutoMock.mock.callCount,
|
||||
pauseAutoMock.mock.calls.length,
|
||||
1,
|
||||
"pauseAuto should be called when strict mode is enabled and pre-execution returns warn",
|
||||
);
|
||||
|
|
@ -410,7 +410,7 @@ describe("Pre-execution checks → pauseAuto wiring", () => {
|
|||
|
||||
// Verify pauseAuto was NOT called (warnings don't block in non-strict mode)
|
||||
assert.equal(
|
||||
pauseAutoMock.mock.callCount,
|
||||
pauseAutoMock.mock.calls.length,
|
||||
0,
|
||||
"pauseAuto should NOT be called when strict mode is disabled and only warnings exist",
|
||||
);
|
||||
|
|
@ -442,7 +442,7 @@ describe("Pre-execution checks → pauseAuto wiring", () => {
|
|||
|
||||
// Verify pauseAuto was NOT called (pre-execution checks only run for plan-slice)
|
||||
assert.equal(
|
||||
pauseAutoMock.mock.callCount,
|
||||
pauseAutoMock.mock.calls.length,
|
||||
0,
|
||||
"pauseAuto should NOT be called for non-plan-slice unit types",
|
||||
);
|
||||
|
|
@ -477,7 +477,7 @@ describe("Pre-execution checks → pauseAuto wiring", () => {
|
|||
|
||||
// Verify pauseAuto was NOT called (pre-execution checks disabled)
|
||||
assert.equal(
|
||||
pauseAutoMock.mock.callCount,
|
||||
pauseAutoMock.mock.calls.length,
|
||||
0,
|
||||
"pauseAuto should NOT be called when enhanced_verification_pre is disabled",
|
||||
);
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ describe("validate-milestone stuck-loop guard (#4094)", () => {
|
|||
);
|
||||
|
||||
assert.equal(result, "pause");
|
||||
assert.equal(pauseAutoMock.mock.callCount, 1);
|
||||
assert.equal(ctx.ui.notify.mock.callCount, 1);
|
||||
assert.equal(pauseAutoMock.mock.calls.length, 1);
|
||||
assert.equal(ctx.ui.notify.mock.calls.length, 1);
|
||||
const notifyArgs = ctx.ui.notify.mock.calls[0];
|
||||
assert.match(notifyArgs[0], /needs-remediation/);
|
||||
assert.equal(notifyArgs[1], "error");
|
||||
|
|
@ -173,7 +173,7 @@ describe("validate-milestone stuck-loop guard (#4094)", () => {
|
|||
);
|
||||
|
||||
assert.equal(result, "pause");
|
||||
assert.equal(pauseAutoMock.mock.callCount, 1);
|
||||
assert.equal(pauseAutoMock.mock.calls.length, 1);
|
||||
});
|
||||
|
||||
test("continues when verdict=needs-remediation but a queued remediation slice exists", async () => {
|
||||
|
|
@ -203,7 +203,7 @@ describe("validate-milestone stuck-loop guard (#4094)", () => {
|
|||
);
|
||||
|
||||
assert.equal(result, "continue");
|
||||
assert.equal(pauseAutoMock.mock.callCount, 0);
|
||||
assert.equal(pauseAutoMock.mock.calls.length, 0);
|
||||
});
|
||||
|
||||
test("continues when verdict is pass", async () => {
|
||||
|
|
@ -227,7 +227,7 @@ describe("validate-milestone stuck-loop guard (#4094)", () => {
|
|||
);
|
||||
|
||||
assert.equal(result, "continue");
|
||||
assert.equal(pauseAutoMock.mock.callCount, 0);
|
||||
assert.equal(pauseAutoMock.mock.calls.length, 0);
|
||||
});
|
||||
|
||||
test("continues when no VALIDATION file exists yet", async () => {
|
||||
|
|
@ -250,6 +250,6 @@ describe("validate-milestone stuck-loop guard (#4094)", () => {
|
|||
);
|
||||
|
||||
assert.equal(result, "continue");
|
||||
assert.equal(pauseAutoMock.mock.callCount, 0);
|
||||
assert.equal(pauseAutoMock.mock.calls.length, 0);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue