Skip to content

Commit

Permalink
Clean test data files and add component test to delete cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Sep 18, 2024
1 parent 3d307b2 commit 630e8c6
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ test: test-back
.PHONY: run-back-for-cypress ##TEST ▶️ Run backend API when using Cypress 📝
run-back-for-cypress: run-stubbed-apis
docker compose up -d --quiet-pull --wait db keycloak
cd backend && MONITORFISH_OIDC_ENABLED=false ./gradlew bootRun --args='--spring.profiles.active=local --spring.config.additional-location=$(INFRA_FOLDER)'
cd backend && MONITORFISH_OIDC_ENABLED=false MONITORFISH_SCHEDULING_ENABLED=false ./gradlew bootRun --args='--spring.profiles.active=local --spring.config.additional-location=$(INFRA_FOLDER)'

.PHONY: run-front-for-cypress ##TEST ▶️ Run frontend when using Cypress 📝
run-front-for-cypress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
-- Do NOT update it directly, update the associated .jsonc file in /backend/src/main/resources/db/testdata/json/ and execute 'make generate-test-data'.

TRUNCATE TABLE reportings RESTART IDENTITY CASCADE;
INSERT INTO reportings (archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (false, NOW() - INTERVAL '1 day', false, 'VP374069', 'FR', 'ABC000180832', 'CG1312', 41.569, 37.28, 'ALERT', NOW() - INTERVAL '30 minutes', '{"seaFront":"NAMO","riskFactor":3.5647,"type":"THREE_MILES_TRAWLING_ALERT","natinfCode":7059}', 123456, 'INTERNAL_REFERENCE_NUMBER', 'MARIAGE ÎLE HASARD');

INSERT INTO reportings (archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (true, NOW() - INTERVAL '3 day', false, 'VP374069', 'FR', 'ABC000180832', 'CG1312', NULL, NULL, 'ALERT', NOW() - INTERVAL '4 day', '{"seaFront":"NAMO","riskFactor":3.3647,"type":"THREE_MILES_TRAWLING_ALERT","natinfCode":7059}', 123456, 'INTERNAL_REFERENCE_NUMBER', 'MARIAGE ÎLE HASARD');
INSERT INTO reportings (id, archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (1, false, NOW() - INTERVAL '1 day', false, 'VP374069', 'FR', 'ABC000180832', 'CG1312', 41.569, 37.28, 'ALERT', NOW() - INTERVAL '30 minutes', '{"seaFront":"NAMO","riskFactor":3.5647,"type":"THREE_MILES_TRAWLING_ALERT","natinfCode":7059}', 123456, 'INTERNAL_REFERENCE_NUMBER', 'MARIAGE ÎLE HASARD');

INSERT INTO reportings (archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (true, NOW() - INTERVAL '4 day', true, 'VP374069', 'FR', 'ABC000180832', 'CG1312', -5.569, 71.569, 'ALERT', NOW() - INTERVAL '5 day', '{"seaFront":"NAMO","riskFactor":3.6947,"type":"MISSING_FAR_ALERT","natinfCode":27689}', 123456, 'INTERNAL_REFERENCE_NUMBER', 'MARIAGE ÎLE HASARD');
INSERT INTO reportings (id, archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (2, true, NOW() - INTERVAL '3 day', false, 'VP374069', 'FR', 'ABC000180832', 'CG1312', NULL, NULL, 'ALERT', NOW() - INTERVAL '4 day', '{"seaFront":"NAMO","riskFactor":3.3647,"type":"THREE_MILES_TRAWLING_ALERT","natinfCode":7059}', 123456, 'INTERNAL_REFERENCE_NUMBER', 'MARIAGE ÎLE HASARD');

INSERT INTO reportings (archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (false, NOW() - INTERVAL '1 day', false, 'ZJ472279', 'FR', 'ABC000232227', 'TMG5756', 1.123, -12.569, 'ALERT', NOW(), '{"seaFront":"SA","riskFactor":2.647,"type":"TWELVE_MILES_FISHING_ALERT","natinfCode":2610}', NULL, 'INTERNAL_REFERENCE_NUMBER', 'PROMETTRE INTÉRIEUR SAINT');
INSERT INTO reportings (id, archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (3, true, NOW() - INTERVAL '4 day', true, 'VP374069', 'FR', 'ABC000180832', 'CG1312', -5.569, 71.569, 'ALERT', NOW() - INTERVAL '5 day', '{"seaFront":"NAMO","riskFactor":3.6947,"type":"MISSING_FAR_ALERT","natinfCode":27689}', 123456, 'INTERNAL_REFERENCE_NUMBER', 'MARIAGE ÎLE HASARD');

INSERT INTO reportings (archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (false, NOW() - INTERVAL '2 day', false, 'HK498094', 'FR', 'ABC000591595', 'KF0313', NULL, NULL, 'ALERT', NOW() - INTERVAL '1 day', '{"seaFront":"MEMN","flagState":"FR","riskFactor":1.389,"type":"MISSING_FAR_ALERT","natinfCode":27689}', NULL, 'INTERNAL_REFERENCE_NUMBER', 'HAÏR GAUCHE VIVRE');
INSERT INTO reportings (id, archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (4, false, NOW() - INTERVAL '1 day', false, 'ZJ472279', 'FR', 'ABC000232227', 'TMG5756', 1.123, -12.569, 'ALERT', NOW(), '{"seaFront":"SA","riskFactor":2.647,"type":"TWELVE_MILES_FISHING_ALERT","natinfCode":2610}', NULL, 'INTERNAL_REFERENCE_NUMBER', 'PROMETTRE INTÉRIEUR SAINT');

INSERT INTO reportings (archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (false, NOW() - INTERVAL '1 day', false, 'IW783219', 'FR', 'ABC000042310', 'QD0506', NULL, NULL, 'INFRACTION_SUSPICION', NOW() - INTERVAL '1 day', '{"reportingActor":"OPS","controlUnitId":null,"authorTrigram":"LTH","authorContact":"","title":"Suspicion de chalutage dans les 3 milles","description":"Chalutage dans les 3 milles (vitesse & parcours pêche) le 22/08/22 à 22h56","natinfCode":23588,"dml":"DML 29","type":"INFRACTION_SUSPICION","seaFront":"NAMO"}', 10, 'INTERNAL_REFERENCE_NUMBER', 'COURANT MAIN PROFESSEUR');
INSERT INTO reportings (id, archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (5, false, NOW() - INTERVAL '2 day', false, 'HK498094', 'FR', 'ABC000591595', 'KF0313', NULL, NULL, 'ALERT', NOW() - INTERVAL '1 day', '{"seaFront":"MEMN","flagState":"FR","riskFactor":1.389,"type":"MISSING_FAR_ALERT","natinfCode":27689}', NULL, 'INTERNAL_REFERENCE_NUMBER', 'HAÏR GAUCHE VIVRE');

INSERT INTO reportings (archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (false, NOW() - INTERVAL '1 day 1 hour', false, 'JL026591', 'FR', 'ABC000597493', 'CMQ7994', NULL, NULL, 'INFRACTION_SUSPICION', NULL, '{"reportingActor":"UNIT","controlUnitId":10012,"authorTrigram":"LTH","authorContact":"Jean Bon (0600000000)","title":"Pêche sans VMS ni JPE","description":"Pêche thon rouge sans VMS détecté ni JPE","natinfCode":27689,"dml":"DML 29","type":"INFRACTION_SUSPICION","seaFront":"NAMO"}', 11, 'INTERNAL_REFERENCE_NUMBER', 'RENCONTRER VEILLER APPARTEMENT');
INSERT INTO reportings (id, archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (6, false, NOW() - INTERVAL '1 day', false, 'IW783219', 'FR', 'ABC000042310', 'QD0506', NULL, NULL, 'INFRACTION_SUSPICION', NOW() - INTERVAL '1 day', '{"reportingActor":"OPS","controlUnitId":null,"authorTrigram":"LTH","authorContact":"","title":"Suspicion de chalutage dans les 3 milles","description":"Chalutage dans les 3 milles (vitesse & parcours pêche) le 22/08/22 à 22h56","natinfCode":23588,"dml":"DML 29","type":"INFRACTION_SUSPICION","seaFront":"NAMO"}', 10, 'INTERNAL_REFERENCE_NUMBER', 'COURANT MAIN PROFESSEUR');

INSERT INTO reportings (archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (false, NOW() - INTERVAL '1 day 1 hour', false, 'JL026591', 'FR', 'ABC000597493', 'CMQ7994', NULL, NULL, 'OBSERVATION', NOW() - INTERVAL '1 day 1 hour', '{"reportingActor":"UNIT","controlUnitId":10012,"authorTrigram":"","authorContact":"Jean Bon (0600000000)","title":"OBSERVATION: Pêche sans VMS ni JPE","description":"OBSERVATION: Pêche thon rouge sans VMS détecté ni JPE","type":"OBSERVATION","seaFront":"NAMO"}', 11, 'INTERNAL_REFERENCE_NUMBER', 'RENCONTRER VEILLER APPARTEMENT');
INSERT INTO reportings (id, archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (7, false, NOW() - INTERVAL '1 day 1 hour', false, 'JL026591', 'FR', 'ABC000597493', 'CMQ7994', NULL, NULL, 'INFRACTION_SUSPICION', NULL, '{"reportingActor":"UNIT","controlUnitId":10012,"authorTrigram":"LTH","authorContact":"Jean Bon (0600000000)","title":"Pêche sans VMS ni JPE","description":"Pêche thon rouge sans VMS détecté ni JPE","natinfCode":27689,"dml":"DML 29","type":"INFRACTION_SUSPICION","seaFront":"NAMO"}', 11, 'INTERNAL_REFERENCE_NUMBER', 'RENCONTRER VEILLER APPARTEMENT');

INSERT INTO reportings (id, archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (8, false, NOW() - INTERVAL '1 day 1 hour', false, 'JL026591', 'FR', 'ABC000597493', 'CMQ7994', NULL, NULL, 'OBSERVATION', NOW() - INTERVAL '1 day 1 hour', '{"reportingActor":"UNIT","controlUnitId":10012,"authorTrigram":"","authorContact":"Jean Bon (0600000000)","title":"OBSERVATION: Pêche sans VMS ni JPE","description":"OBSERVATION: Pêche thon rouge sans VMS détecté ni JPE","type":"OBSERVATION","seaFront":"NAMO"}', 11, 'INTERNAL_REFERENCE_NUMBER', 'RENCONTRER VEILLER APPARTEMENT');

INSERT INTO reportings (id, archived, creation_date, deleted, external_reference_number, flag_state, internal_reference_number, ircs, latitude, longitude, type, validation_date, value, vessel_id, vessel_identifier, vessel_name) VALUES (9, false, NOW() AT TIME ZONE 'UTC' - INTERVAL '10 days', false, 'EXTIMM101', 'FR', 'CFR101', 'IRCS101', NULL, NULL, 'INFRACTION_SUSPICION', NULL, '{"authorContact":"Jean Bon (0623456789)","authorTrigram":"LTH","controlUnitId":10012,"description":"Une description d''infraction.","dml":"DML 29","natinfCode":27689,"reportingActor":"OPS","seaFront":"NAMO","title":"Suspicion d''infraction 9","type":"INFRACTION_SUSPICION"}', 101, 'INTERNAL_REFERENCE_NUMBER', 'VIVA ESPANA');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// - Vessel: MARIAGE ÎLE HASARD
// - With 3 reportings
{
"id": 1,
"archived": false,
"creation_date:sql": "NOW() - INTERVAL '1 day'",
"deleted": false,
Expand All @@ -29,6 +30,7 @@
"vessel_name": "MARIAGE ÎLE HASARD"
},
{
"id": 2,
"archived": true,
"creation_date:sql": "NOW() - INTERVAL '3 day'",
"deleted": false,
Expand All @@ -51,6 +53,7 @@
"vessel_name": "MARIAGE ÎLE HASARD"
},
{
"id": 3,
"archived": true,
"creation_date:sql": "NOW() - INTERVAL '4 day'",
"deleted": true,
Expand All @@ -76,6 +79,7 @@
// - Vessel: PROMETTRE INTÉRIEUR SAINT
// - With 1 reporting
{
"id": 4,
"archived": false,
"creation_date:sql": "NOW() - INTERVAL '1 day'",
"deleted": false,
Expand All @@ -101,6 +105,7 @@
// - Vessel: HAÏR GAUCHE VIVRE
// - With 1 reporting
{
"id": 5,
"archived": false,
"creation_date:sql": "NOW() - INTERVAL '2 day'",
"deleted": false,
Expand All @@ -127,6 +132,7 @@
// - Vessel: COURANT MAIN PROFESSEUR
// - With 1 reporting
{
"id": 6,
"archived": false,
"creation_date:sql": "NOW() - INTERVAL '1 day'",
"deleted": false,
Expand Down Expand Up @@ -158,6 +164,7 @@
// - Vessel: RENCONTRER VEILLER APPARTEMENT
// - With 2 reportings
{
"id": 7,
"archived": false,
"creation_date:sql": "NOW() - INTERVAL '1 day 1 hour'",
"deleted": false,
Expand Down Expand Up @@ -186,6 +193,7 @@
"vessel_name": "RENCONTRER VEILLER APPARTEMENT"
},
{
"id": 8,
"archived": false,
"creation_date:sql": "NOW() - INTERVAL '1 day 1 hour'",
"deleted": false,
Expand Down
15 changes: 5 additions & 10 deletions frontend/cypress/e2e/vessel_sidebar/reporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ context('Vessel sidebar reporting tab', () => {
cy.get('*[data-cy^="vessel-search-selected-vessel-close-title"]', { timeout: 10000 }).click()
})

it('Dates occurrences of an alert and reporting summary should be displayed', () => {
it('Reporting summary of reportings should be displayed', () => {
// Given
cy.get('*[data-cy="vessel-search-input"]', { timeout: 10000 }).type('mariage ile hasard')
cy.get('*[data-cy="vessel-search-item"]', { timeout: 10000 }).eq(0).click()
Expand All @@ -133,23 +133,18 @@ context('Vessel sidebar reporting tab', () => {
cy.get('*[data-cy="vessel-menu-reporting"]').click({ timeout: 10000 })
cy.get('*[data-cy="vessel-reporting"]', { timeout: 10000 }).should('be.visible')
cy.wait('@reporting')
createReporting()
cy.get('[data-cy="archive-reporting-card"]').eq(0).click()
cy.get('*[data-cy="reporting-card"]').should('not.exist')
cy.get('*[data-cy="vessel-sidebar-reporting-tab-history-button"]').click()
cy.get('*[data-cy="vessel-sidebar-reporting-tab-history"]').should('exist')

// Then
// Summary
cy.get('[data-cy="vessel-reporting-summary"]').contains('Résumé des derniers signalements (6 dernières années)')
cy.get('[data-cy="vessel-reporting-summary"]').contains('Signalements "3 milles - Chaluts (NATINF 7059)"')

// Dates occurrences of an alert
cy.get('*[data-cy="vessel-sidebar-reporting-tab-archive-year"]').eq(0).click()
cy.get('[data-cy="reporting-card"]').should('not.contain', '1ère alerte le')
cy.clickLink('Voir les dates des autres alertes')
cy.get('[data-cy="reporting-card"]').should('contain', '1ère alerte le')
cy.clickLink('Masquer les dates des autres alertes')
cy.get('[data-cy="reporting-card"]').should('not.contain', '1ère alerte le')
cy.get('[data-cy="vessel-reporting-summary"]').contains(
"Peche maritime non autorisee dans les eaux maritimes ou salees francaises par un navire de pays tiers a l'union europeenne (NATINF 2608)"
)

cy.get('*[data-cy^="vessel-search-selected-vessel-close-title"]', { timeout: 10000 }).click()
})
Expand Down
14 changes: 14 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"@swc/core": "1.7.23",
"@swc/jest": "0.2.36",
"@testing-library/react": "15.0.7",
"@testing-library/user-event": "^14.5.2",
"@tsconfig/vite-react": "2.0.1",
"@types/diacritics": "1.3.3",
"@types/jest": "29.5.12",
Expand Down
2 changes: 1 addition & 1 deletion frontend/scripts/generate_test_data_seeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ for (const file of jsonFiles) {
const { afterAll, beforeAll, data: rows, id, table } = dataTable

return [
beforeAll,
beforeAll?.concat('\n'),
...rows.map(row => {
const insertStatement = generateInsertStatement(row, table)
const updateStatements = generateUpdateStatements(row, table, id)
Expand Down
Loading

0 comments on commit 630e8c6

Please sign in to comment.