From a2caa8bd4b3ba7f22a589247cfac9bf7973e7659 Mon Sep 17 00:00:00 2001 From: j8seangel Date: Tue, 28 Jan 2025 16:07:52 +0100 Subject: [PATCH 1/2] ensure vesselDatasetId is updated on vessel profile --- .../workspace/workspace-migration.hooks.tsx | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/apps/fishing-map/features/workspace/workspace-migration.hooks.tsx b/apps/fishing-map/features/workspace/workspace-migration.hooks.tsx index a96386d869..93ee19dec7 100644 --- a/apps/fishing-map/features/workspace/workspace-migration.hooks.tsx +++ b/apps/fishing-map/features/workspace/workspace-migration.hooks.tsx @@ -21,8 +21,16 @@ import { import { selectIsReportOwner } from 'features/reports/areas/area-reports.selectors' import { updateReportThunk } from 'features/reports/areas/area-reports.slice' import { getWorkspaceReport } from 'features/reports/areas/area-reports.utils' +import { selectVesselDatasetId } from 'features/vessel/vessel.config.selectors' +import { fetchVesselInfoThunk } from 'features/vessel/vessel.slice' import type { AppWorkspace } from 'features/workspaces-list/workspaces-list.slice' -import { selectIsAnyAreaReportLocation, selectUrlDataviewInstances } from 'routes/routes.selectors' +import { useLocationConnect } from 'routes/routes.hook' +import { + selectIsAnyAreaReportLocation, + selectIsAnyVesselLocation, + selectUrlDataviewInstances, + selectVesselId, +} from 'routes/routes.selectors' import { useDataviewInstancesConnect } from './workspace.hook' import { selectIsWorkspaceOwner } from './workspace.selectors' @@ -34,9 +42,10 @@ export const useMigrateWorkspace = () => { const deprecatedDataviewInstances = useSelector(selectDeprecatedDataviewInstances) const urlDataviewInstances = useSelector(selectUrlDataviewInstances) const workspace = useSelector(selectWorkspaceWithCurrentState) - // const vesselDatasetId = useSelector(selectVesselDatasetId) - // const isAnyVesselLocation = useSelector(selectIsAnyVesselLocation) - // const { dispatchQueryParams } = useLocationConnect() + const vesselDatasetId = useSelector(selectVesselDatasetId) + const isAnyVesselLocation = useSelector(selectIsAnyVesselLocation) + const vesselId = useSelector(selectVesselId) + const { dispatchQueryParams } = useLocationConnect() const deprecatedDatasets = useSelector(selectDeprecatedDatasets) const dispatch = useAppDispatch() const { upsertDataviewInstance } = useDataviewInstancesConnect() @@ -98,12 +107,13 @@ export const useMigrateWorkspace = () => { if (dataviewInstancesToMigrate.length) { upsertDataviewInstance(dataviewInstancesToMigrate) } - // TODO update the vesselDatasetId in the url too - // if (isAnyVesselLocation && deprecatedDatasets[vesselDatasetId]) { - // setTimeout(() => { - // dispatchQueryParams({ vesselDatasetId: deprecatedDatasets[vesselDatasetId] }) - // }, 100) - // } + if (isAnyVesselLocation && deprecatedDatasets[vesselDatasetId]) { + const newVesselDatasetId = deprecatedDatasets[vesselDatasetId] + setTimeout(() => { + dispatchQueryParams({ vesselDatasetId: newVesselDatasetId }) + dispatch(fetchVesselInfoThunk({ vesselId, datasetId: newVesselDatasetId })) + }, 100) + } const migratedWorkspace = { ...workspace, // This is needed to get the latest workspace state without waiting to resolve dataviewInstances @@ -148,8 +158,12 @@ export const useMigrateWorkspace = () => { deprecatedDatasets, deprecatedDataviewInstances, dispatch, + dispatchQueryParams, + isAnyVesselLocation, upsertDataviewInstance, urlDataviewInstances, + vesselDatasetId, + vesselId, workspace, ]) From c2648a93ef9b3e4e82a3da5afb784574e89bc776 Mon Sep 17 00:00:00 2001 From: j8seangel Date: Tue, 28 Jan 2025 16:33:49 +0100 Subject: [PATCH 2/2] add test to update legacy vessel profile workspace --- apps/fishing-map-e2e/src/constants/urls.ts | 4 +- .../src/e2e/vessel-viewer/direct-access.cy.ts | 8 +-- .../src/e2e/vessel-viewer/update-legacy.cy.ts | 57 +++++++++++++++++++ .../workspace/workspace-migration.hooks.tsx | 7 ++- 4 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 apps/fishing-map-e2e/src/e2e/vessel-viewer/update-legacy.cy.ts diff --git a/apps/fishing-map-e2e/src/constants/urls.ts b/apps/fishing-map-e2e/src/constants/urls.ts index 1607e83506..e8e5eaddfd 100644 --- a/apps/fishing-map-e2e/src/constants/urls.ts +++ b/apps/fishing-map-e2e/src/constants/urls.ts @@ -10,10 +10,10 @@ export const URL_YEAR_2018 = '/?start=2018-01-01T00%3A00%3A00.000Z&end=2019-01-01T00%3A00%3A00.000Z&' + FULL_MAP_PARAMS export const URL_VESSEL_PROFILE = - 'fishing-activity/default-public/vessel/3d92d0d1e-ed36-e1bd-fd55-3735c2a5485e?start=2018-01-01T00%3A00%3A00.000Z&end=2019-01-01T00%3A00%3A00.000Z&latitude=-51.62826704426086&longitude=-48.04732049999999&zoom=2.746324859308452&dvIn[0][id]=vessel-3d92d0d1e-ed36-e1bd-fd55-3735c2a5485e&dvIn[0][dvId]=fishing-map-vessel-track&dvIn[0][cfg][track]=public-global-all-tracks%3Av20231026&dvIn[0][cfg][info]=public-global-vessel-identity%3Av20231026&dvIn[0][cfg][events][0]=public-global-fishing-events%3Av20231026&dvIn[0][cfg][events][1]=public-global-port-visits-c2-events%3Av20231026&dvIn[0][cfg][events][2]=public-global-encounters-events%3Av20231026&dvIn[0][cfg][events][3]=public-global-loitering-events%3Av20231026&dvIn[0][cfg][events][4]=public-global-gaps-events%3Av20231026&dvIn[0][cfg][clr]=%23F95E5E&lTD=&fTD=&timebarVisualisation=vessel&vesselDatasetId=public-global-vessel-identity%3Av20231026&visibleEvents[0]=loitering&visibleEvents[1]=encounter&visibleEvents[2]=port_visit&tk[0]=public-global-vessel-identity%3Av20231026' + '/map/fishing-activity/default-public/vessel/3d92d0d1e-ed36-e1bd-fd55-3735c2a5485e?start=2021-01-01T00%3A00%3A00.000Z&end=2024-01-01T00%3A00%3A00.000Z&latitude=-51.41842735496924&longitude=-16.9961338043213&zoom=2.3748783848980315&dvIn[0][id]=vessel-3d92d0d1e-ed36-e1bd-fd55-3735c2a5485e&dvIn[0][dvId]=fishing-map-vessel-track-v-3&dvIn[0][cfg][track]=public-global-all-tracks%3Av20231026&dvIn[0][cfg][info]=public-global-vessel-identity%3Av3.0&dvIn[0][cfg][events][0]=public-global-fishing-events%3Av20231026&dvIn[0][cfg][events][1]=public-global-port-visits-c2-events%3Av20231026&dvIn[0][cfg][events][2]=public-global-encounters-events%3Av20231026&dvIn[0][cfg][events][3]=public-global-loitering-events%3Av20231026&dvIn[0][cfg][events][4]=public-global-gaps-events%3Av20231026&dvIn[0][cfg][clr]=%23F95E5E&dvIn[0][datasetsConfigMigration][public-global-all-tracks:v20231026]=public-global-all-tracks%3Av3.0&dvIn[0][datasetsConfigMigration][public-global-fishing-events:v20231026]=public-global-fishing-events%3Av3.0&dvIn[0][datasetsConfigMigration][public-global-loitering-events:v20231026]=public-global-loitering-events%3Av3.0&dvIn[0][datasetsConfigMigration][public-global-encounters-events:v20231026]=public-global-encounters-events%3Av3.0&dvIn[0][datasetsConfigMigration][public-global-gaps-events:v20231026]=public-global-gaps-events%3Av3.0&lTD=&fTD=&tV=vessel&vDi=public-global-vessel-identity%3Av3.0&vE[0]=encounter&vE[1]=port_visit&tk[0]=public-global-vessel-identity%3Av3.0' export const URL_VESSEL_PROFILE_2020 = - 'fishing-activity/default-public/vessel/3d92d0d1e-ed36-e1bd-fd55-3735c2a5485e?start=2021-01-01T00%3A00%3A00.000Z&end=2024-01-01T00%3A00%3A00.000Z&latitude=-51.62826704426086&longitude=-48.04732049999999&zoom=2.746324859308452&dvIn[0][id]=vessel-3d92d0d1e-ed36-e1bd-fd55-3735c2a5485e&dvIn[0][dvId]=fishing-map-vessel-track&dvIn[0][cfg][track]=public-global-all-tracks%3Av20231026&dvIn[0][cfg][info]=public-global-vessel-identity%3Av20231026&dvIn[0][cfg][events][0]=public-global-fishing-events%3Av20231026&dvIn[0][cfg][events][1]=public-global-port-visits-c2-events%3Av20231026&dvIn[0][cfg][events][2]=public-global-encounters-events%3Av20231026&dvIn[0][cfg][events][3]=public-global-loitering-events%3Av20231026&dvIn[0][cfg][events][4]=public-global-gaps-events%3Av20231026&dvIn[0][cfg][clr]=%23F95E5E&lTD=&fTD=&timebarVisualisation=vessel&vesselDatasetId=public-global-vessel-identity%3Av20231026&visibleEvents[0]=loitering&visibleEvents[1]=encounter&visibleEvents[2]=port_visit&tk[0]=public-global-vessel-identity%3Av20231026' + '/map/fishing-activity/default-public/vessel/3d92d0d1e-ed36-e1bd-fd55-3735c2a5485e?start=2021-01-01T00%3A00%3A00.000Z&end=2024-01-01T00%3A00%3A00.000Z&latitude=-51.62826704426086&longitude=-48.04732049999999&zoom=2.746324859308452&dvIn[0][id]=vessel-3d92d0d1e-ed36-e1bd-fd55-3735c2a5485e&dvIn[0][dvId]=fishing-map-vessel-track&dvIn[0][cfg][track]=public-global-all-tracks%3Av20231026&dvIn[0][cfg][info]=public-global-vessel-identity%3Av20231026&dvIn[0][cfg][events][0]=public-global-fishing-events%3Av20231026&dvIn[0][cfg][events][1]=public-global-port-visits-c2-events%3Av20231026&dvIn[0][cfg][events][2]=public-global-encounters-events%3Av20231026&dvIn[0][cfg][events][3]=public-global-loitering-events%3Av20231026&dvIn[0][cfg][events][4]=public-global-gaps-events%3Av20231026&dvIn[0][cfg][clr]=%23F95E5E&lTD=&fTD=&timebarVisualisation=vessel&vesselDatasetId=public-global-vessel-identity%3Av20231026&visibleEvents[0]=loitering&visibleEvents[1]=encounter&visibleEvents[2]=port_visit&tk[0]=public-global-vessel-identity%3Av20231026' // API URLS export const API_URL_VESSELS = '/v3/vessels*' diff --git a/apps/fishing-map-e2e/src/e2e/vessel-viewer/direct-access.cy.ts b/apps/fishing-map-e2e/src/e2e/vessel-viewer/direct-access.cy.ts index 60c232d035..a70e938323 100644 --- a/apps/fishing-map-e2e/src/e2e/vessel-viewer/direct-access.cy.ts +++ b/apps/fishing-map-e2e/src/e2e/vessel-viewer/direct-access.cy.ts @@ -1,4 +1,4 @@ -import { URL_VESSEL_PROFILE, URL_VESSEL_PROFILE_2020 } from '../../constants/urls' +import { URL_VESSEL_PROFILE } from '../../constants/urls' import { disablePopups, switchLanguage, verifyTracksInTimebar } from '../../support/app.po' describe('Access to vessel viewver - direct', () => { @@ -49,11 +49,11 @@ describe('Access to vessel viewver - direct', () => { cy.getBySel('link-vessel-profile').contains('Gadus Neptun') cy.getBySel('vv-insights-tab').click() - cy.get('#insights').contains('Insights available from 1 January 2020 onwards') + cy.get('#insights').contains('Vessel insights') }) - it('should access to a vessel insights profile using a link post 2020', () => { - cy.visit(URL_VESSEL_PROFILE_2020) + it('should access to a vessel insights profile using a link post v3', () => { + cy.visit(URL_VESSEL_PROFILE) cy.getBySel('vv-insights-tab').click() cy.get('#coverage').contains('AIS Coverage') cy.get('#gaps').contains('AIS Off Events') diff --git a/apps/fishing-map-e2e/src/e2e/vessel-viewer/update-legacy.cy.ts b/apps/fishing-map-e2e/src/e2e/vessel-viewer/update-legacy.cy.ts new file mode 100644 index 0000000000..335e7af588 --- /dev/null +++ b/apps/fishing-map-e2e/src/e2e/vessel-viewer/update-legacy.cy.ts @@ -0,0 +1,57 @@ +import { URL_VESSEL_PROFILE_2020 } from '../../constants/urls' +import { disablePopups, switchLanguage, verifyTracksInTimebar } from '../../support/app.po' + +describe('Access to vessel viewver - direct', () => { + before(() => { + // I need to search as a anonymous user, the last update of cypress needed to add the eslit coment + + cy.clearAllLocalStorage().then(() => { + disablePopups() + switchLanguage('en') + }) + }) + + it('should access to a vessel profile using a link and check basic data after run migration updated', () => { + cy.visit(URL_VESSEL_PROFILE_2020) + + cy.getBySel('migrate-workspace-btn').click() + + verifyTracksInTimebar(4) + + // Do a quick test of the loaded content + cy.getBySel('vv-summary-loitering').should('exist') + + cy.getBySel('vv-summary-tab').click() + cy.getBySel('vv-list-encounter').click() + cy.getBySel('vv-encounter-event-0').should('exist') + cy.getBySel('vv-encounter-event-1').should('exist') + + cy.getBySel('vv-areas-tab').click() + cy.get('span').contains('South Georgia and the South Sandwich Islands') + cy.get('span').contains('Uruguay') + + cy.getBySel('vv-area-fao').click() + cy.get('span').contains('Atlantic, Antarctic') + + cy.getBySel('vv-area-rfmo').click() + cy.get('span').contains('ACAP') + cy.get('span').contains('IWC') + cy.get('span').contains('CCAMLR') + + cy.getBySel('vv-area-mpa').click() + cy.get('span').contains( + 'South Georgia and South Sandwich Islands Marine Protected Area - Marine Protected Area' + ) + cy.get('span').contains('Outside MPA areas') + + cy.getBySel('vv-related-tab').click() + cy.getBySel('link-vessel-profile').contains('La Manche') + + cy.getBySel('vv-related-type-owners').click() + cy.getBySel('link-vessel-profile').contains('Antarctic Sea') + cy.getBySel('link-vessel-profile').contains('Gadus Neptun') + + cy.getBySel('vv-insights-tab').click() + cy.get('#insights').contains('Vessel insights') + }) +}) diff --git a/apps/fishing-map/features/workspace/workspace-migration.hooks.tsx b/apps/fishing-map/features/workspace/workspace-migration.hooks.tsx index 93ee19dec7..45109ba7a2 100644 --- a/apps/fishing-map/features/workspace/workspace-migration.hooks.tsx +++ b/apps/fishing-map/features/workspace/workspace-migration.hooks.tsx @@ -234,7 +234,12 @@ export const useMigrateWorkspaceToast = () => { {/* */} -