Stop rereading provider snapshots while loading

This commit is contained in:
Mohamed Boudra
2026-05-26 11:35:20 +07:00
parent 6f16900b8a
commit bde0efc9b0
2 changed files with 9 additions and 19 deletions
@@ -226,23 +226,21 @@ describe("providers snapshot hook cache scope", () => {
await waitForSnapshotEntries(result, [codexEntry("ready", [readyCodexModel])]);
});
it("refetches loading snapshot updates through the read path but ignores empty updates", async () => {
it("applies loading snapshot updates without refetching through the read path", async () => {
enableProvidersSnapshot();
mockClient.getProvidersSnapshot
.mockResolvedValueOnce(providersSnapshot([codexEntry("ready", [])]))
.mockResolvedValueOnce(providersSnapshot([codexEntry("ready", [readyCodexModel])]));
mockClient.getProvidersSnapshot.mockResolvedValueOnce(
providersSnapshot([codexEntry("ready", [])]),
);
renderProvidersSnapshotHook();
const { result } = renderProvidersSnapshotHook();
await waitForSnapshotReads(1);
await emitProvidersSnapshotUpdate([]);
const loadingEntries = [codexEntry("loading")];
await emitProvidersSnapshotUpdate(loadingEntries);
await waitForSnapshotEntries(result, loadingEntries);
expect(mockClient.getProvidersSnapshot).toHaveBeenCalledTimes(1);
await emitProvidersSnapshotUpdate([codexEntry("loading")]);
await waitForSnapshotReads(2);
expect(mockClient.getProvidersSnapshot).toHaveBeenLastCalledWith({});
expect(mockClient.refreshProvidersSnapshot).not.toHaveBeenCalled();
});