test: hold the show collection's type, an unknown title's 404 and Brave's fullscreen stand-in

This commit is contained in:
2026-10-08 21:18:48 +02:00
parent 48bd038c5f
commit 24ad17fc7d
4 changed files with 23 additions and 2 deletions
+4
View File
@@ -159,6 +159,10 @@ def test_a_collection_is_created_with_a_well_formed_uri(plex):
assert plex.seen[-1].method == "POST" assert plex.seen[-1].method == "POST"
assert params["title"] == "Best of: 90s" and params["sectionId"] == "3" assert params["title"] == "Best of: 90s" and params["sectionId"] == "3"
assert params["uri"] == "server://abc/com.plexapp.plugins.library/library/metadata/42" assert params["uri"] == "server://abc/com.plexapp.plugins.library/library/metadata/42"
assert params["type"] == "1" # a movie collection unless told otherwise
# A show collection is made as one: made as a movie one, it came out empty in a TV section.
plex.create_collection("3", "Shows", "42", 2)
assert plex.seen[-1].url.params["type"] == "2"
plex.routes["/library/collections"] = {} plex.routes["/library/collections"] = {}
with pytest.raises(PlexError): with pytest.raises(PlexError):
@@ -78,5 +78,9 @@ def test_a_show_lists_its_own_librarys(db, monkeypatch, override_dep):
assert [(c["id"], c["contains"]) for c in resp.json()["collections"]] == [("cT", False)] assert [(c["id"], c["contains"]) for c in resp.json()["collections"]] == [("cT", False)]
def test_an_episode_or_an_unknown_key_is_not_a_collection_member(db, monkeypatch, override_dep): def test_an_episode_is_not_a_collection_member(db, monkeypatch, override_dep):
assert _get(db, monkeypatch, override_dep, "e1").status_code == 404 assert _get(db, monkeypatch, override_dep, "e1").status_code == 404
def test_an_unknown_key_is_not_found(db, monkeypatch, override_dep):
assert _get(db, monkeypatch, override_dep, "nope").status_code == 404
@@ -678,6 +678,12 @@ describe("PlayerModal — the docked bar's fullscreen", () => {
configurable: true, configurable: true,
value: () => Promise.resolve(), value: () => Promise.resolve(),
}); });
// Brave's stand-in otherwise: a <video>-only requestFullscreen on HTMLElement.prototype.
else
Object.defineProperty(HTMLElement.prototype, "requestFullscreen", {
configurable: true,
value: () => true,
});
vi.spyOn(api, "videoDetail").mockReturnValue(new Promise(() => {})); vi.spyOn(api, "videoDetail").mockReturnValue(new Promise(() => {}));
const A = vid("A", 0); const A = vid("A", 0);
renderModal( renderModal(
@@ -688,6 +694,7 @@ describe("PlayerModal — the docked bar's fullscreen", () => {
}; };
afterEach(() => { afterEach(() => {
delete (Element.prototype as { requestFullscreen?: unknown }).requestFullscreen; delete (Element.prototype as { requestFullscreen?: unknown }).requestFullscreen;
delete (HTMLElement.prototype as { requestFullscreen?: unknown }).requestFullscreen;
}); });
it("is offered where the browser can fullscreen an element", () => { it("is offered where the browser can fullscreen an element", () => {
@@ -912,12 +912,18 @@ describe("the fullscreen button", () => {
expect(screen.queryByLabelText("plex.player.fullscreen")).not.toBeNull(); expect(screen.queryByLabelText("plex.player.fullscreen")).not.toBeNull();
}); });
it("is left out where it cannot, whatever fullscreenEnabled claims", async () => { it("is left out where it cannot, whatever Brave's stand-ins claim", async () => {
withApi(false); withApi(false);
// Brave's: a <video>-only requestFullscreen on HTMLElement.prototype, and fullscreenEnabled true.
Object.defineProperty(HTMLElement.prototype, "requestFullscreen", {
configurable: true,
value: () => true,
});
Object.defineProperty(document, "fullscreenEnabled", { configurable: true, value: true }); Object.defineProperty(document, "fullscreenEnabled", { configurable: true, value: true });
mount({ details: { A: item("A") } }); mount({ details: { A: item("A") } });
await playingAt("/media/A", 100); await playingAt("/media/A", 100);
expect(screen.queryByLabelText("plex.player.fullscreen")).toBeNull(); expect(screen.queryByLabelText("plex.player.fullscreen")).toBeNull();
delete (document as { fullscreenEnabled?: unknown }).fullscreenEnabled; delete (document as { fullscreenEnabled?: unknown }).fullscreenEnabled;
delete (HTMLElement.prototype as { requestFullscreen?: unknown }).requestFullscreen;
}); });
}); });