generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48c6b01
commit 95333e7
Showing
24 changed files
with
408 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, { useState } from 'react' | ||
import { useState } from 'react' | ||
import { | ||
Button, | ||
Checkbox, | ||
|
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import React from 'react' | ||
import { screen } from '@testing-library/react' | ||
|
||
import { render } from '@/test-utils' | ||
|
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import React from 'react' | ||
import { screen } from '@testing-library/react' | ||
import { LatLngTuple } from 'leaflet' | ||
|
||
|
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
2 changes: 1 addition & 1 deletion
2
frontend/src/pages/authorizationDetails/AuthorizationDetails.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import React from 'react' | ||
import { screen } from '@testing-library/react' | ||
|
||
import { render } from '@/test-utils' | ||
|
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
153 changes: 153 additions & 0 deletions
153
frontend/src/pages/map/layers/AuthorizationMarkers.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,153 @@ | ||
import { screen } from '@testing-library/react' | ||
import { useSelector } from 'react-redux' | ||
|
||
import { render } from '@/test-utils' | ||
import { | ||
initialState as initialOmrrState, | ||
OmrrSliceState, | ||
} from '@/features/omrr/omrr-slice' | ||
import { mockOmrrData } from '@/mocks/mock-omrr-data' | ||
import { | ||
initialState as initialMapState, | ||
MapSliceState, | ||
selectZoomPosition, | ||
useSelectedItem, | ||
ZoomPosition, | ||
} from '@/features/map/map-slice' | ||
import OmrrData from '@/interfaces/omrr' | ||
import { TestMapContainer } from './TestMapContainer' | ||
import { AuthorizationMarkers } from './AuthorizationMarkers' | ||
import { ActiveToolEnum, MIN_CIRCLE_RADIUS } from '@/constants/constants' | ||
|
||
interface State { | ||
selectedItem?: OmrrData | ||
zoomPosition?: ZoomPosition | ||
} | ||
|
||
describe('Test suite for AuthorizationMarkers', () => { | ||
function renderComponent( | ||
omrrState: Partial<OmrrSliceState> = {}, | ||
mapState: Partial<MapSliceState> = {}, | ||
screenWidth = 1500, | ||
) { | ||
const state: State = {} | ||
|
||
const TestComponent = () => { | ||
Object.assign(state, { | ||
selectedItem: useSelectedItem(), | ||
zoomPosition: useSelector(selectZoomPosition), | ||
}) | ||
return ( | ||
<TestMapContainer> | ||
<AuthorizationMarkers /> | ||
</TestMapContainer> | ||
) | ||
} | ||
|
||
const { user } = render(<TestComponent />, { | ||
screenWidth, | ||
withStateProvider: true, | ||
initialState: { | ||
omrr: { | ||
...initialOmrrState, | ||
status: 'succeeded', | ||
filteredResults: mockOmrrData, | ||
...omrrState, | ||
}, | ||
map: { | ||
...initialMapState, | ||
...mapState, | ||
}, | ||
}, | ||
}) | ||
return { user, state } | ||
} | ||
|
||
it('should not render AuthorizationMarkers if status is not succeeded', () => { | ||
renderComponent({ status: 'failed' }) | ||
expect( | ||
screen.queryByAltText('Authorization marker'), | ||
).not.toBeInTheDocument() | ||
}) | ||
|
||
it('should not render AuthorizationMarkers if no items', () => { | ||
renderComponent({ filteredResults: [] }) | ||
expect( | ||
screen.queryByAltText('Authorization marker'), | ||
).not.toBeInTheDocument() | ||
}) | ||
|
||
it('should render AuthorizationMarkers and click on marker', async () => { | ||
const { user, state } = renderComponent() | ||
|
||
const markers = screen.getAllByAltText('Authorization marker') | ||
expect(markers).toHaveLength(mockOmrrData.length) | ||
|
||
const [marker] = markers | ||
await user.click(marker) | ||
|
||
expect(state.selectedItem).toBe(mockOmrrData[0]) | ||
expect(state.zoomPosition).toBeDefined() | ||
}) | ||
|
||
it('should render AuthorizationMarkers in polygon search mode and click on marker', async () => { | ||
const { user, state } = renderComponent( | ||
{}, | ||
{ activeTool: ActiveToolEnum.polygonSearch }, | ||
) | ||
|
||
const markers = screen.getAllByAltText('Authorization marker') | ||
const [marker] = markers | ||
// Click is ignored when in polygon search mode | ||
await user.click(marker) | ||
|
||
expect(state.selectedItem).toBeUndefined() | ||
}) | ||
|
||
it('should render AuthorizationMarkers in polygon search mode with positions', async () => { | ||
const { user, state } = renderComponent( | ||
{ | ||
polygonFilter: { | ||
positions: [[48.123, -123.123]], | ||
finished: false, | ||
}, | ||
}, | ||
{ activeTool: ActiveToolEnum.polygonSearch }, | ||
) | ||
|
||
const marker = screen.getAllByAltText('Authorization marker')[0] | ||
expect(marker).toBeDefined() | ||
await user.click(marker) | ||
|
||
expect(state.selectedItem).toBeUndefined() | ||
}) | ||
|
||
it('should render AuthorizationMarkers in point search mode and click on marker', async () => { | ||
const { user, state } = renderComponent( | ||
{}, | ||
{ activeTool: ActiveToolEnum.pointSearch }, | ||
) | ||
|
||
const markers = screen.getAllByAltText('Authorization marker') | ||
const [marker] = markers | ||
await user.click(marker) | ||
|
||
expect(state.selectedItem).toBeUndefined() | ||
}) | ||
|
||
it('should render AuthorizationMarkers in point search mode with radius', async () => { | ||
const { user, state } = renderComponent( | ||
{ | ||
circleFilter: { radius: MIN_CIRCLE_RADIUS }, | ||
}, | ||
{ activeTool: ActiveToolEnum.pointSearch }, | ||
500, | ||
) | ||
|
||
const marker = screen.getAllByAltText('Authorization marker')[0] | ||
expect(marker).toBeDefined() | ||
await user.click(marker) | ||
|
||
expect(state.selectedItem).toBeUndefined() | ||
}) | ||
}) |
Oops, something went wrong.