A related video played in place is the player's item now: its title and its own watched / playlist / download controls, its progress checkpointed and resumed, marked watched at its end — and its end does not step the queue. Back returns to the opened video, where it was left. The related list: - its marks announce through the shared notice (the Notification Center finds them), join the host's player session (the feed refetches on close), and stay per write, so an earlier answer no longer undoes a later mark still on its way; - every host's state write patches the cached related lists, which are never refetched; - kept for the session (gcTime), a retry asks for the page that failed, a list read so far with nothing unseen says so, a refusal a retry cannot answer offers none, and the followed mark names itself on hover. Turned off on the instance (a limit of 0), the tab, the drawer button and the live-search buttons are left out. Keys: the player's keys and its focus reclaim defer to a layer above it (the drawer); going wide moves the drawer's list into the panel's tab; `j` goes on from the slot of a row removed inside the top layer; the help sheet lists the list keys over a layer that holds a list.
85 lines
2.8 KiB
TypeScript
85 lines
2.8 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";
|
|
import type { Me } from "../../lib/api";
|
|
|
|
vi.mock("react-i18next", async (importOriginal) => ({
|
|
...(await importOriginal<typeof import("react-i18next")>()),
|
|
useTranslation: () => ({ t: (k: string) => k, i18n: { language: "en" } }),
|
|
}));
|
|
let me = {} as Me;
|
|
vi.mock("../../lib/useMe", () => ({ useMe: () => me }));
|
|
vi.mock("../../features/navigation/navigationContext", () => ({
|
|
useNavigationActions: () => ({ enterYtSearch: vi.fn() }),
|
|
}));
|
|
vi.mock("./feedFiltersContext", () => ({
|
|
useFeedFilters: () => ({ q: "cats", sort: "newest" }),
|
|
useFeedFiltersActions: () => ({ setFilters: vi.fn() }),
|
|
}));
|
|
vi.mock("../channels", () => ({
|
|
useChannelsActions: () => ({ goToFullHistory: vi.fn() }),
|
|
SyncStatus: () => null,
|
|
}));
|
|
vi.mock("./FeedScopeToggle", () => ({ default: () => null }));
|
|
vi.mock("../../components/ui/PageScroller", () => ({
|
|
default: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
|
}));
|
|
|
|
import FeedHeader from "./FeedHeader";
|
|
import PageShell from "../../components/ui/PageShell";
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
function tipFor(source: Me["search_source"]): string | null {
|
|
vi.stubGlobal(
|
|
"ResizeObserver",
|
|
class {
|
|
observe() {}
|
|
disconnect() {}
|
|
},
|
|
);
|
|
me = { search_source: source, search_enabled: true, role: "user" } as Me;
|
|
render(
|
|
<PageShell header={<div />}>
|
|
<FeedHeader />
|
|
</PageShell>,
|
|
);
|
|
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");
|
|
});
|
|
});
|
|
|
|
describe("the live-search button", () => {
|
|
it("is left out when the instance turned live search off", () => {
|
|
vi.stubGlobal(
|
|
"ResizeObserver",
|
|
class {
|
|
observe() {}
|
|
disconnect() {}
|
|
},
|
|
);
|
|
me = { search_source: "scrape", search_enabled: false, role: "user" } as Me;
|
|
render(
|
|
<PageShell header={<div />}>
|
|
<FeedHeader />
|
|
</PageShell>,
|
|
);
|
|
expect(screen.queryByRole("button", { name: /header\.searchYoutube$/ })).toBeNull();
|
|
});
|
|
});
|