Skip to content

Commit

Permalink
[Test] add tests e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
claire2212 committed Jul 5, 2024
1 parent b79fdbd commit 3d33aac
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 27 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions frontend/cypress/e2e/main_window/monitor-ext.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { FAKE_MAPBOX_RESPONSE } from '../constants'

context('MonitorExt', () => {
beforeEach(() => {
cy.intercept('GET', 'https://api.mapbox.com/**', FAKE_MAPBOX_RESPONSE)
cy.visit('/ext#@-824534.42,6082993.21,8.70')
cy.wait(500)
})

it('A user can search semaphore', () => {
cy.wait(200)
cy.clickButton('Chercher un s茅maphore')
cy.fill('Rechercher un s茅maphore', 'S茅maphore de F茅camp')
cy.get('.baselayer').toMatchImageSnapshot({
imageConfig: {
threshold: 0.05,
thresholdType: 'percent'
},
screenshotConfig: {
clip: { height: 250, width: 250, x: 440, y: 450 }
}
})
})

it("A user can't see missions, reportings, bases and measurements tools button", () => {
cy.wait(200)
cy.getDataCy('missions-button').should('not.exist')
cy.getDataCy('reportings-button').should('not.exist')
cy.getDataCy('semaphores-button').should('exist')
cy.get('button[title="Liste des unit茅s de contr么le"]').should('not.exist')
cy.getDataCy('measurement').should('not.exist')
cy.getDataCy('interest-point').should('not.exist')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { reduceReportingFormOnMap } from 'domain/use_cases/reporting/reduceRepor

import { SearchSemaphores } from './SearchSemaphores'

export function SearchSemaphoreButton() {
export function SearchSemaphoreButton({ isSuperUser }: { isSuperUser: boolean | undefined }) {
const dispatch = useAppDispatch()
const isSearchSemaphoreVisible = useAppSelector(state => state.global.isSearchSemaphoreVisible)

Expand All @@ -19,7 +19,7 @@ export function SearchSemaphoreButton() {
}

return (
<ButtonWrapper topPosition={178}>
<ButtonWrapper topPosition={isSuperUser ? 178 : 82}>
{isSearchSemaphoreVisible && <SearchSemaphores />}
<MenuWithCloseButton.ButtonOnMap
className={isSearchSemaphoreVisible ? '_active' : undefined}
Expand Down
97 changes: 73 additions & 24 deletions frontend/src/features/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,55 @@ import { StationOverlay } from '../Station/components/StationOverlay'
// TODO Either use HOC to get proprer typings inference or migrate to vanilla JS.
// https://legacy.reactjs.org/docs/higher-order-components.html#convention-pass-unrelated-props-through-to-the-wrapped-component
export function Map({ isSuperUser, isVigilanceAreaEnabled }) {
if (!isSuperUser) {
return (
<BaseMap
// BaseMap forwards map & mapClickEvent as props to children
// handleMovingAndZoom={handleMovingAndZoom}
// handlePointerMove={handlePointerMove}
//
// -> only add child to BaseMap if it requires map or mapClickEvent
>
{/* @ts-ignore */}
<ZoomListener />
{/* @ts-ignore */}
<MapAttributionsBox />
{/* @ts-ignore */}
<MapCoordinatesBox />
{/* @ts-ignore */}
<MapLayer />

{/* ZONE */}
{/* @ts-ignore */}
<AMPLayers />
{/* @ts-ignore */}
<AMPPreviewLayer />
{/* @ts-ignore */}
<RegulatoryLayers />
{/* @ts-ignore */}
<RegulatoryPreviewLayer />
{/* @ts-ignore */}
<AdministrativeLayers />
{/* @ts-ignore */}
<LayerEvents />
{/* @ts-ignore */}
<LayersOverlay />

{/* MAP */}
{/* @ts-ignore */}
<MapExtentController />
{/* @ts-ignore */}
<MapHistory />

{/* SEMAPHORE */}
{/* @ts-ignore */}
<SemaphoresLayer />
{/* @ts-ignore */}
<SemaphoreOverlay isSuperUser={false} />
</BaseMap>
)
}

return (
<BaseMap
// BaseMap forwards map & mapClickEvent as props to children
Expand Down Expand Up @@ -82,35 +131,35 @@ export function Map({ isSuperUser, isVigilanceAreaEnabled }) {

{/* MAP */}
{/* @ts-ignore */}
{isSuperUser && <MeasurementLayer />}
<MeasurementLayer />
{/* @ts-ignore */}
{isSuperUser && <InterestPointLayer />}
<InterestPointLayer />
{/* @ts-ignore */}
<MapExtentController />
{/* @ts-ignore */}
<MapHistory />
{/* @ts-ignore */}
{isSuperUser && <DrawLayer />}
<DrawLayer />

{/* MISSION */}
{/* @ts-ignore */}
{isSuperUser && <MissionsLayer />}
<MissionsLayer />
{/* @ts-ignore */}
{isSuperUser && <SelectedMissionLayer />}
<SelectedMissionLayer />
{/* @ts-ignore */}
{isSuperUser && <EditingMissionLayer />}
<EditingMissionLayer />
{/* @ts-ignore */}
{isSuperUser && <HoveredMissionLayer />}
<HoveredMissionLayer />
{/* @ts-ignore */}
{isSuperUser && <MissionOverlays />}
<MissionOverlays />
{/* @ts-ignore */}
{isSuperUser && <ActionOverlay />}
<ActionOverlay />
{/* @ts-ignore */}
{isSuperUser && <ReportingToAttachLayer />}
<ReportingToAttachLayer />
{/* @ts-ignore */}
{isSuperUser && <HoveredReportingToAttachLayer />}
<HoveredReportingToAttachLayer />
{/* @ts-ignore */}
{isSuperUser && <ReportingToAttachOverlays />}
<ReportingToAttachOverlays />

{/* SEMAPHORE */}
{/* @ts-ignore */}
Expand All @@ -120,31 +169,31 @@ export function Map({ isSuperUser, isVigilanceAreaEnabled }) {
{/* @ts-ignore */}
<SelectedSemaphoreLayer />
{/* @ts-ignore */}
<SemaphoreOverlay isSuperUser={isSuperUser} />
<SemaphoreOverlay isSuperUser />

{/* REPORTING */}
{/* @ts-ignore */}
{isSuperUser && <EditingReportingLayer />}
<EditingReportingLayer />
{/* @ts-ignore */}
{isSuperUser && <SelectedReportingLayer />}
<SelectedReportingLayer />
{/* @ts-ignore */}
{isSuperUser && <HoveredReportingLayer />}
<HoveredReportingLayer />
{/* @ts-ignore */}
{isSuperUser && <ReportingsLayer />}
<ReportingsLayer />
{/* @ts-ignore */}
{isSuperUser && <ReportingOverlay />}
<ReportingOverlay />
{/* @ts-ignore */}
{isSuperUser && <StationLayer />}
<StationLayer />
{/* @ts-ignore */}
{isSuperUser && <StationOverlay />}
<StationOverlay />
{/* @ts-ignore */}
{isSuperUser && <MissionToAttachLayer />}
<MissionToAttachLayer />
{/* @ts-ignore */}
{isSuperUser && <HoveredMissionToAttachLayer />}
<HoveredMissionToAttachLayer />
{/* @ts-ignore */}
{isSuperUser && <SelectedMissionToAttachLayer />}
<SelectedMissionToAttachLayer />
{/* @ts-ignore */}
{isSuperUser && <MissionToAttachOverlays />}
<MissionToAttachOverlays />

{/* VIGILANCE AREA */}
{/* @ts-ignore */}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function HomePage() {

{displayMissionMenuButton && isSuperUser && <MissionsMenu />}
{displayReportingsButton && isSuperUser && <ReportingsButton />}
{displaySearchSemaphoreButton && <SearchSemaphoreButton />}
{displaySearchSemaphoreButton && <SearchSemaphoreButton isSuperUser={isSuperUser} />}
{isRightMenuControlUnitListButtonVisible && isSuperUser && <ControlUnitListButton />}

{displayMeasurement && isSuperUser && <MeasurementMapButton />}
Expand Down

0 comments on commit 3d33aac

Please sign in to comment.