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.
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
// @vitest-environment jsdom
|
|
//
|
|
// The live-search button's tooltip says what a search costs under the search source the instance
|
|
// actually runs. It used to say "uses shared API quota" always, while the default source (the
|
|
// website's own endpoint) spends none — so the owner avoided a free search for months.
|
|
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
import { render, screen, cleanup } from "@testing-library/react";
|
|
|
|
vi.mock("react-i18next", async (importOriginal) => ({
|
|
...(await importOriginal<typeof import("react-i18next")>()),
|
|
useTranslation: () => ({ t: (k: string) => k, i18n: { language: "en" } }),
|
|
}));
|
|
vi.mock("./navigationContext", () => ({ useNavigation: () => ({ page: "feed" }) }));
|
|
vi.mock("./feedFiltersContext", () => ({
|
|
useFeedFilters: () => ({ q: "cats", 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 type { Me } from "../lib/api";
|
|
|
|
afterEach(cleanup);
|
|
|
|
function tipFor(source: Me["search_source"]): string | null {
|
|
const me = { plex_enabled: false, search_source: source } as Me;
|
|
render(<Header me={me} onYtSearch={() => {}} />);
|
|
return screen.getByRole("button", { name: /header\.searchYoutube$/ }).getAttribute("title");
|
|
}
|
|
|
|
describe("the live-search tooltip", () => {
|
|
it("does not claim a quota cost under the free website source", () => {
|
|
expect(tipFor("scrape")).toBe("header.searchYoutubeTip");
|
|
});
|
|
|
|
it("names the quota cost when the instance searches through the official API", () => {
|
|
expect(tipFor("api")).toBe("header.searchYoutubeTipApi");
|
|
});
|
|
});
|