-
Notifications
You must be signed in to change notification settings - Fork 1
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 control unit dialog
- Loading branch information
1 parent
fafe1ae
commit bbda84f
Showing
20 changed files
with
390 additions
and
67 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ffice/administration_list/filters.spec.ts → ...fice/administration_table/filters.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
2 changes: 1 addition & 1 deletion
2
...e/administration_list/row_actions.spec.ts → .../administration_table/row_actions.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
2 changes: 1 addition & 1 deletion
2
...e2e/back_office/base_list/filters.spec.ts → ...2e/back_office/base_table/filters.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
2 changes: 1 addition & 1 deletion
2
..._office/control_unit_list/filters.spec.ts → ...office/control_unit_table/filters.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
2 changes: 1 addition & 1 deletion
2
...ice/control_unit_list/row_actions.spec.ts → ...ce/control_unit_table/row_actions.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
98 changes: 98 additions & 0 deletions
98
frontend/cypress/e2e/main_window/control_unit_dialog/contact_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,98 @@ | ||
import { gotToMainWindowAndOpenControlUnit } from './utils' | ||
|
||
context('Main Window > Control Unit Dialog > Contact List', () => { | ||
beforeEach(() => { | ||
gotToMainWindowAndOpenControlUnit(10000) | ||
}) | ||
|
||
it('Should show all contacts by default', () => { | ||
cy.contains('Contact 1').should('be.visible') | ||
cy.contains('Contact 2').should('be.visible') | ||
}) | ||
|
||
it('Should validate the form', () => { | ||
cy.clickButton('Ajouter un contact') | ||
|
||
cy.clickButton('Ajouter') | ||
|
||
cy.contains('Veuillez choisir un nom.').should('be.visible') | ||
cy.contains('Veuillez entrer un téléphone ou un email.').should('be.visible') | ||
|
||
cy.clickButton('Annuler') | ||
|
||
cy.get('p').contains('Ajouter un contact').should('not.exist') | ||
}) | ||
|
||
it('Should add, edit and delete a contact', () => { | ||
// ------------------------------------------------------------------------- | ||
// Create | ||
|
||
cy.intercept('POST', `/api/v1/control_unit_contacts`).as('createControlUnitContact') | ||
|
||
cy.clickButton('Ajouter un contact') | ||
|
||
cy.fill('Nom du contact', 'Adjoint') | ||
cy.fill('Numéro de téléphone', '0123456789') | ||
cy.fill('Adresse mail', '[email protected]') | ||
|
||
cy.clickButton('Ajouter') | ||
|
||
cy.wait('@createControlUnitContact').then(interception => { | ||
if (!interception.response) { | ||
assert.fail('`interception.response` is undefined.') | ||
} | ||
|
||
assert.deepInclude(interception.request.body, { | ||
email: '[email protected]', | ||
name: 'ADJUNCT', | ||
phone: '0123456789' | ||
}) | ||
}) | ||
|
||
cy.get('p').contains('Ajouter un contact').should('not.exist') | ||
cy.contains('Adjoint').should('be.visible') | ||
|
||
// ------------------------------------------------------------------------- | ||
// Edit | ||
|
||
cy.intercept('PUT', `/api/v1/control_unit_contacts/4`).as('updateControlUnitContact') | ||
|
||
cy.getDataCy('ControlUnitDialog-control-unit-contact').filter('[data-id="4"]').clickButton('Éditer ce contact') | ||
|
||
cy.fill('Nom du contact', 'Passerelle') | ||
cy.fill('Numéro de téléphone', '9876543210') | ||
cy.fill('Adresse mail', '[email protected]') | ||
|
||
cy.clickButton('Enregistrer les modifications') | ||
|
||
cy.wait('@updateControlUnitContact').then(interception => { | ||
if (!interception.response) { | ||
assert.fail('`interception.response` is undefined.') | ||
} | ||
|
||
assert.deepInclude(interception.request.body, { | ||
email: '[email protected]', | ||
id: 4, | ||
name: 'BRIDGE', | ||
phone: '9876543210' | ||
}) | ||
}) | ||
|
||
cy.get('p').contains('Éditer un contact').should('not.exist') | ||
cy.contains('Enregistrer les modifications').should('not.exist') | ||
cy.contains('Passerelle').should('be.visible') | ||
|
||
// ------------------------------------------------------------------------- | ||
// Delete | ||
|
||
cy.intercept('DELETE', `/api/v1/control_unit_contacts/4`).as('deleteControlUnitContact') | ||
|
||
cy.getDataCy('ControlUnitDialog-control-unit-contact').filter('[data-id="4"]').clickButton('Éditer ce contact') | ||
cy.clickButton('Supprimer ce contact') | ||
cy.clickButton('Supprimer') | ||
|
||
cy.wait('@deleteControlUnitContact') | ||
|
||
cy.contains('Passerelle').should('not.exist') | ||
}) | ||
}) |
57 changes: 57 additions & 0 deletions
57
frontend/cypress/e2e/main_window/control_unit_dialog/form.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,57 @@ | ||
import { gotToMainWindowAndOpenControlUnit } from './utils' | ||
|
||
context('Main Window > Control Unit Dialog > Resource List', () => { | ||
beforeEach(() => { | ||
gotToMainWindowAndOpenControlUnit(10000) | ||
}) | ||
|
||
it('Should edit a control unit', () => { | ||
cy.intercept('PUT', `/api/v2/control_units/10000`).as('updateControlUnit') | ||
|
||
// ------------------------------------------------------------------------- | ||
// Terms note | ||
|
||
cy.getDataCy('ControlUnitDialog-termsNote').forceClick() | ||
|
||
cy.fill('Modalités de contact avec l’unité', 'Des modalités de contact avec l’unité.') | ||
|
||
cy.clickButton('Valider') | ||
|
||
cy.wait('@updateControlUnit').then(interception => { | ||
if (!interception.response) { | ||
assert.fail('`interception.response` is undefined.') | ||
} | ||
|
||
assert.deepInclude(interception.request.body, { | ||
id: 10000, | ||
termsNote: 'Des modalités de contact avec l’unité.' | ||
}) | ||
}) | ||
|
||
cy.contains('Des modalités de contact avec l’unité.').should('be.visible') | ||
cy.get('.Element-Button').contains('Valider').should('not.exist') | ||
|
||
// ------------------------------------------------------------------------- | ||
// Area note | ||
|
||
cy.getDataCy('ControlUnitDialog-areaNote').forceClick() | ||
|
||
cy.fill('Secteur d’intervention', 'Un secteur d’intervention.') | ||
|
||
cy.clickButton('Valider') | ||
|
||
cy.wait('@updateControlUnit').then(interception => { | ||
if (!interception.response) { | ||
assert.fail('`interception.response` is undefined.') | ||
} | ||
|
||
assert.deepInclude(interception.request.body, { | ||
areaNote: 'Un secteur d’intervention.', | ||
id: 10000 | ||
}) | ||
}) | ||
|
||
cy.contains('Un secteur d’intervention.').should('be.visible') | ||
cy.get('.Element-Button').contains('Valider').should('not.exist') | ||
}) | ||
}) |
103 changes: 103 additions & 0 deletions
103
frontend/cypress/e2e/main_window/control_unit_dialog/resource_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,103 @@ | ||
import { gotToMainWindowAndOpenControlUnit } from './utils' | ||
|
||
context('Main Window > Control Unit Dialog > Resource List', () => { | ||
beforeEach(() => { | ||
gotToMainWindowAndOpenControlUnit(10000) | ||
}) | ||
|
||
it('Should show all resources by default', () => { | ||
cy.contains('Barge – Semi-rigide 1').should('be.visible') | ||
cy.contains('Barge – Semi-rigide 2').should('be.visible') | ||
}) | ||
|
||
it('Should validate the form', () => { | ||
cy.clickButton('Ajouter un moyen') | ||
|
||
cy.clickButton('Ajouter') | ||
|
||
cy.contains('Veuillez choisir un type.').should('be.visible') | ||
cy.contains('Veuillez choisir une base.').should('be.visible') | ||
|
||
cy.clickButton('Annuler') | ||
|
||
cy.get('p').contains('Ajouter un moyen').should('not.exist') | ||
}) | ||
|
||
it('Should add, edit and delete a resource', () => { | ||
// ------------------------------------------------------------------------- | ||
// Create | ||
|
||
cy.intercept('POST', `/api/v1/control_unit_resources`).as('createControlUnitResource') | ||
|
||
cy.clickButton('Ajouter un moyen') | ||
|
||
cy.fill('Type de moyen', 'Avion') | ||
// On ne met pas de nom de moyen ici | ||
// pour tester que ce soit bien le type qui soit utilisé comme nom lorsque le nom est vide. | ||
cy.fill('Base du moyen', 'Dunkerque') | ||
cy.fill('Commentaire', 'Un commentaire sur le moyen.') | ||
|
||
cy.clickButton('Ajouter') | ||
|
||
cy.wait('@createControlUnitResource').then(interception => { | ||
if (!interception.response) { | ||
assert.fail('`interception.response` is undefined.') | ||
} | ||
|
||
assert.deepInclude(interception.request.body, { | ||
baseId: 3, | ||
name: 'Avion', | ||
note: 'Un commentaire sur le moyen.', | ||
type: 'AIRPLANE' | ||
}) | ||
}) | ||
|
||
cy.get('p').contains('Ajouter un moyen').should('not.exist') | ||
cy.contains('Avion – Avion').should('be.visible') | ||
|
||
// ------------------------------------------------------------------------- | ||
// Edit | ||
|
||
cy.intercept('PUT', `/api/v1/control_unit_resources/13`).as('updateControlUnitResource') | ||
|
||
cy.getDataCy('ControlUnitDialog-control-unit-resource').filter('[data-id="13"]').clickButton('Éditer ce moyen') | ||
|
||
cy.fill('Type de moyen', 'Bâtiment de soutien') | ||
cy.fill('Nom du moyen', 'Super Moyen') | ||
cy.fill('Base du moyen', 'Saint-Malo') | ||
cy.fill('Commentaire', 'Un autre commentaire sur le moyen.') | ||
|
||
cy.clickButton('Enregistrer les modifications') | ||
|
||
cy.wait('@updateControlUnitResource').then(interception => { | ||
if (!interception.response) { | ||
assert.fail('`interception.response` is undefined.') | ||
} | ||
|
||
assert.deepInclude(interception.request.body, { | ||
baseId: 2, | ||
id: 13, | ||
name: 'Super Moyen', | ||
note: 'Un autre commentaire sur le moyen.', | ||
type: 'SUPPORT_SHIP' | ||
}) | ||
}) | ||
|
||
cy.get('p').contains('Éditer un moyen').should('not.exist') | ||
cy.contains('Enregistrer les modifications').should('not.exist') | ||
cy.contains('Bâtiment de soutien – Super Moyen').should('be.visible') | ||
|
||
// ------------------------------------------------------------------------- | ||
// Delete | ||
|
||
cy.intercept('DELETE', `/api/v1/control_unit_resources/13`).as('deleteControlUnitResource') | ||
|
||
cy.getDataCy('ControlUnitDialog-control-unit-resource').filter('[data-id="13"]').clickButton('Éditer ce moyen') | ||
cy.clickButton('Supprimer ce moyen') | ||
cy.clickButton('Supprimer') | ||
|
||
cy.wait('@deleteControlUnitResource') | ||
|
||
cy.contains('Bâtiment de soutien – Super Moyen').should('not.exist') | ||
}) | ||
}) |
8 changes: 8 additions & 0 deletions
8
frontend/cypress/e2e/main_window/control_unit_dialog/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,8 @@ | ||
import { goToMainWindow } from '../utils' | ||
|
||
export function gotToMainWindowAndOpenControlUnit(controlUnitId: number) { | ||
goToMainWindow() | ||
|
||
cy.clickButton('Liste des unités de contrôle') | ||
cy.getDataCy('ControlUnitListDialog-control-unit').filter(`[data-id="${controlUnitId}"]`).forceClick().wait(250) | ||
} |
50 changes: 0 additions & 50 deletions
50
frontend/cypress/e2e/main_window/control_unit_list/filters.spec.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.