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

refactor: Rename "finish" variables and functions to "review" #2673

Merged
merged 1 commit into from
Jun 25, 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: 3 additions & 3 deletions assets/src/components/detours/diversionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const DiversionPage = ({
canUndo,
undo,
clear,
finishDetour,
reviewDetour,
editDetour,
} = useDetour(originalRoute)

Expand Down Expand Up @@ -198,8 +198,8 @@ export const DiversionPage = ({
routeDescription={routeDescription ?? "??"}
routeOrigin={routeOrigin ?? "??"}
routeDirection={routeDirection ?? "??"}
detourFinished={finishDetour !== undefined}
onFinishDetour={finishDetour}
detourFinished={reviewDetour !== undefined}
onReviewDetour={reviewDetour}
onChangeRoute={
inTestGroup(TestGroups.DetourRouteSelection)
? () => send({ type: "detour.route-pattern.open" })
Expand Down
6 changes: 3 additions & 3 deletions assets/src/components/detours/diversionPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface DiversionPanelProps {
routeOrigin: string
routeDirection: string
detourFinished?: boolean
onFinishDetour?: () => void
onReviewDetour?: () => void
onChangeRoute?: () => void
}

Expand All @@ -27,7 +27,7 @@ export const DiversionPanel = ({
routeOrigin,
routeDirection,
detourFinished,
onFinishDetour,
onReviewDetour,
onChangeRoute,
}: DiversionPanelProps) => (
<Panel as="article" className="c-diversion-panel">
Expand Down Expand Up @@ -103,7 +103,7 @@ export const DiversionPanel = ({
</Panel.Body.ScrollArea>

<Panel.Body.Footer hidden={!detourFinished}>
<Button className="flex-grow-1 m-3" onClick={onFinishDetour}>
<Button className="flex-grow-1 m-3" onClick={onReviewDetour}>
Review Detour
</Button>
</Panel.Body.Footer>
Expand Down
6 changes: 3 additions & 3 deletions assets/src/hooks/useDetour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const useDetour = (input: CreateDetourMachineInput) => {
send({ type: "detour.edit.clear-detour" })
}

const finishDetour = () => {
const reviewDetour = () => {
send({ type: "detour.edit.done" })
}

Expand Down Expand Up @@ -206,8 +206,8 @@ export const useDetour = (input: CreateDetourMachineInput) => {
clear,

/** When present, puts this detour in "finished mode" */
finishDetour: snapshot.can({ type: "detour.edit.done" })
? finishDetour
reviewDetour: snapshot.can({ type: "detour.edit.done" })
? reviewDetour
: undefined,
/** When present, puts this detour in "edit mode" */
editDetour,
Expand Down
16 changes: 8 additions & 8 deletions assets/tests/components/detours/diversionPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { DiversionPage as DiversionPageDefault } from "../../../src/components/d
import stopFactory from "../../factories/stop"
import userEvent from "@testing-library/user-event"
import {
finishDetourButton,
originalRouteShape,
reviewDetourButton,
} from "../../testHelpers/selectors/components/detours/diversionPage"
import {
finishedDetourFactory,
Expand Down Expand Up @@ -898,7 +898,7 @@ describe("DiversionPage", () => {
fireEvent.click(originalRouteShape.get(container))
})

await userEvent.click(finishDetourButton.get())
await userEvent.click(reviewDetourButton.get())

expect(
screen.queryByRole("heading", { name: "Create Detour" })
Expand All @@ -919,7 +919,7 @@ describe("DiversionPage", () => {
fireEvent.click(originalRouteShape.get(container))
})

await userEvent.click(finishDetourButton.get())
await userEvent.click(reviewDetourButton.get())

expect(screen.getByRole("alert")).toHaveTextContent(
"Detour shape is not editable from this screen."
Expand All @@ -937,7 +937,7 @@ describe("DiversionPage", () => {
fireEvent.click(originalRouteShape.get(container))
})

await userEvent.click(finishDetourButton.get())
await userEvent.click(reviewDetourButton.get())

await waitFor(() => {
expect(screen.getByRole("button", { name: "Undo" })).toBeDisabled()
Expand All @@ -956,7 +956,7 @@ describe("DiversionPage", () => {
fireEvent.click(originalRouteShape.get(container))
})

await userEvent.click(finishDetourButton.get())
await userEvent.click(reviewDetourButton.get())

expect(screen.getByRole("button", { name: "Edit Detour" })).toBeVisible()
})
Expand All @@ -972,7 +972,7 @@ describe("DiversionPage", () => {
fireEvent.click(originalRouteShape.get(container))
})

await userEvent.click(finishDetourButton.get())
await userEvent.click(reviewDetourButton.get())

await userEvent.click(
await screen.findByRole("button", { name: "Edit Detour" })
Expand Down Expand Up @@ -1002,7 +1002,7 @@ describe("DiversionPage", () => {
fireEvent.click(originalRouteShape.get(container))
})

await userEvent.click(finishDetourButton.get())
await userEvent.click(reviewDetourButton.get())

expect(screen.getByRole("button", { name: "Copy Details" })).toBeVisible()
})
Expand Down Expand Up @@ -1067,7 +1067,7 @@ describe("DiversionPage", () => {
fireEvent.click(originalRouteShape.get(container))
})

await userEvent.click(finishDetourButton.get())
await userEvent.click(reviewDetourButton.get())

await userEvent.click(screen.getByRole("button", { name: "Copy Details" }))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from "@jest/globals"
import { byRole } from "testing-library-selector"

export const finishDetourButton = byRole("button", { name: "Review Detour" })
export const reviewDetourButton = byRole("button", { name: "Review Detour" })

export const originalRouteShape = {
interactive: {
Expand Down
Loading