Skip to content

Commit 9892798

Browse files
test(server): mock cancelStaleQueuedRunsForIssue in route-level heartbeat mocks
The eager-cancel-on-reassignment call in routes/issues.ts (added by an earlier commit on this PR for RENA-55610) invokes heartbeat.cancelStaleQueuedRunsForIssue on every PATCH /api/issues/:id that changes assigneeAgentId. Route test files that hoist their own mockHeartbeatService double did not define that method, so any reassignment-path test threw "cancelStaleQueuedRunsForIssue is not a function" synchronously - before the route's own .catch() around that call could ever run - and the request failed with a 500. This surfaced as unrelated-looking failures across three "Verify serialized server suites" shards in CI (issue-agent-mutation-ownership-routes, issue-assignee-invokability-routes, issue-comment-reopen-routes), all "expected 500 to be 200" on PATCH reassignment paths. Add the missing mock (resolving to []) to every hoisted mockHeartbeatService in server/src/__tests__ that mounts routes/issues.ts, so reassignment tests exercise the real .catch()-guarded call path instead of throwing before it. Verified locally (serialized, extended timeouts to offset this box's resource contention): the three previously-failing files now pass 174/174. RENA-55706
1 parent 92a61f6 commit 9892798

14 files changed

Lines changed: 14 additions & 0 deletions

server/src/__tests__/document-annotation-routes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const mockIssueReferenceService = vi.hoisted(() => ({
3737
syncIssue: vi.fn(async () => undefined),
3838
}));
3939
const mockHeartbeatService = vi.hoisted(() => ({
40+
cancelStaleQueuedRunsForIssue: vi.fn(async () => []),
4041
wakeup: vi.fn(async () => undefined),
4142
reportRunActivity: vi.fn(async () => undefined),
4243
}));

server/src/__tests__/issue-activity-events-routes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const mockAccessService = vi.hoisted(() => ({
2222
hasPermission: vi.fn(async () => false),
2323
}));
2424
const mockHeartbeatService = vi.hoisted(() => ({
25+
cancelStaleQueuedRunsForIssue: vi.fn(async () => []),
2526
wakeup: vi.fn(async () => undefined),
2627
reportRunActivity: vi.fn(async () => undefined),
2728
getRun: vi.fn(async () => null),

server/src/__tests__/issue-agent-mutation-ownership-routes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const mockTaskWatchdogService = vi.hoisted(() => ({
101101
disableForIssue: vi.fn(async () => null),
102102
}));
103103
const mockHeartbeatService = vi.hoisted(() => ({
104+
cancelStaleQueuedRunsForIssue: vi.fn(async () => []),
104105
wakeup: vi.fn(async () => undefined),
105106
reportRunActivity: vi.fn(async () => undefined),
106107
getRun: vi.fn(async () => null),

server/src/__tests__/issue-assignee-invokability-routes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const mockIssueService = vi.hoisted(() => ({
3333
}));
3434

3535
const mockHeartbeatService = vi.hoisted(() => ({
36+
cancelStaleQueuedRunsForIssue: vi.fn(async () => []),
3637
wakeup: vi.fn(async () => undefined),
3738
reportRunActivity: vi.fn(async () => undefined),
3839
getRun: vi.fn(async () => null),

server/src/__tests__/issue-closed-workspace-routes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const mockAccessService = vi.hoisted(() => ({
2424
}));
2525

2626
const mockHeartbeatService = vi.hoisted(() => ({
27+
cancelStaleQueuedRunsForIssue: vi.fn(async () => []),
2728
wakeup: vi.fn(async () => undefined),
2829
reportRunActivity: vi.fn(async () => undefined),
2930
getRun: vi.fn(async () => null),

server/src/__tests__/issue-comment-cancel-routes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const mockAccessService = vi.hoisted(() => ({
1616
}));
1717

1818
const mockHeartbeatService = vi.hoisted(() => ({
19+
cancelStaleQueuedRunsForIssue: vi.fn(async () => []),
1920
getRun: vi.fn(async () => null),
2021
getActiveRunForAgent: vi.fn(async () => null),
2122
}));

server/src/__tests__/issue-comment-reopen-routes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const mockAccessService = vi.hoisted(() => ({
2222
}));
2323

2424
const mockHeartbeatService = vi.hoisted(() => ({
25+
cancelStaleQueuedRunsForIssue: vi.fn(async () => []),
2526
wakeup: vi.fn(async () => undefined),
2627
reportRunActivity: vi.fn(async () => undefined),
2728
getRun: vi.fn(async () => null),

server/src/__tests__/issue-document-restore-routes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const mockAgentService = vi.hoisted(() => ({
2727

2828
const mockLogActivity = vi.hoisted(() => vi.fn(async () => undefined));
2929
const mockHeartbeatService = vi.hoisted(() => ({
30+
cancelStaleQueuedRunsForIssue: vi.fn(async () => []),
3031
wakeup: vi.fn(async () => undefined),
3132
reportRunActivity: vi.fn(async () => undefined),
3233
}));

server/src/__tests__/issue-execution-policy-routes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const mockIssueService = vi.hoisted(() => ({
1717
}));
1818

1919
const mockHeartbeatService = vi.hoisted(() => ({
20+
cancelStaleQueuedRunsForIssue: vi.fn(async () => []),
2021
wakeup: vi.fn(async () => undefined),
2122
triggerIssueMonitor: vi.fn(async () => ({ outcome: "triggered" as const })),
2223
reportRunActivity: vi.fn(async () => undefined),

server/src/__tests__/issue-feedback-routes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const mockAgentService = vi.hoisted(() => ({
2929
getById: vi.fn(),
3030
}));
3131
const mockHeartbeatService = vi.hoisted(() => ({
32+
cancelStaleQueuedRunsForIssue: vi.fn(async () => []),
3233
wakeup: vi.fn(async () => undefined),
3334
reportRunActivity: vi.fn(async () => undefined),
3435
getRun: vi.fn(async () => null),

0 commit comments

Comments
 (0)