feat(GRO-2160): route nav export buttons + offline map polish (#66)
CI / Test (pull_request) Successful in 21s
CI / Lint & Typecheck (pull_request) Successful in 26s
CI / Build & Push Docker Image (pull_request) Successful in 25s

This commit is contained in:
2026-06-09 04:31:24 +00:00
committed by gb_flea
parent e93017b279
commit 9894a86717
4 changed files with 305 additions and 3 deletions
+39
View File
@@ -82,6 +82,18 @@ function mockFetch(meRole: "manager" | "groomer") {
if (/^\/api\/routes\/[^/]+\/reorder$/.test(url) && opts?.method === "PATCH") {
return Promise.resolve({ ok: true, json: () => Promise.resolve(ROUTE_RESPONSE) } as Response);
}
if (/^\/api\/routes\/[^/]+\/export\/google-maps$/.test(url)) {
return Promise.resolve({
ok: true,
json: () => Promise.resolve({ platform: "google-maps", url: "https://www.google.com/maps/dir/?api=1", stopCount: 2, waypointCount: 0 }),
} as Response);
}
if (/^\/api\/routes\/[^/]+\/export\/apple-maps$/.test(url)) {
return Promise.resolve({
ok: true,
json: () => Promise.resolve({ platform: "apple-maps", url: "maps://?saddr=51.5,-0.1&daddr=51.52,-0.12", stopCount: 2, waypointCount: 0 }),
} as Response);
}
return Promise.resolve({ ok: true, json: () => Promise.resolve({}) } as Response);
});
}
@@ -169,4 +181,31 @@ describe("RoutesPage", () => {
)
);
});
it("renders both navigation export buttons when the route has stops", async () => {
global.fetch = mockFetch("manager") as unknown as typeof fetch;
render(<RoutesPage />);
await waitFor(() => expect(screen.getByText("Alice")).toBeInTheDocument());
expect(screen.getByRole("button", { name: "Open in Google Maps" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Open in Apple Maps" })).toBeInTheDocument();
});
it("fetches the export deep link and opens it when Open in Google Maps is clicked", async () => {
const fetchMock = mockFetch("manager");
global.fetch = fetchMock as unknown as typeof fetch;
const openSpy = vi
.spyOn(window, "open")
.mockReturnValue({ location: { href: "" }, close: vi.fn() } as unknown as Window);
render(<RoutesPage />);
await waitFor(() => expect(screen.getByText("Alice")).toBeInTheDocument());
fireEvent.click(screen.getByRole("button", { name: "Open in Google Maps" }));
await waitFor(() =>
expect(fetchMock).toHaveBeenCalledWith("/api/routes/r1/export/google-maps")
);
expect(openSpy).toHaveBeenCalled();
});
});