fix(nav): a page settling keeps a reload's overlay entry; an old entry's sub-view goes to its own (review round 4)
- useUrlMirror: a change before the user has done anything since the load is the page settling (the rail stepping off a playlist deleted since, Files off a folder gone), not another view: the reload mark stays, and the player that reopens takes its entry over — one Back closes it, as before. - useHistorySubview: an entry an older build wrote is a module's only when its _sub is the view the address names under that module's key (the card's push kept the season's `v` beside its `m`). - Playlists: the rail's default selection and the page's "the rail moved there" read one helper. - moduleUrl contract: writer literals in a choice's branches are scanned too; the sub-view census walks type arguments of any depth and refuses an aliased import. - A stale comment on the nav press over a live search.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// @vitest-environment jsdom
|
||||
//
|
||||
// A reload under an overlay that reopens (the player) loads on the overlay's entry, its mark on it.
|
||||
// A page that settles before the overlay is back (the rail steps off a playlist deleted since, before
|
||||
// the player's row has loaded) has not been sent to another view: nothing the user did moved it. The
|
||||
// mark stays, and the reopened overlay takes its entry over rather than pushing one more — one more
|
||||
// was a Back that went nowhere. Its own file: the entry is read as the history module loads, so it is
|
||||
// set up before the import.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { act, renderHook } from "@testing-library/react";
|
||||
|
||||
describe("a page settling on the entry a reload under an overlay started from", () => {
|
||||
it("before the user has done anything, leaves the entry to the overlay that reopens", async () => {
|
||||
Object.defineProperty(navigator, "userActivation", {
|
||||
configurable: true,
|
||||
value: { hasBeenActive: false },
|
||||
});
|
||||
window.history.replaceState({ sfPage: "playlists" }, "", "/?page=playlists&pl=7");
|
||||
window.history.pushState(
|
||||
{ sfPage: "playlists", _ov: 1, _ovd: 1 },
|
||||
"",
|
||||
"/?page=playlists&pl=7&watch=Z",
|
||||
);
|
||||
const { useUrlMirror } = await import("./useUrlMirror");
|
||||
const { useBackToClose } = await import("./history");
|
||||
const mirror = renderHook(({ pl }) => useUrlMirror({ pl }), { initialProps: { pl: "7" } });
|
||||
mirror.rerender({ pl: "1" });
|
||||
expect(new URLSearchParams(window.location.search).get("pl")).toBe("1");
|
||||
|
||||
const depth = window.history.length;
|
||||
renderHook(() => useBackToClose(() => {}));
|
||||
await act(async () => {
|
||||
await Promise.resolve();
|
||||
});
|
||||
expect(window.history.length).toBe(depth);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user