mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
test(orchestration): fail loudly on an unexpected second detection call
The mock overwrote resolveDetection on every call, so a second invocation would strand the first promise and hang to a 30s timeout instead of naming what changed. A test that hangs rather than fails is how a real bug gets mistaken for infrastructure noise.
This commit is contained in:
@@ -656,9 +656,21 @@ describe('legacy coordinator takeover races', () => {
|
||||
const detectionStarted = new Promise<void>((resolve) => {
|
||||
signalDetectionStarted = resolve
|
||||
})
|
||||
let detectionCalls = 0
|
||||
vi.spyOn(harness.runtime, 'isTerminalRunningAgent').mockImplementation(
|
||||
() =>
|
||||
new Promise<boolean>((resolve) => {
|
||||
new Promise<boolean>((resolve, reject) => {
|
||||
detectionCalls += 1
|
||||
// Why reject instead of re-arming: a second call would overwrite resolveDetection and
|
||||
// strand the first promise, hanging to a timeout instead of naming what changed.
|
||||
if (detectionCalls > 1) {
|
||||
reject(
|
||||
new Error(
|
||||
`isTerminalRunningAgent was called ${detectionCalls} times; this test drives exactly one detection.`
|
||||
)
|
||||
)
|
||||
return
|
||||
}
|
||||
resolveDetection = resolve
|
||||
signalDetectionStarted?.()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user