The demo account — one shared user that whitelisted emails entered from the login page, reset on a schedule — goes end to end (owner decision, E34): demo.py and the reset job, users.is_demo and demo_whitelist (migration 0098 deletes the demo user, its audit rows, the reset job's override and notices, then drops the column and table; the downgrade restores the empty schema), the /auth/demo entry, the admin whitelist and reset, the Demo tab, the banner, the login page's "Try the demo", and every is_demo branch in routes, userscope, scheduler and the UI. require_human only ever refused the demo account, so its 87 uses become current_user (owner-approved); require_write_scope keeps its own check. The login page's "or" divider now shows only beside the Google button: without the demo entry under it, an instance without Google would have said "or" to nothing. A contract test (removedFeatures) fails on the word anywhere in the backend, frontend, e2e or scripts — seen red on a planted hit. Size ceilings tightened for the modules that shrank; admin.py is back under the limit.
78 lines
2.8 KiB
TypeScript
78 lines
2.8 KiB
TypeScript
// @vitest-environment jsdom
|
|
//
|
|
// Ctrl/Cmd+K had no visible entry point (debt burn B28). The owner's pick: a key cap in the header's
|
|
// search field, and a "Jump to…" pill in its place on a page that has no search field.
|
|
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
import { render, screen, fireEvent, cleanup, act } from "@testing-library/react";
|
|
|
|
vi.mock("react-i18next", async (importOriginal) => ({
|
|
...(await importOriginal<typeof import("react-i18next")>()),
|
|
useTranslation: () => ({ t: (k: string) => k, i18n: { language: "en" } }),
|
|
}));
|
|
|
|
let page = "home";
|
|
vi.mock("./navigationContext", () => ({ useNavigation: () => ({ page }) }));
|
|
vi.mock("./feedFiltersContext", () => ({
|
|
useFeedFilters: () => ({ q: "", sort: "newest" }),
|
|
useFeedFiltersActions: () => ({ setFilters: vi.fn() }),
|
|
}));
|
|
vi.mock("./playlistsContext", () => ({
|
|
usePlaylists: () => ({ search: "" }),
|
|
usePlaylistsActions: () => ({ setSearch: vi.fn() }),
|
|
}));
|
|
vi.mock("./channelsContext", () => ({
|
|
useChannels: () => ({ search: "" }),
|
|
useChannelsActions: () => ({ setSearch: vi.fn(), goToFullHistory: vi.fn() }),
|
|
}));
|
|
vi.mock("./SyncStatus", () => ({ default: () => null }));
|
|
|
|
import Header from "./Header";
|
|
import { closePalette, usePaletteOpen } from "../lib/keymap";
|
|
import type { Me } from "../lib/api";
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
act(() => closePalette());
|
|
});
|
|
|
|
function mount() {
|
|
let open = false;
|
|
function Probe() {
|
|
open = usePaletteOpen();
|
|
return null;
|
|
}
|
|
render(
|
|
<>
|
|
<Header me={{ plex_enabled: false } as Me} onYtSearch={() => {}} />
|
|
<Probe />
|
|
</>,
|
|
);
|
|
return () => open;
|
|
}
|
|
|
|
describe("the command palette's visible entry", () => {
|
|
it("is a key cap inside the search field, naming the chord the palette row binds", () => {
|
|
page = "feed";
|
|
const isOpen = mount();
|
|
const cap = screen.getByRole("button", { name: /^palette\.open \((Ctrl|⌘) K\)$/ });
|
|
// Label in Name: the name carries what the cap shows, so "click Ctrl K" finds it.
|
|
expect(cap.getAttribute("aria-label")).toContain(cap.textContent);
|
|
// …and a tooltip equal to that name, so a screen reader does not read it again as a description.
|
|
expect(cap.getAttribute("title")).toBe(cap.getAttribute("aria-label"));
|
|
expect(screen.getByRole("textbox")).toBeTruthy();
|
|
fireEvent.click(cap);
|
|
expect(isOpen()).toBe(true);
|
|
});
|
|
|
|
it("is a Jump-to pill on a page with no search field", () => {
|
|
page = "home";
|
|
const isOpen = mount();
|
|
expect(screen.queryByRole("textbox")).toBeNull();
|
|
// Named by what it shows ("Jump to…" and its key cap), not by a label that replaced it.
|
|
const pill = screen.getByRole("button", { name: /^palette\.title ?(Ctrl|⌘) K$/ });
|
|
expect(pill.getAttribute("title")).toBe("palette.open");
|
|
fireEvent.click(pill);
|
|
expect(isOpen()).toBe(true);
|
|
});
|
|
});
|