Skip to content

Commit

Permalink
Fix Cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Jul 11, 2023
1 parent 53b5834 commit f6f9578
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions frontend/cypress/e2e/vessel_sidebar/controls.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ context('Vessel sidebar controls tab', () => {
.contains(`CONTRÔLE EN MER DU ${getDate(yearBeforeMinusOneMonth.toISOString())}`)
})

it('A control mission Should be opened', () => {
it('A control mission Should be opened in the side window', () => {
// Given
cy.get('.VESSELS_POINTS').click(460, 480, { force: true, timeout: 10000 })
cy.wait(200)
Expand All @@ -116,8 +116,13 @@ context('Vessel sidebar controls tab', () => {
cy.get('*[data-cy="vessel-controls-year"]').first().click({ timeout: 10000 })

// Click on Modify mission button
cy.intercept('http://localhost:8081/api/v1/missions/2').as('openMission')
cy.window().then(win => {
cy.stub(win, 'open', () => {
// eslint-disable-next-line no-param-reassign
win.location.href = '/side_window'
}).as('side_window')
})
cy.clickButton('Modifier le CR du contrôle')
cy.wait('@openMission')
cy.get('@side_window').should('be.called')
})
})
2 changes: 1 addition & 1 deletion frontend/src/api/APIWorker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function APIWorker() {
} else if (vesselSidebarTab === VesselSidebarTab.CONTROLS) {
dispatch(getVesselControls(false))
} else if (vesselSidebarTab === VesselSidebarTab.REPORTING) {
dispatch(getVesselReportings(true))
dispatch(getVesselReportings(false))
} else if (isSuperUser && vesselSidebarTab === VesselSidebarTab.ERSVMS) {
dispatch(getVesselBeaconMalfunctions(false))
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/domain/use_cases/alert/validateAlert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export const validateAlert =

validateAlertFromAPI(id)
.then(() => {
// We dispatch this action to update the reportings list
// We dispatch this action to update the reporting list
// since it depends on the the alerts list that we just updated
dispatch(getVesselReportings(false))
dispatch(getVesselReportings(true))

const validatedAlert = previousAlertsWithValidatedFlag.find(alert => alert.id === id)
if (!validatedAlert) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domain/use_cases/error/displayOrLogError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { RetryableUseCase } from '../../../libs/DisplayedError'

/**
* Dispatch:
* - A displayedError to be shown in the vessel sidebar if the use-case was triggered by the user
* - A toast error if the use-case was triggered by the cron
* - A displayedError to be shown in the vessel sidebar if the use-case was triggered by the user
*/
export const displayOrLogError =
(
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/VesselSidebar/Reportings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function Reportings() {
const previousSelectedVesselIdentity = usePrevious(selectedVesselIdentity)

useEffect(() => {
dispatch(getVesselReportings(false))
dispatch(getVesselReportings(true))
}, [dispatch, selectedVesselIdentity])

useEffect(() => {
Expand Down

0 comments on commit f6f9578

Please sign in to comment.