Skip to content

Commit bb7f54c

Browse files
test(web): make the favicon picker offscreen-preview test deterministic
expectPreview waited for the image's naturalWidth and then asserted the fallback icon was gone, but decoding sets naturalWidth before the load event reaches React's onLoad. Poll for both conditions together. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent ce2815d commit bb7f54c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎apps/web/src/components/settings/ProjectFaviconPickerDialog.browser.test.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,14 @@ async function publishUrl(path: string, url: string) {
166166
});
167167
}
168168

169+
// Decoding sets naturalWidth before the load event reaches React, so wait for both together.
169170
async function expectPreview(row: HTMLElement) {
170-
await expect.poll(() => row.querySelector("img")?.naturalWidth).toBe(8);
171-
expect(row.querySelector("svg")).toBeNull();
171+
await expect
172+
.poll(() => ({
173+
width: row.querySelector("img")?.naturalWidth,
174+
fallback: row.querySelector("svg") !== null,
175+
}))
176+
.toEqual({ width: 8, fallback: false });
172177
}
173178

174179
it("loads previews asynchronously and only acquires offscreen images after scrolling", async () => {

0 commit comments

Comments
 (0)