Files
siftlode/frontend/src/lib/history.reloadedNestedBack.dom.test.tsx
T
peter 6d57d62ac8 fix(nav): a linked player, file and search survive what the app does by itself (review round 2)
- Playlists: a link over a playlist the account does not hold plays alone; the rail's own
  fallback no longer counts as a pick that gives the player up.
- The linked opener opens or clears nothing once the address names another player, and stops
  looking (and fetching its row) once it settled.
- Files: a list the server's cap cut — the sorted or searched one too — keeps the link, with a
  notice of its own (EN/HU).
- History: an in-place view rewrite (search refine, count, channel to channel, sub-view)
  drops a reloaded entry's overlay marks (replaceView); a landing on a channel opened from a
  search keeps the search; the Feed press on a search opens the plain feed.
- Files/Playlists: an emptied search is written at once.
- Client log: plf/cf (column text filters) are typed keys; the shell has none of its own.
- Contract: writers outside lib/ take a literal or a lib/ function's result; every URL key is
  sorted typed or not; the writer regexes are held by a fixture; sub-views named; the bookmark
  net reads page tags.
- Feed defaults in one constant; one live-search queue helper; Scheduler writes through the
  Activity codec; notRun copy (EN/HU) names Forward and a plain "Search YouTube" button.
2026-10-27 16:08:52 +01:00

38 lines
1.5 KiB
TypeScript

// @vitest-environment jsdom
//
// A reload under two overlays: the player reopens on the upper one's entry, the lower one's is dead
// under it. A browser Back closes the player — and steps over the dead entry too, onto the page, as
// the player's own close does. Its own file: the entry is read as the module loads, so it is set up
// before the import.
import { describe, expect, it } from "vitest";
import { act, renderHook } from "@testing-library/react";
const landing = () =>
new Promise((res) => window.addEventListener("popstate", res, { once: true }));
describe("a browser Back over an overlay reopened on the entry a reload under two started from", () => {
it("lands on the page under both", async () => {
window.history.replaceState({ sfPage: "feed" }, "", "/?page=feed");
window.history.pushState({ sfPage: "feed", _ov: 1, _ovd: 1 }, "", "/?page=feed&watch=v1");
window.history.pushState({ sfPage: "feed", _ov: 2, _ovd: 2 }, "", "/?page=feed&watch=v1");
const { useBackToClose } = await import("./history");
let closed = false;
renderHook(() => useBackToClose(() => (closed = true), { watch: "v1" }));
await act(async () => {
await Promise.resolve();
});
await act(async () => {
const first = landing();
window.history.back();
await first;
await landing(); // the step over the dead entry
await Promise.resolve();
});
expect(closed).toBe(true);
expect(window.history.state?._ov).toBeUndefined();
expect(window.location.search).toBe("?page=feed");
});
});