feat(FN-3344): preserve history state in deep-link close

Fixes deep-link close to preserve browser history state and adds comprehensive integration tests for the navigation history feature, covering App component and useDeepLink hook behavior.

Fusion-Task-Id: FN-3344
This commit is contained in:
Fusion
2026-05-04 02:17:44 -07:00
committed by gsxdsm
parent cbb87ae00e
commit 685cfc063d
3 changed files with 10 additions and 5 deletions

View File

@@ -142,11 +142,15 @@ describe("useDeepLink", () => {
});
});
it("cleans task query param when deep-linked modal closes", async () => {
it("cleans task query param when deep-linked modal closes and preserves history state", async () => {
Object.defineProperty(window, "location", {
configurable: true,
value: new URL("http://localhost:3000/?project=proj_123&task=FN-123"),
});
const replaceStateMock = window.history.replaceState as ReturnType<typeof vi.fn>;
window.history.replaceState = originalReplaceState;
window.history.replaceState({ navIndex: 2, existing: "value" }, "");
window.history.replaceState = replaceStateMock;
const { result, closeTaskDetail } = renderUseDeepLink();
@@ -157,7 +161,7 @@ describe("useDeepLink", () => {
result.current.handleDetailClose();
expect(window.history.replaceState).toHaveBeenCalledWith(
null,
{ navIndex: 2, existing: "value" },
"",
"/?project=proj_123",
);