-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix activeIndex bug and previous data fn
- Loading branch information
Showing
5 changed files
with
146 additions
and
6 deletions.
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
80 changes: 80 additions & 0 deletions
80
editor.planx.uk/src/@planx/components/MapAndLabel/Public/index.bugTest.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,80 @@ | ||
import { MyMap } from "@opensystemslab/map"; | ||
import React from "react"; | ||
import { setup } from "testUtils"; | ||
import { it, vi } from "vitest"; | ||
|
||
import { point1, point2, point3 } from "../test/mocks/geojson"; | ||
import { | ||
previousDoubleDataProps, | ||
previousSingleDataProps, | ||
} from "../test/mocks/Trees"; | ||
import { addFeaturesToMap, addMultipleFeatures } from "../test/utils"; | ||
import { Presentational as MapAndLabel } from "."; | ||
|
||
beforeAll(() => { | ||
if (!window.customElements.get("my-map")) { | ||
window.customElements.define("my-map", MyMap); | ||
} | ||
|
||
const ResizeObserverMock = vi.fn(() => ({ | ||
observe: vi.fn(), | ||
unobserve: vi.fn(), | ||
disconnect: vi.fn(), | ||
})); | ||
|
||
vi.stubGlobal("ResizeObserver", ResizeObserverMock); | ||
}); | ||
|
||
describe("navigating back after adding single feature", () => { | ||
it("shows previously submitted features", async () => { | ||
const { getByTestId, queryByRole, user } = setup( | ||
<MapAndLabel {...previousSingleDataProps} />, | ||
); | ||
const map = getByTestId("map-and-label-map"); | ||
|
||
expect(map).toBeInTheDocument(); | ||
|
||
const firstTab = queryByRole("tab", { name: /Tree 1/ }); | ||
expect(firstTab).toBeInTheDocument(); | ||
expect(firstTab).toBeVisible(); | ||
|
||
const firstTabPanel = getByTestId("vertical-tabpanel-0"); | ||
expect(firstTabPanel).toBeInTheDocument(); | ||
expect(firstTabPanel).toBeVisible(); | ||
|
||
// point1 here needs to be reflected in the props you pass in at the start so labels match | ||
addMultipleFeatures([point1, point2]); | ||
|
||
const secondTab = queryByRole("tab", { name: /Tree 2/ }); | ||
expect(secondTab).toBeInTheDocument(); | ||
expect(secondTab).toBeVisible(); | ||
}); | ||
}); | ||
|
||
describe("navigating back after adding two features", () => { | ||
it("shows previously submitted features", async () => { | ||
const { getByTestId, queryByRole, user } = setup( | ||
<MapAndLabel {...previousDoubleDataProps} />, | ||
); | ||
const map = getByTestId("map-and-label-map"); | ||
|
||
expect(map).toBeInTheDocument(); | ||
|
||
const firstTab = queryByRole("tab", { name: /Tree 1/ }); | ||
const secondTab = queryByRole("tab", { name: /Tree 2/ }); | ||
expect(firstTab).toBeInTheDocument(); | ||
expect(secondTab).toBeInTheDocument(); | ||
|
||
const firstTabPanel = getByTestId("vertical-tabpanel-0"); | ||
const secondTabPanel = getByTestId("vertical-tabpanel-1"); | ||
expect(firstTabPanel).toBeInTheDocument(); | ||
expect(secondTabPanel).toBeInTheDocument(); | ||
expect(secondTabPanel).toBeVisible(); | ||
|
||
addMultipleFeatures([point1, point2, point3]); | ||
|
||
const thirdTab = queryByRole("tab", { name: /Tree 3/ }); | ||
expect(thirdTab).toBeInTheDocument(); | ||
expect(thirdTab).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
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