Full-epic /deep-review (11 finders + 12 adversarial verifiers) surfaced no HIGH; every mechanism finding calibrated to LOW on verification. Fix all 13: Correctness / reliability: - Combobox: Enter now commits the VISUALLY highlighted row (highlightIndex ?? activeIndex), not the bare keyboard activeIndex — so arrow-then-hover-then-Enter no longer toggles a different option than the one painted, and hover-with-no-arrow is no longer a silent no-op. - parse_person: dedup the known_for pool by (id, media_type), not the bare id — TMDB movie and tv id spaces are independent, so a same-id movie+show pair is two distinct credits (matches the collision-safe key the rest of the module already uses). - person-enrich: a per-person in-flight + 60s cooldown guard (people._should_schedule_enrich) dedups concurrent opens and rate-limits re-triggering while TMDB is degraded (a transient TmdbError leaves the watermark NULL), so bursts can't pile 8s tasks onto the shared threadpool. - PlexInfo compact()/money(): format with i18n.language (keeping currency USD) instead of a hardcoded en/en-US, matching the app's Intl convention. - delete the dead `plex.filter.add` i18n key (both locales) — the +Add button that used it is gone. Reuse: - _continue_watching reuses rollup.agg_subquery(include_resumed=True) + query.apply_show_state_filter instead of a third hand-inlined copy of the per-show rollup + in_progress predicate, so the Discover rail can't drift from the grid's definition. Test coverage (the gaps a regression would ship through): - resolve_library_guids scope-exclusion (a credit in a non-scoped/disabled library is dropped) + the []-vs-None distinction; parse_person cross-media-id retention; enrich_person transient (NULL watermark) and 404 (stamp) branches; _enrich_person_bg body (fresh session close/rollback, None-guard) + the cooldown dedup; continue_watching fully-watched-show exclusion; Combobox Enter-commits-highlighted + async/controlled-query mode; PopoverItem aria-checked contract; RatingsRow missing-IMDb + imdb==audience branches. Backend lane 413→420, FE vitest 351→357; all gates green. No migration.
61 lines
2.3 KiB
TypeScript
61 lines
2.3 KiB
TypeScript
// @vitest-environment jsdom
|
|
//
|
|
// Gates the shared PopoverItem ARIA contract: aria-checked for menuitemradio/menuitemcheckbox and
|
|
// aria-selected for option are rendered as explicit attributes AFTER the floating-ui item props (so they
|
|
// win over getItemProps' single-select guess). Six live menus (LanguageSwitcher, ViewSwitcher,
|
|
// AddToPlaylist, ChannelTags, tableHeader, plexDetailUi) depend on this; without a test, a regression in
|
|
// the shared path would silently drop the checked indicator for screen-reader users. Floating-ui recipe:
|
|
// stub the two observers autoUpdate wires, wrap in a FloatingTree, query the hidden surface.
|
|
import { describe, it, expect, beforeAll, afterEach } from "vitest";
|
|
import { useState } from "react";
|
|
import { render, screen, cleanup } from "@testing-library/react";
|
|
import { FloatingTree } from "@floating-ui/react";
|
|
import { useAnchoredPopover, PopoverSurface, PopoverItem } from "./AnchoredPopover";
|
|
|
|
beforeAll(() => {
|
|
class Stub {
|
|
observe() {}
|
|
unobserve() {}
|
|
disconnect() {}
|
|
takeRecords() {
|
|
return [];
|
|
}
|
|
}
|
|
globalThis.ResizeObserver ??= Stub as unknown as typeof ResizeObserver;
|
|
globalThis.IntersectionObserver ??= Stub as unknown as typeof IntersectionObserver;
|
|
});
|
|
|
|
afterEach(cleanup);
|
|
|
|
function Menu() {
|
|
const [open, setOpen] = useState(true);
|
|
const pop = useAnchoredPopover({ open, onOpenChange: setOpen, mode: "menu" });
|
|
return (
|
|
<PopoverSurface popover={pop} ariaLabel="Choices">
|
|
<PopoverItem role="menuitemradio" checked onSelect={() => {}}>
|
|
Newest
|
|
</PopoverItem>
|
|
<PopoverItem role="menuitemradio" checked={false} onSelect={() => {}}>
|
|
Oldest
|
|
</PopoverItem>
|
|
<PopoverItem role="menuitemcheckbox" checked onSelect={() => {}}>
|
|
Show shorts
|
|
</PopoverItem>
|
|
</PopoverSurface>
|
|
);
|
|
}
|
|
|
|
describe("PopoverItem ARIA contract", () => {
|
|
it("exposes aria-checked on menuitemradio and menuitemcheckbox items", () => {
|
|
render(
|
|
<FloatingTree>
|
|
<Menu />
|
|
</FloatingTree>,
|
|
);
|
|
const radios = screen.getAllByRole("menuitemradio", { hidden: true });
|
|
expect(radios.map((r) => r.getAttribute("aria-checked"))).toEqual(["true", "false"]);
|
|
const checkbox = screen.getByRole("menuitemcheckbox", { hidden: true });
|
|
expect(checkbox.getAttribute("aria-checked")).toBe("true");
|
|
});
|
|
});
|