test(orchestration): distinguish the heartbeat straggler guard from the row's initial null

The straggler case never gave the row a heartbeat before settling it, so
last_heartbeat_at was null from creation and the expected value equalled
the initial state. That did catch outright removal of recordHeartbeat's
`AND status = 'dispatched'` filter, but it conflated "guard held" with
"completeDispatch cleared the column" and with "recordHeartbeat is inert" —
both of those regressions kept toBeNull() green.

Seed a heartbeat while the row is still dispatched so the expectation is a
timestamp: null now means the column was cleared, '2026-05-04...' means the
guard is gone.

Carried from #15165.
This commit is contained in:
Tauri-EPO
2026-08-21 23:02:15 -07:00
committed by Neil
parent 2b1254d681
commit 3a9ddd1068
+3 -1
View File
@@ -658,11 +658,13 @@ describe('OrchestrationDb', () => {
const d = createDb()
const task = d.createTask({ spec: 'work' })
const ctx = d.createDispatchContext(task.id, 'term_a')
// Why: seed first so the expectation isn't the row's initial null — a completion that cleared the column would satisfy that too.
d.recordHeartbeat(ctx.id, '2026-05-03T00:00:00.000Z')
d.completeDispatch(ctx.id)
d.recordHeartbeat(ctx.id, '2026-05-04T00:00:00.000Z')
const after = d.getDispatchContext(task.id)
expect(after?.last_heartbeat_at).toBeNull()
expect(after?.last_heartbeat_at).toBe('2026-05-03T00:00:00.000Z')
})
it('getStaleDispatches returns only dispatched rows past the grace window', () => {