// @vitest-environment jsdom // // The Hidden / Blocked channel cards as a keyboard list (E11 S4c): `j`/`k` walk the cards, Enter opens // the channel — the ChannelLink name is the card's open element — and the card's own action button // keeps its Enter. import { afterEach, describe, expect, it, vi } from "vitest"; import { act, cleanup, render, screen } from "@testing-library/react"; vi.mock("react-i18next", async (importOriginal) => { const actual = await importOriginal(); return { ...actual, useTranslation: () => ({ t: (key: string) => key }) }; }); import ExcludedChannelList from "./ExcludedChannelList"; afterEach(cleanup); function press(key: string) { act(() => { (document.activeElement ?? document.body).dispatchEvent( new KeyboardEvent("keydown", { key, bubbles: true, cancelable: true }), ); }); } const channels = [ { id: "UCa", title: "Alpha", thumbnail_url: null }, { id: "UCb", title: "Beta", thumbnail_url: null }, ]; describe("ExcludedChannelList · keyboard", () => { it("walks the cards with j/k and opens the channel on Enter", () => { const onView = vi.fn(); render( {}} onView={onView} />, ); press("j"); press("j"); expect(document.activeElement?.textContent).toContain("Beta"); press("k"); expect(document.activeElement?.textContent).toContain("Alpha"); press("Enter"); expect(onView).toHaveBeenCalledWith(channels[0]); expect(screen.getAllByRole("button", { name: "Unhide" })).toHaveLength(2); }); });