From 414bf0232b36f13d6e0ca9ff3c0977dcfc7788d5 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 24 Oct 2026 18:33:50 -0700 Subject: [PATCH] test(file-watch): wait for the coalesced refresh instead of a 250ms clock in the noise case (#33329) --- src/main/ipc/rebinding-file-watch-noise.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/ipc/rebinding-file-watch-noise.test.ts b/src/main/ipc/rebinding-file-watch-noise.test.ts index 467107571c4..7e278ceb720 100644 --- a/src/main/ipc/rebinding-file-watch-noise.test.ts +++ b/src/main/ipc/rebinding-file-watch-noise.test.ts @@ -71,16 +71,20 @@ describe('watchFileAcrossReplacement event filtering', () => { }) await settle() + const watchesBeforeNoise = nativeEvents.length for (let read = 0; read < 50; read++) { nativeEvents.at(-1)?.() } - await settle() + // The rebind is the coalesced refresh having stat'ed the file, so the absence below is read after it. + await vi.waitFor(() => expect(nativeEvents.length).toBeGreaterThan(watchesBeforeNoise)) expect(onChange).not.toHaveBeenCalled() writeFileSync(path, 'refs and more') for (let read = 0; read < 50; read++) { nativeEvents.at(-1)?.() } + // Noise backed the coalesce window off, so the write lands on its own schedule rather than a clock's. + await vi.waitFor(() => expect(onChange).toHaveBeenCalled(), { timeout: 5_000 }) await settle() expect(onChange).toHaveBeenCalledOnce() })