diff --git a/backend/src/main/resources/db/testdata/V0.205.0__Insert_dummy_reportings_for_migration.sql b/backend/src/main/resources/db/testdata/V0.205.0__Insert_dummy_reportings_for_migration.sql deleted file mode 100644 index 46c1d12a63..0000000000 --- a/backend/src/main/resources/db/testdata/V0.205.0__Insert_dummy_reportings_for_migration.sql +++ /dev/null @@ -1,39 +0,0 @@ -TRUNCATE TABLE reportings RESTART IDENTITY CASCADE; - -INSERT INTO reportings (type, vessel_name, internal_reference_number, external_reference_number, ircs, - vessel_identifier, flag_state, creation_date, validation_date, archived, deleted, value, latitude, longitude, vessel_id) -VALUES ('ALERT', 'MARIAGE ÎLE HASARD', 'ABC000180832', 'VP374069', 'CG1312', 'INTERNAL_REFERENCE_NUMBER', 'FR', - NOW() - ('1 DAY')::interval, NOW(), false, false, ('{' || - '"seaFront": "NAMO",' || - '"riskFactor": 3.5647,' || - '"type": "THREE_MILES_TRAWLING_ALERT",' || - '"natinfCode": "7059"' || - '}')::jsonb, 41.569, 37.28, null), - ('ALERT', 'MARIAGE ÎLE HASARD', 'ABC000180832', 'VP374069', 'CG1312', 'INTERNAL_REFERENCE_NUMBER', 'FR', - NOW() - ('3 DAY')::interval, NOW() - ('4 DAY')::interval, true, false, ('{' || - '"seaFront": "NAMO",' || - '"riskFactor": 3.3647,' || - '"type": "THREE_MILES_TRAWLING_ALERT"' || - '}')::jsonb, null, null, null), - ('ALERT', 'MARIAGE ÎLE HASARD', 'ABC000180832', 'VP374069', 'CG1312', 'INTERNAL_REFERENCE_NUMBER', 'FR', - NOW() - ('4 DAY')::interval, NOW() - ('5 DAY')::interval, true, true, ('{' || - '"seaFront": "NAMO",' || - '"riskFactor": 3.6947,' || - '"type": "MISSING_FAR_ALERT",' || - '"natinfCode": null' || - '}')::jsonb, -5.569, 71.569, null), - ('ALERT', 'PROMETTRE INTÉRIEUR SAINT', 'ABC000232227', 'ZJ472279', 'TMG5756', 'INTERNAL_REFERENCE_NUMBER', 'FR', - NOW() - ('1 DAY')::interval, NOW(), false, false, ('{' || - '"seaFront": "SA",' || - '"riskFactor": 2.647,' || - '"type": "TWELVE_MILES_FISHING_ALERT",' || - '"natinfCode": ""' || - '}')::jsonb, 1.123, -12.569, null), - ('ALERT', 'HAÏR GAUCHE VIVRE', 'ABC000591595', 'HK498094', 'KF0313', 'INTERNAL_REFERENCE_NUMBER', 'FR', - NOW() - ('2 DAY')::interval, NOW() - ('1 DAY')::interval, false, false, ('{' || - '"seaFront": "MEMN",' || - '"flagState": "FR",' || - '"riskFactor": 1.389,' || - '"type": "MISSING_FAR_ALERT",' || - '"natinfCode": "27689"' || - '}')::jsonb, null, null, null); diff --git a/frontend/config/cypress.config.ts b/frontend/config/cypress.config.ts index ea3bd8186f..a92a6bde10 100644 --- a/frontend/config/cypress.config.ts +++ b/frontend/config/cypress.config.ts @@ -1,6 +1,6 @@ -import {defineConfig} from 'cypress' +import { defineConfig } from 'cypress' import initCypressMousePositionPlugin from 'cypress-mouse-position/plugin' -import {initPlugin} from 'cypress-plugin-snapshots/plugin' +import { initPlugin } from 'cypress-plugin-snapshots/plugin' const IS_CI = Boolean(process.env.CI) @@ -15,8 +15,6 @@ export default defineConfig({ specPattern: 'cypress/e2e/**/*.spec.ts' }, env: { - "FRONTEND_OIDC_AUTHORITY": `http://${IS_CI ? '0.0.0.0:8880' : 'localhost:8880'}/realms/monitor`, - "FRONTEND_OIDC_CLIENT_ID": "monitorfish", 'cypress-plugin-snapshots': { imageConfig: { threshold: 20, @@ -28,7 +26,9 @@ export default defineConfig({ * When running Cypress tests, we modify this env var in spec file, so we use `window.Cypress.env()` * instead of `import.meta.env` in application code. */ - FRONTEND_MISSION_FORM_AUTO_SAVE_ENABLED: true + FRONTEND_MISSION_FORM_AUTO_SAVE_ENABLED: true, + FRONTEND_OIDC_AUTHORITY: `http://${IS_CI ? '0.0.0.0:8880' : 'localhost:8880'}/realms/monitor`, + FRONTEND_OIDC_CLIENT_ID: 'monitorfish' }, projectId: '9b7q8z', retries: { diff --git a/frontend/cypress/e2e/back_office/control_objective_tables/actions.spec.ts b/frontend/cypress/e2e/back_office/control_objective_tables/actions.spec.ts index ba33966f4c..ae12655bad 100644 --- a/frontend/cypress/e2e/back_office/control_objective_tables/actions.spec.ts +++ b/frontend/cypress/e2e/back_office/control_objective_tables/actions.spec.ts @@ -130,24 +130,51 @@ context('BackOffice > Control Objective Tables > Actions', () => { cy.get('.rs-table-row').should('have.length', 67) }) - it('Should add the next control objective year', () => { + it('Should handle new year as expected', () => { + const currentYear = new Date().getFullYear() + const nextYear = currentYear + 1 + + cy.intercept('GET', `/bff/v1/fleet_segments/${currentYear}`).as('fleetSegments') + cy.intercept('GET', `/bff/v1/admin/control_objectives/${currentYear}`).as('controlObjectives') + cy.intercept('POST', '/bff/v1/admin/control_objectives/years').as('addObjectiveYear') + + cy.log('Should allow adding a control objective for a year that has not yet been added') + + // Given + cy.clock(new Date(nextYear, 3, 14).getTime()) + + cy.getDataCy('control-objectives-year').contains(currentYear) + cy.get('.rs-table-row').should('have.length', 67) + + // When + cy.getDataCy('control-objectives-year').click() + + // Then + cy.get('.rs-picker-select-menu-item').should('have.length', 2) + cy.get('*[data-cy="control-objectives-add-year"]').contains(nextYear) + + cy.log('Should add the next control objective year') + // Given + cy.clock(new Date().getTime()) + cy.get('.rs-table-row').should('have.length', 67) - cy.get('*[data-cy^="control-objectives-year"]').click() + + cy.getDataCy('control-objectives-year').click() + cy.get('.rs-picker-select-menu-item').should('have.length', 2) - cy.intercept('POST', '/bff/v1/admin/control_objectives/years').as('addObjectiveYear') // When cy.get('*[data-cy="control-objectives-add-year"]').click() + cy.wait('@addObjectiveYear') // Then cy.wait(50) - const nextYear = new Date().getFullYear() + 1 - cy.get('*[data-cy^="control-objectives-year"]').contains(nextYear) - cy.get('*[data-cy^="control-objectives-year"]').click() + cy.getDataCy('control-objectives-year').contains(nextYear) + cy.getDataCy('control-objectives-year').click() cy.get('.rs-picker-select-menu-item').should('have.length', 3) cy.get('.rs-table-row').should('have.length', 67) - cy.get('*[data-cy="control-objectives-add-year"]').should('be.not.visible') + cy.getDataCy('control-objectives-add-year').should('be.not.visible') }) }) diff --git a/frontend/cypress/e2e/back_office/control_objective_tables/behavior.spec.ts b/frontend/cypress/e2e/back_office/control_objective_tables/behavior.spec.ts deleted file mode 100644 index af996e03db..0000000000 --- a/frontend/cypress/e2e/back_office/control_objective_tables/behavior.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-disable no-undef */ - -context('BackOffice > Control Objective Tables > Behavior', () => { - beforeEach(() => { - const currentYear = new Date().getFullYear() - - cy.intercept('GET', `/bff/v1/fleet_segments/${currentYear}`).as('fleetSegments') - cy.intercept('GET', `/bff/v1/admin/control_objectives/${currentYear}`).as('controlObjectives') - - cy.login('superuser') - - cy.visit('/backoffice/control_objectives') - cy.wait('@fleetSegments') - cy.wait('@controlObjectives') - }) - - it('Should permit to add a control objective year When the current year is not yet added', () => { - // Given - const currentYear = new Date().getFullYear() - const nextYear = currentYear + 1 - const now = new Date(nextYear, 3, 14).getTime() - - cy.clock(now) - cy.get('.rs-table-row').should('have.length', 67) - cy.get('*[data-cy^="control-objectives-year"]').contains(currentYear) - cy.get('*[data-cy^="control-objectives-year"]').click() - cy.get('.rs-picker-select-menu-item').should('have.length', 2) - - // Then - cy.get('*[data-cy="control-objectives-add-year"]').contains(nextYear) - }) -}) diff --git a/frontend/cypress/support/e2e.ts b/frontend/cypress/support/e2e.ts index 5d40a314f6..9a5640dd58 100644 --- a/frontend/cypress/support/e2e.ts +++ b/frontend/cypress/support/e2e.ts @@ -67,12 +67,6 @@ Cypress.on('uncaught:exception', err => { return false } - // We ignore uncaught exceptions `TypeError: NetworkError when attempting to fetch resource` - // if (err.message.includes('NetworkError when attempting to fetch resource') ) { - // console.log(`Error skipped: ${err}`) - // return false // return false to make test continue - // } - // We ignore uncaught exceptions `AbortError: The operation was aborted` // This error happens after using `reload()` in Cypress if (err.message.includes('The operation was aborted')) { diff --git a/frontend/src/api/constants.ts b/frontend/src/api/constants.ts index 9a57eb7503..5ed118a5bf 100644 --- a/frontend/src/api/constants.ts +++ b/frontend/src/api/constants.ts @@ -5,22 +5,24 @@ import type { StartQueryActionCreatorOptions, SubscriptionOptions } from '@redux export const RTK_MAX_RETRIES = 1 -export const RTK_THIRTY_SECONDS_POLLING_QUERY_OPTIONS: SubscriptionOptions & Partial = { - pollingInterval: THIRTY_SECONDS, +export const RTK_DEFAULT_REFETCH_QUERY_OPTIONS: Partial = { refetchOnMountOrArgChange: true, refetchOnReconnect: true } +export const RTK_THIRTY_SECONDS_POLLING_QUERY_OPTIONS: SubscriptionOptions & Partial = { + ...RTK_DEFAULT_REFETCH_QUERY_OPTIONS, + pollingInterval: THIRTY_SECONDS +} + export const RTK_ONE_MINUTE_POLLING_QUERY_OPTIONS: SubscriptionOptions & Partial = { - pollingInterval: ONE_MINUTE, - refetchOnMountOrArgChange: true, - refetchOnReconnect: true + ...RTK_DEFAULT_REFETCH_QUERY_OPTIONS, + pollingInterval: ONE_MINUTE } export const RTK_FIVE_MINUTES_POLLING_QUERY_OPTIONS: SubscriptionOptions & Partial = { - pollingInterval: FIVE_MINUTES, - refetchOnMountOrArgChange: true, - refetchOnReconnect: true + ...RTK_DEFAULT_REFETCH_QUERY_OPTIONS, + pollingInterval: FIVE_MINUTES } export const RTK_FORCE_REFETCH_QUERY_OPTIONS: StartQueryActionCreatorOptions = { diff --git a/frontend/src/features/PriorNotification/components/LogbookPriorNotificationForm/index.tsx b/frontend/src/features/PriorNotification/components/LogbookPriorNotificationForm/index.tsx index b98861adac..666b878a23 100644 --- a/frontend/src/features/PriorNotification/components/LogbookPriorNotificationForm/index.tsx +++ b/frontend/src/features/PriorNotification/components/LogbookPriorNotificationForm/index.tsx @@ -46,7 +46,7 @@ export function LogbookPriorNotificationForm() { ) }, isBeingSent, - 5000 + 1000 ) const displayedErrorKey = displayedError ? DisplayedErrorKey.SIDE_WINDOW_PRIOR_NOTIFICATION_FORM_ERROR : undefined diff --git a/frontend/src/features/PriorNotification/components/ManualPriorNotificationForm/index.tsx b/frontend/src/features/PriorNotification/components/ManualPriorNotificationForm/index.tsx index f95c16233e..7bf469e315 100644 --- a/frontend/src/features/PriorNotification/components/ManualPriorNotificationForm/index.tsx +++ b/frontend/src/features/PriorNotification/components/ManualPriorNotificationForm/index.tsx @@ -55,7 +55,7 @@ export function ManualPriorNotificationForm() { ) }, isBeingSent, - 5000 + 1000 ) const [shouldValidateOnChange, setShouldValidateOnChange] = useState(false) diff --git a/frontend/src/features/PriorNotification/components/shared/CardBodyHead/SentMessageList.tsx b/frontend/src/features/PriorNotification/components/shared/CardBodyHead/SentMessageList.tsx index 0455287d81..f818ac35ef 100644 --- a/frontend/src/features/PriorNotification/components/shared/CardBodyHead/SentMessageList.tsx +++ b/frontend/src/features/PriorNotification/components/shared/CardBodyHead/SentMessageList.tsx @@ -1,3 +1,4 @@ +import { RTK_DEFAULT_REFETCH_QUERY_OPTIONS } from '@api/constants' import { PriorNotification } from '@features/PriorNotification/PriorNotification.types' import { useGetPriorNotificationSentNessagesQuery } from '@features/PriorNotification/priorNotificationApi' import { Icon } from '@mtes-mct/monitor-ui' @@ -12,7 +13,11 @@ type SentMessageListProps = Readonly<{ state: PriorNotification.State | undefined }> export function SentMessageList({ detail, state }: SentMessageListProps) { - const { data: sentMessages, isError, isFetching } = useGetPriorNotificationSentNessagesQuery(detail.reportId) + const { + data: sentMessages, + isError, + isFetching + } = useGetPriorNotificationSentNessagesQuery(detail.reportId, RTK_DEFAULT_REFETCH_QUERY_OPTIONS) const sentMessagesBatches = sentMessages ? getSentMessagesBatches(sentMessages) : [] const lastSentMessagesBatch = sentMessagesBatches ? sentMessagesBatches[sentMessagesBatches.length - 1] : undefined