test: Avoid test flakiness by waiting for request count (#2740)

This commit is contained in:
Dermot Duffy
2026-08-30 16:39:39 -07:00
committed by GitHub
parent bb6794ac49
commit fe7ac89982
2 changed files with 55 additions and 3 deletions
@@ -19,6 +19,7 @@ import {
createUnansweredMediaURL,
getTestMediaRequestCount,
useTestMedia,
waitForTestMediaRequestCount,
} from '../../../browser/test-media';
import {
CAMERA_ENTITY,
@@ -446,7 +447,8 @@ describe('MediaUnavailableIssue', () => {
cameras: [createStillImageCameraConfig(CAMERA_ENTITY, mediaURL)],
});
await card.waitForSelector('img');
await waitForTestMediaRequestCount(mediaURL, 1);
await card.advanceSeconds(MEDIA_LOADING_TIMEOUT_SECONDS);
expect(isIssueReported(card)).toBe(true);
@@ -460,6 +462,8 @@ describe('MediaUnavailableIssue', () => {
// Past the grace period the attempt has had long enough, and the next retry
// replaces it.
await card.advanceSeconds(retrySeconds + 1);
await waitForTestMediaRequestCount(mediaURL, 2);
expect(getTestMediaRequestCount(mediaURL)).toBeGreaterThan(1);
});