-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Préavis – Prévenir le risque de race condition entre la sauvegarde et…
… la diffusion par la pipeline pendant l'envoi (#3544) ## Linked issues - Resolve #3538 - Resolve #3419 ---- - [x] Tests E2E (Cypress)
- Loading branch information
Showing
28 changed files
with
524 additions
and
432 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
frontend/cypress/e2e/side_window/logbook_prior_notification_card/behavior.spec.ts
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,15 @@ | ||
import { editSideWindowPriorNotification } from '../logbook_prior_notification_form/utils' | ||
|
||
context('Side Window > Logbook Prior Notification Form > Behavior', () => { | ||
it("Should show a banner, freeze the logbook prior notification form and button when it's in pending send", () => { | ||
editSideWindowPriorNotification(`DES BARS`, 'FAKE_OPERATION_107') | ||
|
||
cy.get('.Component-Banner').contains(`Le préavis est en cours de diffusion.`) | ||
|
||
cy.get('textarea[name=note]').should('have.attr', 'readonly') | ||
cy.get('input[name=authorTrigram]').should('have.attr', 'readonly') | ||
|
||
cy.contains('button', 'Télécharger').should('be.disabled') | ||
cy.contains('button', 'Diffuser').should('be.disabled') | ||
}) | ||
}) |
118 changes: 118 additions & 0 deletions
118
frontend/cypress/e2e/side_window/logbook_prior_notification_card/card.spec.ts
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,118 @@ | ||
import { PriorNotification } from '@features/PriorNotification/PriorNotification.types' | ||
|
||
import { openSideWindowPriorNotificationCardAsUser } from './utils' | ||
|
||
context('Side Window > Logbook Prior Notification Card > Card', () => { | ||
it('Should display a logbook prior notification corrected message as expected', () => { | ||
openSideWindowPriorNotificationCardAsUser(`L'ANCRE`, 'FAKE_OPERATION_109_COR') | ||
|
||
// Title | ||
cy.contains(`Préavis navire < 12 M`).should('be.visible') | ||
cy.contains(`L'ANCRE SÈCHE (CFR106)`).should('be.visible') | ||
|
||
// Message Header | ||
cy.contains(`PNO`).should('be.visible') | ||
cy.contains(`Préavis (notification de retour au port)`).should('be.visible') | ||
cy.contains(`MESSAGE CORRIGÉ`).should('be.visible') | ||
|
||
// Message Body | ||
cy.contains(`Vannes (FRVNE)`).should('be.visible') | ||
cy.contains(`Débarquement (LAN)`).should('be.visible') | ||
cy.contains(`BATHYBATES FEROX (BHX)`).should('be.visible') | ||
cy.contains(`32.5 kg`).should('be.visible') | ||
}) | ||
|
||
it('Should display a logbook prior notification successfully acknowledged message as expected', () => { | ||
openSideWindowPriorNotificationCardAsUser(`BARS`, 'FAKE_OPERATION_107') | ||
|
||
// Title | ||
cy.contains(`Préavis navire ≥ 12 M`).should('be.visible') | ||
cy.contains(`DES BARS (CFR104)`).should('be.visible') | ||
|
||
// Message Header | ||
cy.contains(`PNO`).should('be.visible') | ||
cy.contains(`Préavis (notification de retour au port)`).should('be.visible') | ||
|
||
// Message Body | ||
cy.getDataCy('LogbookMessage-successful-acknowledgement-icon').should('be.visible') | ||
cy.contains(`Saint-Malo (FRSML)`).should('be.visible') | ||
cy.contains(`Débarquement (LAN)`).should('be.visible') | ||
cy.contains(`MORUE COMMUNE (CABILLAUD) (COD)`).should('be.visible') | ||
cy.contains(`25 kg`).should('be.visible') | ||
}) | ||
|
||
it('Should refresh the list when the opened logbook prior notification data differs from its entry in the current list', () => { | ||
const url = '/bff/v1/prior_notifications/FAKE_OPERATION_109_COR?isManuallyCreated=false&operationDate=*' | ||
|
||
cy.intercept({ | ||
method: 'GET', | ||
times: 1, | ||
url | ||
}).as('getOriginalPriorNotification') | ||
|
||
openSideWindowPriorNotificationCardAsUser(`L'ANCRE`, 'FAKE_OPERATION_109_COR') | ||
|
||
cy.wait('@getOriginalPriorNotification').then(interception => { | ||
const originalPriorNotificationDetail: PriorNotification.Detail = interception.response!.body | ||
const updatedPriorNotificationDetailStub: PriorNotification.Detail = { | ||
...originalPriorNotificationDetail, | ||
fingerprint: '109.1109.2109' | ||
} | ||
|
||
cy.reload() | ||
|
||
cy.fill('Rechercher un navire', `L'ANCRE`) | ||
|
||
cy.intercept('GET', url, { body: updatedPriorNotificationDetailStub }).as('getUpdatedPriorNotification') | ||
cy.intercept('GET', '/bff/v1/prior_notifications?*').as('getPriorNotifications') | ||
|
||
cy.getTableRowById('FAKE_OPERATION_109_COR').clickButton('Consulter le préavis') | ||
|
||
cy.wait('@getUpdatedPriorNotification') | ||
cy.wait('@getPriorNotifications') | ||
|
||
cy.contains(`L'ANCRE SÈCHE (CFR106)`).should('be.visible') | ||
}) | ||
}) | ||
|
||
it('Should display a warning banner and refresh the list when the opened logbook prior notification has been deleted', () => { | ||
const url = '/bff/v1/prior_notifications/FAKE_OPERATION_109_COR?isManuallyCreated=false&operationDate=*' | ||
|
||
cy.intercept({ | ||
method: 'GET', | ||
times: 1, | ||
url | ||
}).as('getOriginalPriorNotification') | ||
|
||
openSideWindowPriorNotificationCardAsUser(`L'ANCRE`, 'FAKE_OPERATION_109_COR') | ||
|
||
cy.wait('@getOriginalPriorNotification').then(interception => { | ||
const originalPriorNotificationDetail: PriorNotification.Detail = interception.response!.body | ||
const deletedPriorNotificationDetailStub: PriorNotification.Detail = { | ||
...originalPriorNotificationDetail, | ||
fingerprint: '109.1109.2109', | ||
logbookMessage: { | ||
...originalPriorNotificationDetail.logbookMessage, | ||
isDeleted: true | ||
} | ||
} | ||
|
||
cy.reload() | ||
|
||
cy.fill('Rechercher un navire', `L'ANCRE`) | ||
|
||
cy.intercept('GET', url, { body: deletedPriorNotificationDetailStub }).as('getDeletedPriorNotification') | ||
cy.intercept('GET', '/bff/v1/prior_notifications?*').as('getPriorNotifications') | ||
|
||
cy.clickButton('Consulter le préavis') | ||
|
||
cy.wait('@getDeletedPriorNotification') | ||
cy.wait('@getPriorNotifications') | ||
|
||
// The warning banner should be displayed | ||
cy.contains(`Ce préavis a été supprimé (entre temps).`).should('be.visible') | ||
// The card should be closed | ||
cy.contains(`L'ANCRE SÈCHE (CFR106)`).should('not.exist') | ||
}) | ||
}) | ||
}) |
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
16 changes: 16 additions & 0 deletions
16
frontend/cypress/e2e/side_window/logbook_prior_notification_card/utils.ts
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,16 @@ | ||
import { openSideWindowPriorNotificationListAsUser } from '../prior_notification_list/utils' | ||
|
||
// Cards can only be opened as User, SuperUser open them as forms | ||
export const openSideWindowPriorNotificationCardAsUser = (vesselName: string, reportId: string) => { | ||
openSideWindowPriorNotificationListAsUser() | ||
|
||
cy.get('.Table-SimpleTable tr').should('have.length.to.be.greaterThan', 0) | ||
|
||
cy.get('[data-cy="side-window-sub-menu-ALL"]').click() | ||
cy.fill('Rechercher un navire', vesselName) | ||
|
||
cy.getTableRowById(reportId as any).clickButton('Consulter le préavis') | ||
if (document.querySelector('[data-cy="first-loader"]')) { | ||
cy.getDataCy('first-loader').should('not.be.visible') | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
frontend/cypress/e2e/side_window/logbook_prior_notification_form/error_handling.spec.ts
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
14 changes: 14 additions & 0 deletions
14
frontend/cypress/e2e/side_window/logbook_prior_notification_form/utils.ts
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,14 @@ | ||
import { openSideWindowPriorNotificationListAsSuperUser } from '../prior_notification_list/utils' | ||
|
||
// Both logbook and manual prior notifications | ||
export const editSideWindowPriorNotification = (vesselName: string, reportId: string) => { | ||
openSideWindowPriorNotificationListAsSuperUser() | ||
|
||
cy.get('[data-cy="side-window-sub-menu-ALL"]').click() | ||
cy.fill('Rechercher un navire', vesselName) | ||
|
||
cy.getTableRowById(reportId).clickButton('Éditer le préavis') | ||
if (document.querySelector('[data-cy="first-loader"]')) { | ||
cy.getDataCy('first-loader').should('not.be.visible') | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
frontend/cypress/e2e/side_window/manual_prior_notification_card/card.spec.ts
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,54 @@ | ||
import { PriorNotification } from '@features/PriorNotification/PriorNotification.types' | ||
|
||
import { openSideWindowPriorNotificationCardAsUser } from '../logbook_prior_notification_card/utils' | ||
|
||
context('Side Window > Manual Prior Notification Card > Card', () => { | ||
it('Should display a read-only manual prior notification form', () => { | ||
openSideWindowPriorNotificationCardAsUser(`POISSON PAS NET`, '00000000-0000-4000-0000-000000000001') | ||
|
||
// Title | ||
cy.contains(`Préavis navire < 12 M`).should('be.visible') | ||
cy.contains(`POISSON PAS NET (CFR112)`).should('be.visible') | ||
|
||
// Message Header | ||
cy.contains(`Préavis (notification de retour au port) – navire sans JPE`).should('be.visible') | ||
|
||
// Message Body | ||
cy.contains(`Filets soulevés portatifs (LNP)`).should('be.visible') | ||
}) | ||
|
||
it('Should refresh the list when the opened manual prior notification data differs from its entry in the current list', () => { | ||
const url = | ||
'/bff/v1/prior_notifications/00000000-0000-4000-0000-000000000001?isManuallyCreated=true&operationDate=*' | ||
|
||
cy.intercept({ | ||
method: 'GET', | ||
times: 1, | ||
url | ||
}).as('getOriginalPriorNotification') | ||
|
||
openSideWindowPriorNotificationCardAsUser(`POISSON PAS NET`, '00000000-0000-4000-0000-000000000001') | ||
|
||
cy.wait('@getOriginalPriorNotification').then(interception => { | ||
const originalPriorNotificationDetail: PriorNotification.Detail = interception.response!.body | ||
const updatedPriorNotificationDetailStub: PriorNotification.Detail = { | ||
...originalPriorNotificationDetail, | ||
fingerprint: '109.1109.2109' | ||
} | ||
|
||
cy.reload() | ||
|
||
cy.fill('Rechercher un navire', `POISSON`) | ||
|
||
cy.intercept('GET', url, { body: updatedPriorNotificationDetailStub }).as('getUpdatedPriorNotification') | ||
cy.intercept('GET', '/bff/v1/prior_notifications?*').as('getPriorNotifications') | ||
|
||
cy.getTableRowById('00000000-0000-4000-0000-000000000001').clickButton('Consulter le préavis') | ||
|
||
cy.wait('@getUpdatedPriorNotification') | ||
cy.wait('@getPriorNotifications') | ||
|
||
cy.contains(`POISSON PAS NET (CFR112)`).should('be.visible') | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.