Skip to content

Commit ba79c23

Browse files
committed
test(webdriver): assert the typed timeout contract on the shared-budget probe
main's #1790 tightened this test to expect the raw TimeoutError DOMException, which this PR intentionally normalizes into AppError{reason: webdriver_request_timeout}. On the merge ref the two met and Coverage went red. The regression now asserts the structured contract and that the second request's budget is the shared remainder (~118ms of 200 after an 80ms first call).
1 parent c5595fa commit ba79c23

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

‎packages/provider-webdriver/src/webdriver-client.test.ts‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,19 @@ test('activeElement bounds its two sequential requests by one shared budget', as
317317
});
318318
});
319319

320-
// Not an AppError: this is the raw AbortSignal.timeout() rejection the transport
321-
// re-throws unwrapped once the combined signal is already aborted (see
322-
// shouldRetryWebDriverRequest in webdriver-transport.ts) — assert the timeout's
323-
// own reason instead of any failure.
324-
await assert.rejects(
325-
client.activeElement(budgetMs),
326-
(error: unknown) => error instanceof Error && error.name === 'TimeoutError',
327-
);
320+
// The transport's own deadline surfaces as the typed timeout (#1774), not a
321+
// raw AbortSignal.timeout() DOMException — assert that contract, and that the
322+
// budget the second request was handed is what the first call left over.
323+
await assert.rejects(client.activeElement(budgetMs), (error: unknown) => {
324+
assert.ok(error instanceof AppError);
325+
assert.equal(error.details?.reason, 'webdriver_request_timeout');
326+
assert.ok(
327+
typeof error.details?.timeoutMs === 'number' &&
328+
error.details.timeoutMs < budgetMs - firstCallMs / 2,
329+
`the rect request's budget must be the shared remainder, got ${String(error.details?.timeoutMs)}`,
330+
);
331+
return true;
332+
});
328333

329334
assert.ok(rectRequestBudgetMs !== undefined, 'the rect request should have been made');
330335
// It must get what the first call left (~120ms), never a fresh 200ms.

0 commit comments

Comments
 (0)