Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fishing map/fix vessel profile update #3012

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/fishing-map-e2e/src/constants/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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*'
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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')
Expand Down
57 changes: 57 additions & 0 deletions apps/fishing-map-e2e/src/e2e/vessel-viewer/update-legacy.cy.ts
Original file line number Diff line number Diff line change
@@ -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')
})
})
41 changes: 30 additions & 11 deletions apps/fishing-map/features/workspace/workspace-migration.hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -148,8 +158,12 @@ export const useMigrateWorkspace = () => {
deprecatedDatasets,
deprecatedDataviewInstances,
dispatch,
dispatchQueryParams,
isAnyVesselLocation,
upsertDataviewInstance,
urlDataviewInstances,
vesselDatasetId,
vesselId,
workspace,
])

Expand Down Expand Up @@ -220,7 +234,12 @@ export const useMigrateWorkspaceToast = () => {
{/* <Button onClick={dissmissToast} type="secondary" className={styles.updateBtn}>
{t('workspace.migrationMaintain', 'Skip')}
</Button> */}
<Button loading={loading} onClick={updateWorkspace} className={styles.updateBtn}>
<Button
loading={loading}
testId="migrate-workspace-btn"
onClick={updateWorkspace}
className={styles.updateBtn}
>
{t('workspace.migrationUpdate', 'Update')}
</Button>
</div>
Expand Down