/** * Tests for the "server only" card rule shared by the grid and the list view. * * TRACES: UR-052 | DR-292 | UT-257 */ import { describe, it, expect } from "vitest"; import { isServerOnly, type ServerOnlyInput } from "./serverOnly"; const offlineReveal: ServerOnlyInput = { isMediaItem: true, isConnected: false, revealServerCatalog: true, isDownloaded: false, isActivelyDownloading: false, hasDeviceContent: false, }; describe("isServerOnly", () => { it("is true only offline, with the reveal on, for an item with nothing on the device", () => { expect(isServerOnly(offlineReveal)).toBe(true); expect(isServerOnly({ ...offlineReveal, isConnected: true })).toBe(false); expect(isServerOnly({ ...offlineReveal, revealServerCatalog: false })).toBe(false); }); it("never greys a library tile: there is nothing to queue", () => { expect(isServerOnly({ ...offlineReveal, isMediaItem: false })).toBe(false); }); it("does not grey the item's own completed or in-flight download", () => { expect(isServerOnly({ ...offlineReveal, isDownloaded: true })).toBe(false); expect(isServerOnly({ ...offlineReveal, isActivelyDownloading: true })).toBe(false); }); it("does not grey a container whose children are on the device", () => { // The regression: an album has no download row of its own — its *tracks* // do — so a fully downloaded album greyed itself out and offered to queue // what was already there. expect(isServerOnly({ ...offlineReveal, hasDeviceContent: true })).toBe(false); }); it("still greys a container with nothing downloaded under it", () => { expect(isServerOnly({ ...offlineReveal, hasDeviceContent: false })).toBe(true); }); });