- Person page: a bio ask that fails says so with a retry instead of reading as 'no biography'. - Show page: the summary is a ClampedText (5 lines + More), like the person and collection pages; one More/Less pair (plex.textMore/textLess) for all three. - Channels: a re-slotted row is placed in the language the server orders by (the stored preference, else English), not the UI's guess. - A skipped run's body is only the reason (its title already says skipped). - HU: Behúzási kvótatartalék; Eseménynapló ürítve / az eseménynaplót; indok; közvetlenül játszható / közvetlen közvetítés in the Plex hints. - Tests: ClampedText re-measures on a resize, the show summary clamp, serverOrderLang.
49 lines
2.0 KiB
TypeScript
49 lines
2.0 KiB
TypeScript
// @vitest-environment jsdom
|
|
//
|
|
// E30 review: the server orders some lists by the reader's STORED language (their keys carry none), so a
|
|
// switch must re-ask for them — after the save lands, not before (the server would sort in the old one).
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { QueryClient } from "@tanstack/react-query";
|
|
import { api } from "./api";
|
|
import { LANGUAGE_ORDERED, qk } from "./queryKeys";
|
|
import { saveLanguage, serverOrderLang } from "./saveLanguage";
|
|
|
|
afterEach(() => vi.restoreAllMocks());
|
|
|
|
describe("saveLanguage", () => {
|
|
it("asks again for the server-ordered lists once the save has landed", async () => {
|
|
let land!: () => void;
|
|
vi.spyOn(api, "savePrefs").mockReturnValue(
|
|
new Promise<never>((r) => (land = r as () => void)) as never,
|
|
);
|
|
const qc = new QueryClient();
|
|
const asked = vi.spyOn(qc, "invalidateQueries");
|
|
const done = saveLanguage(qc, "hu");
|
|
await Promise.resolve();
|
|
expect(asked).not.toHaveBeenCalled(); // the server still sorts in the old language
|
|
land();
|
|
await done;
|
|
const keys = asked.mock.calls.map((c) => c[0]?.queryKey);
|
|
expect(keys).toEqual([...LANGUAGE_ORDERED]);
|
|
expect(keys).toContainEqual(qk.feed());
|
|
expect(keys).toContainEqual(qk.channels());
|
|
});
|
|
|
|
it("leaves the lists alone when the save fails", async () => {
|
|
vi.spyOn(api, "savePrefs").mockRejectedValue(new Error("offline"));
|
|
const qc = new QueryClient();
|
|
const asked = vi.spyOn(qc, "invalidateQueries");
|
|
await expect(saveLanguage(qc, "hu")).rejects.toThrow("offline");
|
|
expect(asked).not.toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe("serverOrderLang", () => {
|
|
it("is the stored language, else English — never the UI's guess", () => {
|
|
expect(serverOrderLang({ language: "hu" })).toBe("hu");
|
|
expect(serverOrderLang({})).toBe("en"); // nothing stored: the server sorts in English
|
|
expect(serverOrderLang({ language: "de" })).toBe("en");
|
|
expect(serverOrderLang(undefined)).toBe("en");
|
|
});
|
|
});
|