Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enter the "Activated" state when "Activate Detour" button is clicked #2714

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion assets/src/components/detours/diversionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ export const DiversionPage = ({
detourText={textArea}
onChangeDetourText={setTextArea}
onActivateDetour={
inTestGroup(TestGroups.DetoursList) ? () => {} : undefined
inTestGroup(TestGroups.DetoursList)
? () => {
send({ type: "detour.share.activate" })
}
: undefined
}
/>
) : null}
Expand Down
7 changes: 6 additions & 1 deletion assets/src/models/createDetourMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export const createDetourMachine = setup({
| { type: "detour.edit.place-waypoint-on-route"; location: ShapePoint }
| { type: "detour.edit.place-waypoint"; location: ShapePoint }
| { type: "detour.edit.undo" }
| { type: "detour.share.copy-detour"; detourText: string },
| { type: "detour.share.copy-detour"; detourText: string }
| { type: "detour.share.activate" },
},
actors: {
"fetch-route-patterns": fromPromise<
Expand Down Expand Up @@ -411,8 +412,12 @@ export const createDetourMachine = setup({
"detour.edit.resume": {
target: "Editing.Finished Drawing",
},
"detour.share.activate": {
target: "Active",
},
},
},
Active: {},
},
},
},
Expand Down
12 changes: 11 additions & 1 deletion assets/tests/components/detours/diversionPageActivate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { beforeEach, describe, expect, jest, test } from "@jest/globals"
import "@testing-library/jest-dom/jest-globals"
import getTestGroups from "../../../src/userTestGroups"
import { TestGroups } from "../../../src/userInTestGroup"
import { act, fireEvent, render } from "@testing-library/react"
import { act, fireEvent, render, screen } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import {
activateDetourButton,
Expand Down Expand Up @@ -81,4 +81,14 @@ describe("DiversionPage activate workflow", () => {

expect(activateDetourButton.get()).toBeVisible()
})

test("clicking the activate button shows the 'Active Detour' screen", async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: there is not yet an "active detour" screen, so the test (appropriately, I think) checks that the old screen is gone. Should the name of the test be changed?

Suggested change
test("clicking the activate button shows the 'Active Detour' screen", async () => {
test("clicking the activate button changes screen from 'Share Detour Details'", async () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errr - woops! Auto-merge scooped your (very accurate) comment.

But I think #2715 makes the test name accurate again.

await diversionPageOnReviewScreen()

await userEvent.click(activateDetourButton.get())

expect(
screen.queryByRole("heading", { name: "Share Detour Details" })
).not.toBeInTheDocument()
})
})
Loading