- A URL mirror names the view again on every entry Back or Forward lands on, so a change made under a dialog, a drawer or a sub-view is not undone by the next reload. - A view pushed from the entry a reload under a dialog started from no longer inherits its overlay mark; a reload under two overlays closes onto the page in one step. - The linked player reopens over a live search, gives itself up when its list moves first, and plays alone over an emptied playlist; a capped Files list keeps the link it cannot resolve. - The Feed press over a channel ends the search; leaving a search ends its asked mark; Files and Playlists searches end with their page; the feed always names its view and debounces its search. - Search-box keys are declared per module and kept out of the client log below TRACE. - Writers outside lib/ go through codecs; the URL contract scans computed keys, overlay writers and two-line reads, and holds every page to a bookmark round trip (Config, Activity, Playlists and the Files sort and viewer added).
48 lines
2.1 KiB
TypeScript
48 lines
2.1 KiB
TypeScript
// @vitest-environment jsdom
|
|
//
|
|
// A reload under two overlays (a dialog, or a maximised player, over the player) loads on the upper
|
|
// one's entry; only the player reopens, and takes that entry over. The lower one's entry is still
|
|
// under it, and nothing reopens there: closing the player steps back over it too, so one close
|
|
// lands on the page — not on a dead step that looks like it. 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";
|
|
|
|
describe("an overlay reopened on the entry a reload under two started from", () => {
|
|
it("closes onto 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 depth = window.history.length;
|
|
const { useBackToClose } = await import("./history");
|
|
|
|
const holder: { unmount?: () => void } = {};
|
|
const r = renderHook(() => useBackToClose(() => holder.unmount?.(), { watch: "v1" }));
|
|
holder.unmount = r.unmount;
|
|
await act(async () => {
|
|
await Promise.resolve();
|
|
});
|
|
expect(window.history.length).toBe(depth);
|
|
|
|
await act(async () => {
|
|
const landed = new Promise((res) => window.addEventListener("popstate", res, { once: true }));
|
|
r.unmount();
|
|
await landed;
|
|
await Promise.resolve();
|
|
});
|
|
expect(window.history.state?._ov).toBeUndefined();
|
|
expect(window.location.search).toBe("?page=feed");
|
|
});
|
|
|
|
it("a pushed overlay entry records how many it stands on", async () => {
|
|
window.history.replaceState({ sfPage: "feed" }, "", "/?page=feed");
|
|
const { useBackToClose } = await import("./history");
|
|
const r = renderHook(() => useBackToClose(() => {}));
|
|
await act(async () => {
|
|
await Promise.resolve();
|
|
});
|
|
expect(window.history.state?._ovd).toBe(1);
|
|
r.unmount();
|
|
});
|
|
});
|