test: wait on the gap marker rather than a depth that never moves

The refused-delivery test waited for `depth(subId)` to reach 1 before
claiming the marker, but `discard` removes the entry and appends the
marker in its place, so the depth is 1 before, during and after. The
wait returned at once, and the claim came back `inflight` — the refused
delivery still held the lease it was invoked on — leaving the assertion
reading `undefined`. It only passed on the slack in `invoked`'s poll
interval, which a loaded runner takes away.

Waiting on the claim itself is the barrier the depth was standing in
for. Dropping `answer = 200` with it: `beforeEach` already resets it,
and a redelivery settling before the last assertion would clear the
failure count it reads.
This commit is contained in:
Juan Castro committed 2026-09-30 16:36:57 -04:00
1 parent 2e0bf26cac
commit 79e496e79d
1 file changed
+8 -7
@@ -556,15 +556,16 @@ describe('what each answer does to the delivery', () => {
// The event is gone and a marker stands in its place, so the
// subscription learns there was one rather than reading silence.
// Waited on by claiming it: depth is 1 across the swap either way.
await waitUntil(async () =>
expect(await pending().depth(subId)).toBe(1),
expect(
(await pending().claim(subId, { leaseMs: 0 }))?.event,
).toMatchObject({
op: 'gap',
reason: 'handler_rejected',
}),
);
answer = 200;
const claimed = await pending().claim(subId, { leaseMs: 0 });
expect(claimed?.event).toMatchObject({
op: 'gap',
reason: 'handler_rejected',
});
expect(await pending().depth(subId)).toBe(1);
// It counted: a refusal is still a handler that did not work.
await expect(
env.server.clients.redis.get(`ev:qf:{${subId}}`),