From 3d33aac4719c3de114c09b069d95d08f18b387e0 Mon Sep 17 00:00:00 2001 From: Claire Dagan Date: Fri, 14 Jun 2024 10:05:59 +0200 Subject: [PATCH] [Test] add tests e2e --- ...torExt A user can search semaphore #0.png | Bin 0 -> 737 bytes ...Places A user can search semaphore #0.png | Bin 0 -> 737 bytes .../e2e/main_window/monitor-ext.spec.ts | 34 ++++++ .../SearchSemaphoreButton/index.tsx | 4 +- frontend/src/features/map/index.tsx | 97 +++++++++++++----- frontend/src/pages/HomePage.tsx | 2 +- 6 files changed, 110 insertions(+), 27 deletions(-) create mode 100644 frontend/cypress/e2e/main_window/__image_snapshots__/MonitorExt A user can search semaphore #0.png create mode 100644 frontend/cypress/e2e/main_window/__image_snapshots__/Search Places A user can search semaphore #0.png create mode 100644 frontend/cypress/e2e/main_window/monitor-ext.spec.ts diff --git a/frontend/cypress/e2e/main_window/__image_snapshots__/MonitorExt A user can search semaphore #0.png b/frontend/cypress/e2e/main_window/__image_snapshots__/MonitorExt A user can search semaphore #0.png new file mode 100644 index 0000000000000000000000000000000000000000..96d23700e3bd5562099c6eade9b905e7224eccc1 GIT binary patch literal 737 zcmeAS@N?(olHy`uVBq!ia0vp^zd)FS4M=vpiLzy2U|Qkn;uuoF`1W8UFM|RDlfvi! z^H*ET6uc8ph+;mI-B8JEu%7Xm>480LGp;jymP&{l6&wwafk+J1X|q^Ad~sj;514cr NJYD@<);T3K0RYj%Fn0g| literal 0 HcmV?d00001 diff --git a/frontend/cypress/e2e/main_window/__image_snapshots__/Search Places A user can search semaphore #0.png b/frontend/cypress/e2e/main_window/__image_snapshots__/Search Places A user can search semaphore #0.png new file mode 100644 index 0000000000000000000000000000000000000000..96d23700e3bd5562099c6eade9b905e7224eccc1 GIT binary patch literal 737 zcmeAS@N?(olHy`uVBq!ia0vp^zd)FS4M=vpiLzy2U|Qkn;uuoF`1W8UFM|RDlfvi! z^H*ET6uc8ph+;mI-B8JEu%7Xm>480LGp;jymP&{l6&wwafk+J1X|q^Ad~sj;514cr NJYD@<);T3K0RYj%Fn0g| literal 0 HcmV?d00001 diff --git a/frontend/cypress/e2e/main_window/monitor-ext.spec.ts b/frontend/cypress/e2e/main_window/monitor-ext.spec.ts new file mode 100644 index 000000000..b470ccc53 --- /dev/null +++ b/frontend/cypress/e2e/main_window/monitor-ext.spec.ts @@ -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') + }) +}) diff --git a/frontend/src/features/Semaphore/components/SearchSemaphoreButton/index.tsx b/frontend/src/features/Semaphore/components/SearchSemaphoreButton/index.tsx index 8668e2807..fa8fe3061 100644 --- a/frontend/src/features/Semaphore/components/SearchSemaphoreButton/index.tsx +++ b/frontend/src/features/Semaphore/components/SearchSemaphoreButton/index.tsx @@ -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) @@ -19,7 +19,7 @@ export function SearchSemaphoreButton() { } return ( - + {isSearchSemaphoreVisible && } only add child to BaseMap if it requires map or mapClickEvent + > + {/* @ts-ignore */} + + {/* @ts-ignore */} + + {/* @ts-ignore */} + + {/* @ts-ignore */} + + + {/* ZONE */} + {/* @ts-ignore */} + + {/* @ts-ignore */} + + {/* @ts-ignore */} + + {/* @ts-ignore */} + + {/* @ts-ignore */} + + {/* @ts-ignore */} + + {/* @ts-ignore */} + + + {/* MAP */} + {/* @ts-ignore */} + + {/* @ts-ignore */} + + + {/* SEMAPHORE */} + {/* @ts-ignore */} + + {/* @ts-ignore */} + + + ) + } + return ( } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} {/* @ts-ignore */} {/* @ts-ignore */} - {isSuperUser && } + {/* MISSION */} {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* SEMAPHORE */} {/* @ts-ignore */} @@ -120,31 +169,31 @@ export function Map({ isSuperUser, isVigilanceAreaEnabled }) { {/* @ts-ignore */} {/* @ts-ignore */} - + {/* REPORTING */} {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* @ts-ignore */} - {isSuperUser && } + {/* VIGILANCE AREA */} {/* @ts-ignore */} diff --git a/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx index 9d2496130..3e50e122a 100644 --- a/frontend/src/pages/HomePage.tsx +++ b/frontend/src/pages/HomePage.tsx @@ -113,7 +113,7 @@ export function HomePage() { {displayMissionMenuButton && isSuperUser && } {displayReportingsButton && isSuperUser && } - {displaySearchSemaphoreButton && } + {displaySearchSemaphoreButton && } {isRightMenuControlUnitListButtonVisible && isSuperUser && } {displayMeasurement && isSuperUser && }