Skip to content

Commit

Permalink
Update e2e tests data following stubs update
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Jan 16, 2024
1 parent eccd048 commit aff481b
Show file tree
Hide file tree
Showing 33 changed files with 2,031 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ context('Main Window > Control Unit List Dialog > Filters', () => {
})

it('Should show all control units by default', () => {
cy.getDataCy('ControlUnitListDialog-control-unit').should('have.length', 9)
cy.contains('BGC Lorient - DF 36 Kan An Avel').should('exist')
cy.getDataCy('ControlUnitListDialog-control-unit').should('have.length', 11)
cy.contains('PAM Jeanne Barret').should('exist')
cy.contains('ULAM 56').should('exist')
})

Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/missions/missions_overlay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ context('Missions overlay', () => {
it('An overlay Should be showed and closed', () => {
cy.get('#root').click(337, 819)

cy.get('*[data-cy="mission-overlay"]').contains('DML 2A')
cy.get('*[data-cy="mission-overlay"]').contains('BGC LORIENT')
cy.get('*[data-cy="mission-overlay"]').contains('Mission Air / Terre')
cy.get('*[data-cy="mission-overlay"]').contains('Aucun contact renseigné')
cy.get('*[data-cy="mission-overlay"]').contains('Ouverte par le CACEM')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,13 @@ context('Side Window > Mission Form > Land Control', () => {
{
administration: 'DDTM',
contact: null,
id: 10001,
id: 10499,
isArchived: false,
name: 'Cultures marines – DDTM 40',
name: 'Cultures marines 56',
resources: [
{
id: 2,
name: 'Semi-rigide 2'
id: 314,
name: 'Brezel - FAH 7185'
}
]
}
Expand Down
110 changes: 62 additions & 48 deletions frontend/cypress/e2e/side_window/mission_form/main_form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ context('Side Window > Mission Form > Main Form', () => {
cy.fill('Types de mission', ['Mer'])

cy.fill('Administration 1', 'DDTM')
cy.fill('Unité 1', 'Cultures marines – DDTM 40')
cy.fill('Unité 1', 'Cultures marines 56')

cy.get('@createMissionSpy').should('have.been.called')

Expand All @@ -49,9 +49,9 @@ context('Side Window > Mission Form > Main Form', () => {
{
administration: 'DDTM',
contact: null,
id: 10001,
id: 10499,
isArchived: false,
name: 'Cultures marines – DDTM 40',
name: 'Cultures marines 56',
resources: []
}
],
Expand Down Expand Up @@ -96,7 +96,7 @@ context('Side Window > Mission Form > Main Form', () => {
cy.fill('Types de mission', ['Mer'])

cy.fill('Administration 1', 'DDTM')
cy.fill('Unité 1', 'Cultures marines – DDTM 40')
cy.fill('Unité 1', 'Cultures marines 56')

cy.wait(500)

Expand Down Expand Up @@ -124,9 +124,9 @@ context('Side Window > Mission Form > Main Form', () => {
{
administration: 'DDTM',
contact: null,
id: 10001,
id: 10499,
isArchived: false,
name: 'Cultures marines – DDTM 40',
name: 'Cultures marines 56',
resources: []
}
],
Expand Down Expand Up @@ -167,26 +167,25 @@ context('Side Window > Mission Form > Main Form', () => {
cy.fill('Ordre de mission', 'Oui')

cy.fill('Administration 1', 'DDTM')
cy.fill('Unité 1', 'Cultures marines – DDTM 40')
cy.fill('Moyen 1', ['Semi-rigide 1'])
cy.fill('Unité 1', 'Cultures marines 56')
cy.fill('Moyen 1', ['Brezel - FAH 7185'])
cy.fill('Contact de l’unité 1', 'Bob')
cy.fill('Contact de l’unité 1', 'Bob')

cy.clickButton('Ajouter une autre unité')

cy.fill('Administration 2', 'DREAL')
cy.fill('Unité 2', 'DREAL Pays-de-La-Loire')
cy.fill('Moyen 2', ['ALTAIR', 'ARIOLA'])
cy.fill('Administration 2', 'Office Français de la Biodiversité')
cy.fill('Unité 2', 'OFB SD 56')
cy.fill('Moyen 2', ['Jean Armel', 'Kereon II'])
cy.fill('Contact de l’unité 2', 'Bob 2')

cy.fill('CACEM : orientations, observations', 'Une note.')
cy.fill('CNSP : orientations, observations', 'Une autre note.')
cy.fill('Ouvert par', 'Nemo')
cy.fill('Clôturé par', 'Doris')

cy.wait(500)

// Approx. 4 requests are sent to the server
cy.wait('@createMission')
cy.wait('@createMission')
cy.waitForLastRequest(
'@createMission',
{
Expand All @@ -196,30 +195,30 @@ context('Side Window > Mission Form > Main Form', () => {
{
administration: 'DDTM',
contact: 'Bob',
id: 10001,
id: 10499,
isArchived: false,
name: 'Cultures marines – DDTM 40',
name: 'Cultures marines 56',
resources: [
{
id: 1,
name: 'Semi-rigide 1'
id: 314,
name: 'Brezel - FAH 7185'
}
]
},
{
administration: 'DREAL',
administration: 'Office Français de la Biodiversité',
contact: 'Bob 2',
id: 10019,
id: 10338,
isArchived: false,
name: 'DREAL Pays-de-La-Loire',
name: 'OFB SD 56',
resources: [
{
id: 10,
name: 'ALTAIR'
id: 388,
name: 'Jean Armel – AY 894009'
},
{
id: 12,
name: 'ARIOLA'
id: 580,
name: 'Kereon II – AY 933119 K'
}
]
}
Expand Down Expand Up @@ -275,9 +274,9 @@ context('Side Window > Mission Form > Main Form', () => {
{
administration: 'Douane',
contact: null,
id: 10015,
id: 10484,
isArchived: false,
name: 'BGC Bastia',
name: 'BGC Lorient - DF 36 Kan An Avel',
resources: []
}
],
Expand Down Expand Up @@ -432,24 +431,34 @@ context('Side Window > Mission Form > Main Form', () => {

cy.fill('Clôturé par', 'Doris')

cy.wait(500)
cy.wait('@updateMission').wait(500)

cy.clickButton('Clôturer')

cy.waitForLastRequest(
'@updateMission',
{
body: {
// We check this prop to be sure all the data is there (this is the last field to be filled)
closedBy: 'Doris',
id: 2,
isClosed: true
}
},
5
)
.its('response.statusCode')
.should('eq', 201)
cy.wait('@updateMission').then(interception => {
if (!interception.response) {
assert.fail('`interception.response` is undefined.')
}

// assert.strictEqual(interception.response?.statusCode, 201)
assert.deepInclude(interception.request.body, {
// We check this prop to be sure all the data is there (this is the last field to be filled)
closedBy: 'Doris',
id: 2,
isClosed: true
})
})

// cy.wait('@updateMission').then(interception => {

// assert.strictEqual(interception.response?.statusCode, 201)
// assert.deepInclude(interception.request.body, {
// // We check this prop to be sure all the data is there (this is the last field to be filled)
// closedBy: 'Doris',
// id: 2,
// isClosed: true
// })
// })
})

it('Should show the cancellation confirmation dialog when switching to another menu while a draft is dirty', () => {
Expand Down Expand Up @@ -502,12 +511,17 @@ context('Side Window > Mission Form > Main Form', () => {
closedBy: 'Cynthia Phillips',
controlUnits: [
{
administration: 'DDTM',
administration: 'Gendarmerie Maritime',
contact: 'Bob',
id: 10003,
id: 10336,
isArchived: false,
name: 'DML 2A (historique)',
resources: [{ id: 3, name: 'Semi-rigide 1' }]
name: 'BSL Lorient',
resources: [
{
id: 90,
name: 'Voiture'
}
]
}
],
envActions: [],
Expand Down Expand Up @@ -613,8 +627,8 @@ context('Side Window > Mission Form > Main Form', () => {
it('Should show a warning indicating that a control unit is already engaged in a mission', () => {
openSideWindowNewMission()

cy.fill('Administration 1', 'DDTM')
cy.fill('Unité 1', 'DML 2A')
cy.fill('Administration 1', 'Gendarmerie Maritime')
cy.fill('Unité 1', 'BSL Lorient')

cy.get('body').should(
'contain',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,13 +595,13 @@ context('Side Window > Mission Form > Sea Control', () => {
{
administration: 'DDTM',
contact: null,
id: 10001,
id: 10499,
isArchived: false,
name: 'Cultures marines – DDTM 40',
name: 'Cultures marines 56',
resources: [
{
id: 2,
name: 'Semi-rigide 2'
id: 314,
name: 'Brezel - FAH 7185'
}
]
}
Expand Down Expand Up @@ -740,7 +740,7 @@ context('Side Window > Mission Form > Sea Control', () => {
// Remove the PAM control unit
cy.get('span[role="button"][title="Clear"]').eq(0).click({ force: true })
cy.get('span[role="button"][title="Clear"]').eq(1).click({ force: true })
cy.fill('Unité 1', 'Cultures marines – DDTM 40')
cy.fill('Unité 1', 'Cultures marines 56')

cy.get('legend')
.filter(':contains("Autre(s) contrôle(s) effectué(s) par l’unité sur le navire")')
Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/side_window/mission_form/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ export const fillSideWindowMissionFormBase = (
cy.fill('Mission sous JDP', true)

cy.fill('Administration 1', 'DDTM')
cy.fill('Unité 1', 'Cultures marines – DDTM 40')
cy.fill('Moyen 1', ['Semi-rigide 2'])
cy.fill('Unité 1', 'Cultures marines 56')
cy.fill('Moyen 1', ['Brezel - FAH 7185'])
}
22 changes: 10 additions & 12 deletions frontend/cypress/e2e/side_window/mission_list/filter_bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,32 @@ context('Side Window > Mission List > Filter Bar', () => {
})

it('Should filter missions by administration', () => {
cy.fill('Administration', ['DREAL'])
cy.fill('Administration', ['Douane'])

cy.get('[data-cy="mission-list-filter-tags"]').contains('DREAL')
cy.get('[data-cy="mission-list-filter-tags"]').contains('Douane')
// This filter does the filtering in the frontend
cy.get('.TableBodyRow').should('have.length', 1)
// Expected first row
cy.get('[data-id="43"]').should('exist')
cy.get('.TableBodyRow').should('have.length', 2)
cy.get('[data-id="25"]').should('exist')
cy.get('[data-id="6"]').should('exist')
})

it('Should filter missions by unit When an administration filter is set', () => {
cy.fill('Administration', ['Gendarmerie Maritime'])

cy.get('[data-cy="mission-list-filter-tags"]').contains('Gendarmerie Maritime')
cy.get('input[id="UNIT"]').parent().parent().parent().forceClick()
// There is only one unit in the unit select
cy.get('.rs-checkbox-checker > label').should('have.length', 1)
cy.get('.rs-checkbox-checker > label').contains('P602 Verdon').click({ force: true })

cy.get('.rs-checkbox-checker > label').should('have.length', 2)
cy.get('.rs-checkbox-checker > label').contains('BSL Lorient').click({ force: true })
// This filter does the filtering in the frontend
cy.get('.TableBodyRow').should('have.length', 0)
})

it('Should filter missions by unit', () => {
cy.fill('Unité', ['BGC Ajaccio'])
cy.fill('Unité', ['BGC Lorient'])

cy.get('[data-cy="mission-list-filter-tags"]').contains('BGC Ajaccio')
cy.get('[data-cy="mission-list-filter-tags"]').contains('BGC Lorient')
// This filter does the filtering in the frontend
cy.get('.TableBodyRow').should('have.length', 0)
cy.get('.TableBodyRow').should('have.length', 2)
})

it('Should filter missions by type', () => {
Expand Down
12 changes: 6 additions & 6 deletions frontend/cypress/e2e/vessel_sidebar/reporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ context('Vessel sidebar reporting tab', () => {

// Then
cy.get('*[data-cy="vessel-menu-reporting"]').contains(1)
cy.get('*[data-cy="reporting-card"]').eq(0).contains('Cross Etel / Sortie non autorisée')
cy.get('*[data-cy="reporting-card"]').eq(0).contains('OFB SD 56 / Sortie non autorisée')
cy.get('*[data-cy="reporting-card"]')
.eq(0)
.contains("Ce navire ne devrait pas être en mer, il n'a plus de points sur son permis")
Expand Down Expand Up @@ -67,7 +67,7 @@ context('Vessel sidebar reporting tab', () => {
cy.get('[data-cy="new-reporting-select-observation-reporting-type"]').click()
cy.get('*[data-cy="new-reporting-reporting-actor-UNIT"]').click()
cy.get('*[data-cy="new-reporting-select-unit"]').click()
cy.get('[data-key="10012"] > .rs-picker-select-menu-item').click({ force: true })
cy.get('[data-key="10338"] > .rs-picker-select-menu-item').click({ force: true })
cy.get('*[data-cy="new-reporting-author-contact"]').type('Jean Bon (0612365896)')
cy.get('*[data-cy="new-reporting-title"]').type('Observation: Sortie non autorisée')
cy.get('*[data-cy="new-reporting-description"]').type(
Expand Down Expand Up @@ -112,7 +112,7 @@ context('Vessel sidebar reporting tab', () => {

createReporting()

cy.get('*[data-cy="reporting-card"]').eq(0).contains('Cross Etel / Sortie non autorisée')
cy.get('*[data-cy="reporting-card"]').eq(0).contains('OFB SD 56 / Sortie non autorisée')
cy.get('*[data-cy="reporting-card"]').eq(0).contains('NATINF 2608')
cy.get('*[data-cy="archive-reporting-card"]').eq(0).click()

Expand All @@ -121,7 +121,7 @@ context('Vessel sidebar reporting tab', () => {
cy.get('*[data-cy="vessel-sidebar-reporting-tab-history-button"]').click()
cy.get('*[data-cy="vessel-sidebar-reporting-tab-history"]').should('exist')
cy.get('*[data-cy="vessel-sidebar-reporting-tab-archive-year"]').eq(0).click()
cy.get('*[data-cy="reporting-card"]').eq(0).contains('Cross Etel / Sortie non autorisée')
cy.get('*[data-cy="reporting-card"]').eq(0).contains('OFB SD 56 / Sortie non autorisée')
cy.get('*[data-cy^="vessel-search-selected-vessel-close-title"]', { timeout: 10000 }).click()
})

Expand All @@ -145,7 +145,7 @@ context('Vessel sidebar reporting tab', () => {

// When
cy.get('*[data-cy="vessel-menu-reporting"]').contains(1)
cy.get('*[data-cy="reporting-card"]').eq(0).contains('Cross Etel / Sortie non autorisée')
cy.get('*[data-cy="reporting-card"]').eq(0).contains('OFB SD 56 / Sortie non autorisée')
cy.get('*[data-cy="delete-reporting-card"]').eq(0).click()
// First, we do not confirm the reporting deletion
cy.get('*[data-cy="close-reporting-deletion-modal"]').click()
Expand All @@ -161,7 +161,7 @@ context('Vessel sidebar reporting tab', () => {
cy.get('*[data-cy="vessel-sidebar-open-reporting"]').click()
cy.get('*[data-cy="new-reporting-reporting-actor-UNIT"]').click()
cy.get('*[data-cy="new-reporting-select-unit"]').click()
cy.get('[data-key="10012"] > .rs-picker-select-menu-item').click({ force: true })
cy.get('[data-key="10338"] > .rs-picker-select-menu-item').click({ force: true })
cy.get('*[data-cy="new-reporting-author-contact"]').type('Jean Bon (0612365896)')
cy.get('*[data-cy="new-reporting-title"]').type('Sortie non autorisée')
cy.get('*[data-cy="new-reporting-description"]').type(
Expand Down
Loading

0 comments on commit aff481b

Please sign in to comment.