Files
siftlode/frontend/src/components/ui/useItemTriggers.dom.test.ts
T
peter 29875b7367 fix(ui): stable shelf-card menu triggers, a named Button by type, true layout comments
- Home's rail handed each card a fresh `() => menu.triggerProps(c)` per
  render, defeating memo(VideoCard) on every tile whenever the menu's own
  state changed. `useItemTriggers` (ui/useContextMenu) keeps one trigger per
  item, index-aligned; tested for identity across renders.
- The Button accessible-name union had one hole: `<Button icon={…} />` with
  no children and no size typechecked into a nameless button. A textful
  button now needs children or a name; pinned with @ts-expect-error.
- comfortPin's header said the pin belongs "on every card and row", which
  the code never meant (an episode, a season, a person are not pin kinds).
  It now says what is pinnable — and the show page's Related strip, whose
  shows ARE pinnable, gets the pin menu it was missing (and a rem width).
- gridColumns / feedView / VirtualGrid claimed layouts 1024–2560 are
  "byte-identical" under the column cap; the small cards are capped at 2560
  with the filter rail collapsed. The comments say so.
2026-09-19 07:40:48 +02:00

19 lines
745 B
TypeScript

// @vitest-environment jsdom
import { describe, expect, it, vi } from "vitest";
import { renderHook } from "@testing-library/react";
import { useItemTriggers } from "./useContextMenu";
describe("useItemTriggers", () => {
it("hands each item the same trigger across renders, so a memo card is not re-rendered", () => {
const items = [{ id: 1 }, { id: 2 }];
const triggerProps = vi.fn((it: { id: number }) => ({ "data-id": it.id }));
const { result, rerender } = renderHook(() => useItemTriggers(items, triggerProps));
const first = result.current;
rerender();
expect(result.current[0]).toBe(first[0]);
expect(result.current[1]).toBe(first[1]);
expect(result.current[1]!()).toEqual({ "data-id": 2 });
});
});