feat(frontend): add intake journal and shared note flows (#648)

* feat(backend): add intake journal APIs and share note support

* feat(frontend): add intake journal and shared note flows
This commit is contained in:
Daniel Volz
2026-05-24 14:00:30 +02:00
committed by GitHub
parent e4a1b449c6
commit c78fc43083
67 changed files with 5414 additions and 580 deletions
@@ -0,0 +1,47 @@
import { act, renderHook } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { useModalHistory } from "../../hooks/useModalHistory";
describe("useModalHistory", () => {
beforeEach(() => {
vi.spyOn(window.history, "pushState").mockImplementation(() => {});
});
afterEach(() => {
vi.restoreAllMocks();
});
it("pushes a modal history entry and closes the modal on browser back", () => {
const onClose = vi.fn();
const { rerender } = renderHook(({ isOpen }) => useModalHistory(isOpen, "journal-editor", onClose), {
initialProps: { isOpen: false },
});
rerender({ isOpen: true });
expect(window.history.pushState).toHaveBeenCalledWith({ modal: "journal-editor" }, "");
act(() => {
window.dispatchEvent(new PopStateEvent("popstate"));
});
expect(onClose).toHaveBeenCalledTimes(1);
});
it("stops parent popstate handlers when a nested modal consumes browser back", () => {
const onClose = vi.fn();
const parentClose = vi.fn();
window.addEventListener("popstate", parentClose);
renderHook(() => useModalHistory(true, "nested-confirm", onClose));
act(() => {
window.dispatchEvent(new PopStateEvent("popstate"));
});
expect(onClose).toHaveBeenCalledTimes(1);
expect(parentClose).not.toHaveBeenCalled();
window.removeEventListener("popstate", parentClose);
});
});