// @vitest-environment jsdom // // A shared Plex link is persisted to the account, but only the dimensions it CARRIES. The bug it // replaced: a link with only a scope also wrote the (empty) default filters, and a stored Plex filters // value at all is what tells SavedViewsProvider the account has picked filters — so the account's // default saved view was never applied again. import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { render, cleanup } from "@testing-library/react"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { NavigationProvider } from "./NavigationProvider"; import { PlexProvider } from "./PlexProvider"; import { ACTIVE_ACCOUNT_KEY } from "../lib/activeAccount"; function mount() { render(
, ); } beforeEach(() => { localStorage.clear(); sessionStorage.setItem(ACTIVE_ACCOUNT_KEY, "5"); }); afterEach(() => { cleanup(); window.history.replaceState(null, "", "/"); }); describe("PlexProvider shared link", () => { it("persists the scope a link carries and leaves the dimensions it omits unwritten", () => { window.history.replaceState(null, "", "/?page=plex&pscope=movie"); mount(); expect(localStorage.getItem("siftlode.plexLibrary.5")).toBe("movie"); expect(localStorage.getItem("siftlode.plexFilters.5")).toBeNull(); expect(localStorage.getItem("siftlode.plexSort.5")).toBeNull(); expect(localStorage.getItem("siftlode.plexShow.5")).toBeNull(); }); });