diff --git a/assets/src/components/detours/diversionPage.tsx b/assets/src/components/detours/diversionPage.tsx index 74e0abde4..b23da9cee 100644 --- a/assets/src/components/detours/diversionPage.tsx +++ b/assets/src/components/detours/diversionPage.tsx @@ -151,7 +151,9 @@ export const DiversionPage = ({ ...(missedStops?.map(({ name }) => name) ?? ["no stops"]), , "Turn-by-Turn Directions:", - ...(extendedDirections?.map((v) => v.instruction) ?? []), + ...(editedDirections + ? [editedDirections] + : extendedDirections?.map((v) => v.instruction) ?? []), ].join("\n") const routes = useContext(RoutesContext) diff --git a/assets/tests/components/detours/diversionPage.test.tsx b/assets/tests/components/detours/diversionPage.test.tsx index b4b7c5388..13be7cc9f 100644 --- a/assets/tests/components/detours/diversionPage.test.tsx +++ b/assets/tests/components/detours/diversionPage.test.tsx @@ -1335,6 +1335,34 @@ describe("DiversionPage", () => { expect(input.value).toBe(startText + "\nHello World!") }) + test("Edited detour text is reflected in the copy button", async () => { + const { container } = render() + + act(() => { + fireEvent.click(originalRouteShape.get(container)) + }) + + act(() => { + fireEvent.click(originalRouteShape.get(container)) + }) + + await userEvent.click(reviewDetourButton.get()) + + const input = screen.getByRole("textbox") as HTMLTextAreaElement + + const startText = `From null` + + await userEvent.type(input, "\nHello World!") + + await userEvent.click(screen.getByRole("button", { name: "Copy details" })) + + await waitFor(() => + expect(window.navigator.clipboard.readText()).resolves.toMatch( + startText + "\nHello World!" + ) + ) + }) + test("Attempting to close the page calls the onClose callback", async () => { const onClose = jest.fn()