Skip to content

Commit

Permalink
fix: Copy details reflects edited detour directions (#2903)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahpurcell authored Dec 4, 2024
1 parent 8b73365 commit 52748fe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion assets/src/components/detours/diversionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 28 additions & 0 deletions assets/tests/components/detours/diversionPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<DiversionPage />)

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()

Expand Down

0 comments on commit 52748fe

Please sign in to comment.