-
Notifications
You must be signed in to change notification settings - Fork 9
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: Add Activate
button gated behind detours-list test group
#2713
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
23bd5eb
feat: Activate button
joshlarson bb1ab5c
fixup! feat: Activate button
joshlarson 9f0b5bc
fixup! feat: Activate button
joshlarson 87f820a
fixup! feat: Activate button
joshlarson a09633c
fixup! feat: Activate button
joshlarson a9c43b6
fixup! feat: Activate button
joshlarson d41364b
fixup! feat: Activate button
joshlarson 135faf1
fixup! feat: Activate button
joshlarson cec1abd
fixup! feat: Activate button
joshlarson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
assets/tests/components/detours/diversionPageActivate.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import React from "react" | ||
import { | ||
DiversionPage as DiversionPageDefault, | ||
DiversionPageProps, | ||
} from "../../../src/components/detours/diversionPage" | ||
import { originalRouteFactory } from "../../factories/originalRouteFactory" | ||
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 userEvent from "@testing-library/user-event" | ||
import { | ||
activateDetourButton, | ||
originalRouteShape, | ||
reviewDetourButton, | ||
} from "../../testHelpers/selectors/components/detours/diversionPage" | ||
import { | ||
fetchDetourDirections, | ||
fetchFinishedDetour, | ||
fetchNearestIntersection, | ||
fetchRoutePatterns, | ||
fetchUnfinishedDetour, | ||
} from "../../../src/api" | ||
import { neverPromise } from "../../testHelpers/mockHelpers" | ||
|
||
beforeEach(() => { | ||
jest.spyOn(global, "scrollTo").mockImplementationOnce(jest.fn()) | ||
}) | ||
|
||
const DiversionPage = (props: Partial<DiversionPageProps>) => ( | ||
<DiversionPageDefault | ||
originalRoute={originalRouteFactory.build()} | ||
showConfirmCloseModal={false} | ||
{...props} | ||
/> | ||
) | ||
|
||
jest.mock("../../../src/api") | ||
jest.mock("../../../src/userTestGroups") | ||
|
||
beforeEach(() => { | ||
jest.mocked(fetchDetourDirections).mockReturnValue(neverPromise()) | ||
jest.mocked(fetchUnfinishedDetour).mockReturnValue(neverPromise()) | ||
jest.mocked(fetchFinishedDetour).mockReturnValue(neverPromise()) | ||
jest.mocked(fetchNearestIntersection).mockReturnValue(neverPromise()) | ||
jest.mocked(fetchRoutePatterns).mockReturnValue(neverPromise()) | ||
|
||
jest | ||
.mocked(getTestGroups) | ||
.mockReturnValue([TestGroups.DetoursPilot, TestGroups.DetoursList]) | ||
}) | ||
|
||
const diversionPageOnReviewScreen = async ( | ||
props?: Partial<DiversionPageProps> | ||
) => { | ||
const { container } = render(<DiversionPage {...props} />) | ||
|
||
act(() => { | ||
fireEvent.click(originalRouteShape.get(container)) | ||
}) | ||
act(() => { | ||
fireEvent.click(originalRouteShape.get(container)) | ||
}) | ||
await userEvent.click(reviewDetourButton.get()) | ||
|
||
return { container } | ||
} | ||
|
||
describe("DiversionPage activate workflow", () => { | ||
test("does not have an activate button on the review details screen if not in the detours-list test group", async () => { | ||
jest.mocked(getTestGroups).mockReturnValue([TestGroups.DetoursPilot]) | ||
|
||
await diversionPageOnReviewScreen() | ||
|
||
expect(activateDetourButton.query()).not.toBeInTheDocument() | ||
}) | ||
|
||
test("has an activate button on the review details screen", async () => { | ||
await diversionPageOnReviewScreen() | ||
|
||
expect(activateDetourButton.get()).toBeVisible() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a thing I've been thinking about doing for a while.
diversionPage.test.tsx
is getting very large, which makes it kind of unwieldy. There's no reason we need to have all of the detour tests live in the same file. I was thinking that we could start splitting out test cases for different angles of the detours feature into different test files.For instance, all of the test cases that make assertions about which route-shape pieces are visible could be in
diversionPageRouteShapes.test.tsx
, and the test cases that assert when the undo and clear buttons are disabled or enabled might live indiversionPageUndoClearButtons.test.tsx
.Exactly how to divvy the use cases into files is a matter of taste, and I don't have strong feelings about it. But I figured that test cases related to saving/activating might be happiest away from everything else.