Files
silo-server/web/src/lib/queryInvalidation.test.ts
T
6b1554a86c Fix scoped catalog refresh invalidation (#51)
* Fix scoped catalog refresh invalidation

* Remove duplicate catalog refetch

* fix(web): keep library lists fresh on scoped catalog events

---------

Co-authored-by: RXWatcher <14085001+RXWatcher@users.noreply.github.com>
Co-authored-by: Quick <31828688+Quick104@users.noreply.github.com>
2026-06-07 18:15:34 -04:00

28 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
activeCatalogQueryMatchesLibrary,
activeSectionQueryMatchesLibrary,
} from "./queryInvalidation";
describe("activeCatalogQueryMatchesLibrary", () => {
it("does not match a catalog list query for a different library event", () => {
expect(activeCatalogQueryMatchesLibrary(["catalog", "list", { library_id: 1 }], 3)).toBe(false);
});
it("matches unscoped and same-library catalog queries", () => {
expect(activeCatalogQueryMatchesLibrary(["catalog", "list", { library_id: 3 }], 3)).toBe(true);
expect(activeCatalogQueryMatchesLibrary(["catalog", "list", {}], 3)).toBe(true);
});
});
describe("activeSectionQueryMatchesLibrary", () => {
it("does not match a library section query for a different library event", () => {
expect(activeSectionQueryMatchesLibrary(["sections", "library", 1, "items"], 3)).toBe(false);
});
it("matches non-library and same-library section queries", () => {
expect(activeSectionQueryMatchesLibrary(["sections", "home", "items"], 3)).toBe(true);
expect(activeSectionQueryMatchesLibrary(["sections", "library", 3, "layout"], 3)).toBe(true);
});
});