From c5c66355e1e879fde6e20558c73d73b6cc135bf1 Mon Sep 17 00:00:00 2001 From: baron unread Date: Fri, 17 Jul 2026 15:09:08 +0200 Subject: [PATCH] test: stop rebuilding folderInfo() across clock ticks in listingCache tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The helper stamps lastModified with Date.now(), so comparing a cached object against a second, freshly built folderInfo(n) only passes while both calls land in the same millisecond. On a loaded CI runner the tick in between is likely — PR #22's check hit exactly this on the invalidateConnection test. Both comparison sites now build the object once and assert against that same reference. Co-Authored-By: Claude Fable 5 --- tests/unit/ui/listingCache.test.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/unit/ui/listingCache.test.ts b/tests/unit/ui/listingCache.test.ts index 59eb06a..af282bb 100644 --- a/tests/unit/ui/listingCache.test.ts +++ b/tests/unit/ui/listingCache.test.ts @@ -102,9 +102,12 @@ describe("listingCache", () => { const first = fetchFolderInfo("conn-b", "photos/", fetcher); const second = fetchFolderInfo("conn-b", "photos/", fetcher); - release(folderInfo(5)); - expect(await first).toEqual(folderInfo(5)); - expect(await second).toEqual(folderInfo(5)); + // One shared object: folderInfo() stamps lastModified with Date.now(), + // so building it twice flakes whenever the ms clock ticks in between. + const released = folderInfo(5); + release(released); + expect(await first).toEqual(released); + expect(await second).toEqual(released); expect(calls).toBe(1); }); @@ -184,7 +187,10 @@ describe("listingCache", () => { putListing("conn-a", "photos/", [FILE_B]); await fetchFolderInfo("conn-a", "photos/", async () => folderInfo(1)); putListing("conn-b", "", [FILE_B]); - await fetchFolderInfo("conn-b", "photos/", async () => folderInfo(9)); + // Kept in a const for the same clock-tick reason as the inflight-dedupe + // test above — this exact flake hit CI on a loaded runner (PR #22). + const infoB = folderInfo(9); + await fetchFolderInfo("conn-b", "photos/", async () => infoB); invalidateConnection("conn-a"); @@ -193,7 +199,7 @@ describe("listingCache", () => { expect(peekFolderInfo("conn-a", "photos/")).toBeUndefined(); expect(peekListing("conn-b", "")).toEqual([FILE_B]); - expect(peekFolderInfo("conn-b", "photos/")).toEqual(folderInfo(9)); + expect(peekFolderInfo("conn-b", "photos/")).toEqual(infoB); }); }); });