-
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 tests for reporting list actions in pno forms
- Loading branch information
1 parent
1a7fa70
commit cf679a1
Showing
4 changed files
with
301 additions
and
1 deletion.
There are no files selected for viewing
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
129 changes: 129 additions & 0 deletions
129
frontend/cypress/e2e/side_window/logbook_prior_notification_form/reporting_list.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,129 @@ | ||
import { createReportingFromPriorNotificationForm, editSideWindowPriorNotification } from './utils' | ||
import { deleteReporting } from '../../main_window/vessel_sidebar/utils' | ||
|
||
import type { Reporting } from '@features/Reporting/types' | ||
|
||
context('Side Window > Logbook Prior Notification Form > Reporting List', () => { | ||
it('Should create a reporting', () => { | ||
cy.intercept('GET', '/bff/v1/vessels/reportings?*').as('getVesselReportings') | ||
cy.intercept('POST', '/bff/v1/reportings').as('createReporting') | ||
|
||
// Given | ||
editSideWindowPriorNotification('LE POISSON AMBULANT', 'FAKE_OPERATION_112_COR_ORPHAN') | ||
|
||
cy.clickButton('Ouvrir un signalement sur le navire') | ||
cy.wait('@getVesselReportings') | ||
|
||
// When | ||
cy.fill('Origine', 'Unité') | ||
cy.fill("Choisir l'unité", 'OFB SD 56 (Office Français de la Biodiversité)') | ||
cy.fill('Nom et contact (numéro, mail…) de l’émetteur', 'Jean Bon (0612365896)') | ||
cy.fill('Titre', 'Sortie non autorisée') | ||
cy.fill('Description', 'Ce navire ne devrait pas être en mer.') | ||
cy.fill('Natinf', '2608') | ||
cy.fill('Saisi par', 'LTH', { index: 1 }) | ||
|
||
cy.clickButton('Valider') | ||
|
||
cy.wait('@createReporting').then(createInterception => { | ||
if (!createInterception.response) { | ||
assert.fail('`createInterception.response` is undefined.') | ||
} | ||
|
||
const createdPriorNotification: Reporting.Reporting = createInterception.response.body | ||
|
||
// Then | ||
cy.getDataCy('reporting-card').should('have.length', 1) | ||
cy.getDataCy('reporting-card').eq(0).contains('OFB SD 56 / Sortie non autorisée') | ||
cy.getDataCy('reporting-card').eq(0).contains('Ce navire ne devrait pas être en mer.') | ||
cy.getDataCy('reporting-card').eq(0).contains('Émetteur: Jean Bon (0612365896)') | ||
cy.getDataCy('reporting-card').eq(0).contains('NATINF 2608') | ||
|
||
// Reset | ||
deleteReporting(createdPriorNotification.id) | ||
}) | ||
}) | ||
|
||
it('Should edit a reporting', () => { | ||
// Given | ||
createReportingFromPriorNotificationForm('LE POISSON AMBULANT', 'FAKE_OPERATION_112_COR_ORPHAN').then( | ||
createdReportingId => { | ||
cy.intercept('PUT', `/bff/v1/reportings/${createdReportingId}/update`).as('updateReporting') | ||
|
||
cy.getDataCy('reporting-card').should('have.length', 1) | ||
|
||
// When | ||
cy.clickButton('Éditer ce signalement') | ||
|
||
cy.fill('Origine', 'Unité') | ||
cy.fill("Choisir l'unité", 'OFB SD 56 (Office Français de la Biodiversité)') | ||
cy.fill('Nom et contact (numéro, mail…) de l’émetteur', 'Jean Bon (0612365896)') | ||
cy.fill('Titre', 'Sortie non autorisée') | ||
cy.fill('Description', 'Ce navire ne devrait pas être en mer.') | ||
cy.fill('Natinf', '2608') | ||
cy.fill('Saisi par', 'LTH', { index: 1 }) | ||
|
||
cy.clickButton('Valider') | ||
|
||
cy.wait('@updateReporting') | ||
|
||
// Then | ||
cy.getDataCy('reporting-card').should('have.length', 1) | ||
cy.getDataCy('reporting-card').eq(0).contains('OFB SD 56 / Sortie non autorisée') | ||
cy.getDataCy('reporting-card').eq(0).contains('Ce navire ne devrait pas être en mer.') | ||
cy.getDataCy('reporting-card').eq(0).contains('Émetteur: Jean Bon (0612365896)') | ||
cy.getDataCy('reporting-card').eq(0).contains('NATINF 2608') | ||
|
||
// Reset | ||
deleteReporting(createdReportingId) | ||
} | ||
) | ||
}) | ||
|
||
it('Should archive a reporting', () => { | ||
// Given | ||
createReportingFromPriorNotificationForm('LE POISSON AMBULANT', 'FAKE_OPERATION_112_COR_ORPHAN').then( | ||
createdReportingId => { | ||
cy.intercept('PUT', `/bff/v1/reportings/${createdReportingId}/archive`).as('archiveReporting') | ||
|
||
cy.getDataCy('reporting-card').should('have.length', 1) | ||
|
||
// When | ||
cy.clickButton('Archiver ce signalement') | ||
|
||
cy.wait('@archiveReporting') | ||
|
||
// Then | ||
cy.getDataCy('reporting-card').should('have.length', 0) | ||
|
||
// Reset | ||
deleteReporting(createdReportingId) | ||
} | ||
) | ||
}) | ||
|
||
it('Should delete a reporting', () => { | ||
// Given | ||
createReportingFromPriorNotificationForm('LE POISSON AMBULANT', 'FAKE_OPERATION_112_COR_ORPHAN').then( | ||
createdReportingId => { | ||
cy.intercept('PUT', `/bff/v1/reportings/${createdReportingId}/delete`).as('deleteReporting') | ||
|
||
cy.getDataCy('reporting-card').should('have.length', 1) | ||
|
||
// When | ||
cy.clickButton('Supprimer ce signalement') | ||
|
||
// Then | ||
cy.contains('Voulez-vous supprimer le signalement ?').should('be.visible') | ||
|
||
// When | ||
cy.clickButton('Oui') | ||
|
||
cy.wait('@deleteReporting') | ||
|
||
// Then | ||
cy.getDataCy('reporting-card').should('have.length', 0) | ||
} | ||
) | ||
}) | ||
}) |
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
132 changes: 132 additions & 0 deletions
132
frontend/cypress/e2e/side_window/manual_prior_notification_form/reporting_list.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,132 @@ | ||
import { deleteReporting } from '../../main_window/vessel_sidebar/utils' | ||
import { | ||
createReportingFromPriorNotificationForm, | ||
editSideWindowPriorNotification | ||
} from '../logbook_prior_notification_form/utils' | ||
|
||
import type { Reporting } from '@features/Reporting/types' | ||
|
||
context('Side Window > Manual Prior Notification Form > Reporting List', () => { | ||
it('Should create a reporting', () => { | ||
cy.intercept('GET', '/bff/v1/vessels/reportings?*').as('getVesselReportings') | ||
cy.intercept('POST', '/bff/v1/reportings').as('createReporting') | ||
|
||
// Given | ||
editSideWindowPriorNotification('POISSON PAS NET', '00000000-0000-4000-0000-000000000001') | ||
|
||
cy.clickButton('Ouvrir un signalement sur le navire') | ||
cy.wait('@getVesselReportings') | ||
|
||
// When | ||
cy.fill('Origine', 'Unité') | ||
cy.fill("Choisir l'unité", 'OFB SD 56 (Office Français de la Biodiversité)') | ||
cy.fill('Nom et contact (numéro, mail…) de l’émetteur', 'Jean Bon (0612365896)') | ||
cy.fill('Titre', 'Sortie non autorisée') | ||
cy.fill('Description', 'Ce navire ne devrait pas être en mer.') | ||
cy.fill('Natinf', '2608') | ||
cy.fill('Saisi par', 'LTH', { index: 1 }) | ||
|
||
cy.clickButton('Valider') | ||
|
||
cy.wait('@createReporting').then(createInterception => { | ||
if (!createInterception.response) { | ||
assert.fail('`createInterception.response` is undefined.') | ||
} | ||
|
||
const createdPriorNotification: Reporting.Reporting = createInterception.response.body | ||
|
||
// Then | ||
cy.getDataCy('reporting-card').should('have.length', 1) | ||
cy.getDataCy('reporting-card').eq(0).contains('OFB SD 56 / Sortie non autorisée') | ||
cy.getDataCy('reporting-card').eq(0).contains('Ce navire ne devrait pas être en mer.') | ||
cy.getDataCy('reporting-card').eq(0).contains('Émetteur: Jean Bon (0612365896)') | ||
cy.getDataCy('reporting-card').eq(0).contains('NATINF 2608') | ||
|
||
// Reset | ||
deleteReporting(createdPriorNotification.id) | ||
}) | ||
}) | ||
|
||
it('Should edit a reporting', () => { | ||
// Given | ||
createReportingFromPriorNotificationForm('POISSON PAS NET', '00000000-0000-4000-0000-000000000001').then( | ||
createdReportingId => { | ||
cy.intercept('PUT', `/bff/v1/reportings/${createdReportingId}/update`).as('updateReporting') | ||
|
||
cy.getDataCy('reporting-card').should('have.length', 1) | ||
|
||
// When | ||
cy.clickButton('Éditer ce signalement') | ||
|
||
cy.fill('Origine', 'Unité') | ||
cy.fill("Choisir l'unité", 'OFB SD 56 (Office Français de la Biodiversité)') | ||
cy.fill('Nom et contact (numéro, mail…) de l’émetteur', 'Jean Bon (0612365896)') | ||
cy.fill('Titre', 'Sortie non autorisée') | ||
cy.fill('Description', 'Ce navire ne devrait pas être en mer.') | ||
cy.fill('Natinf', '2608') | ||
cy.fill('Saisi par', 'LTH', { index: 1 }) | ||
|
||
cy.clickButton('Valider') | ||
|
||
cy.wait('@updateReporting') | ||
|
||
// Then | ||
cy.getDataCy('reporting-card').should('have.length', 1) | ||
cy.getDataCy('reporting-card').eq(0).contains('OFB SD 56 / Sortie non autorisée') | ||
cy.getDataCy('reporting-card').eq(0).contains('Ce navire ne devrait pas être en mer.') | ||
cy.getDataCy('reporting-card').eq(0).contains('Émetteur: Jean Bon (0612365896)') | ||
cy.getDataCy('reporting-card').eq(0).contains('NATINF 2608') | ||
|
||
// Reset | ||
deleteReporting(createdReportingId) | ||
} | ||
) | ||
}) | ||
|
||
it('Should archive a reporting', () => { | ||
// Given | ||
createReportingFromPriorNotificationForm('POISSON PAS NET', '00000000-0000-4000-0000-000000000001').then( | ||
createdReportingId => { | ||
cy.intercept('PUT', `/bff/v1/reportings/${createdReportingId}/archive`).as('archiveReporting') | ||
|
||
cy.getDataCy('reporting-card').should('have.length', 1) | ||
|
||
// When | ||
cy.clickButton('Archiver ce signalement') | ||
|
||
cy.wait('@archiveReporting') | ||
|
||
// Then | ||
cy.getDataCy('reporting-card').should('have.length', 0) | ||
|
||
// Reset | ||
deleteReporting(createdReportingId) | ||
} | ||
) | ||
}) | ||
|
||
it('Should delete a reporting', () => { | ||
// Given | ||
createReportingFromPriorNotificationForm('POISSON PAS NET', '00000000-0000-4000-0000-000000000001').then( | ||
createdReportingId => { | ||
cy.intercept('PUT', `/bff/v1/reportings/${createdReportingId}/delete`).as('deleteReporting') | ||
|
||
cy.getDataCy('reporting-card').should('have.length', 1) | ||
|
||
// When | ||
cy.clickButton('Supprimer ce signalement') | ||
|
||
// Then | ||
cy.contains('Voulez-vous supprimer le signalement ?').should('be.visible') | ||
|
||
// When | ||
cy.clickButton('Oui') | ||
|
||
cy.wait('@deleteReporting') | ||
|
||
// Then | ||
cy.getDataCy('reporting-card').should('have.length', 0) | ||
} | ||
) | ||
}) | ||
}) |