Skip to content

Commit

Permalink
fix: Remove auto-close feature from RoutePropertiesCard (#2619)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshlarson authored May 23, 2024
1 parent 12c32a4 commit eb4377f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
1 change: 0 additions & 1 deletion assets/src/components/mapPage/routePropertiesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ const RoutePropertiesCard = ({
selectedRoutePatternId={selectedRoutePattern.id}
selectRoutePattern={(routePattern: RoutePattern) => {
selectRoutePattern(routePattern)
setOpenedDetails(null)
}}
/>
</DetailSection>
Expand Down
24 changes: 22 additions & 2 deletions assets/tests/components/mapPage/routePropertiesCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ describe("<RoutePropertiesCard/>", () => {
)
})

test("Clicking a different route pattern calls selectRoutePattern and closes the variants list", async () => {
test("Clicking a different route pattern calls selectRoutePattern", async () => {
const mockSelectRoutePattern = jest.fn()

render(
Expand All @@ -321,7 +321,27 @@ describe("<RoutePropertiesCard/>", () => {

await userEvent.click(routePattern2Radio)
expect(mockSelectRoutePattern).toHaveBeenCalledWith(routePattern2)
expect(routePattern2Radio).not.toBeVisible()
})

test("Clicking a different route pattern does not close the variants list", async () => {
const mockSelectRoutePattern = jest.fn()

render(
<RoutePropertiesCardWithDefaults
selectRoutePattern={mockSelectRoutePattern}
/>
)

await userEvent.click(
screen.getByRole("button", { name: "Show variants" })
)

const routePattern2Radio = screen.getByRole("radio", {
name: new RegExp(patternDisplayName(routePattern2).name),
})

await userEvent.click(routePattern2Radio)
expect(routePattern2Radio).toBeVisible()
})

test("Clicking the close button calls onClose prop", async () => {
Expand Down

0 comments on commit eb4377f

Please sign in to comment.