-
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.
Add e2e test for manual prior notification form freeze during send [WIP]
- Loading branch information
1 parent
b194441
commit 1edaa27
Showing
22 changed files
with
482 additions
and
388 deletions.
There are no files selected for viewing
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') | ||
} | ||
} |
Oops, something went wrong.