diff --git a/src/components/FunctionalArea/ContextMenu/ContextMenu.component.tsx b/src/components/FunctionalArea/ContextMenu/ContextMenu.component.tsx index 5e92826059af1ed40834e13d57ab5a60f6ac9ca5..1e4d612b0297062a993227bdd18389bc5b9050b8 100644 --- a/src/components/FunctionalArea/ContextMenu/ContextMenu.component.tsx +++ b/src/components/FunctionalArea/ContextMenu/ContextMenu.component.tsx @@ -46,7 +46,7 @@ export const ContextMenu = (): React.ReactNode => { dispatch(openAddCommentModal()); }; - const modelId = model ? model.idObject : ZERO; + const modelId = model ? model.id : ZERO; const handleCallback = ( callback: (coordinates: ClickCoordinates, element: BioEntity | NewReaction | undefined) => void, diff --git a/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx b/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx index 35c89a0c07e0950eda63195256750d1e49ecc129..e1839e6627287b38b702bbf9b03216e817d3604c 100644 --- a/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx +++ b/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx @@ -1,7 +1,6 @@ /* eslint-disable no-magic-numbers */ import { MODELS_MOCK } from '@/redux/compartmentPathways/compartmentPathways.mock'; import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures'; -import { MODELS_DATA_MOCK_WITH_MAIN_MAP } from '@/redux/models/models.mock'; import { StoreType } from '@/redux/store'; import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus'; import { @@ -11,8 +10,48 @@ import { import { act, render, screen, within } from '@testing-library/react'; import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; import MapBackgroundsEnum from '@/redux/map/map.enums'; +import { Project } from '@/types/models'; +import { projectFixture } from '@/models/fixtures/projectFixture'; +import { ProjectState } from '@/redux/project/project.types'; +import { PROJECT_STATE_INITIAL_MOCK } from '@/redux/project/project.mock'; +import { ModelsState } from '@/redux/models/models.types'; +import { DEFAULT_ERROR } from '@/constants/errors'; import { MapNavigation } from './MapNavigation.component'; +export const MODELS_DATA: ModelsState = { + data: [ + { + id: MAIN_MAP_ID, + width: 26779.25, + height: 13503, + defaultCenterX: null, + defaultCenterY: null, + description: '', + name: 'Core PD map', + defaultZoomLevel: null, + tileSize: 256, + references: [], + authors: [], + creationDate: null, + modificationDates: [], + minZoom: 2, + maxZoom: 9, + }, + ], + loading: 'idle', + error: DEFAULT_ERROR, +}; + +const PROJECT: Project = { + ...projectFixture, + topMap: { id: MAIN_MAP_ID }, +}; + +const PROJECT_STATE: ProjectState = { + ...PROJECT_STATE_INITIAL_MOCK, + data: PROJECT, +}; + const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState); @@ -109,6 +148,7 @@ describe('MapNavigation - component', () => { it('should close currently selected map map and open main map', async () => { const { store } = renderComponent({ + project: PROJECT_STATE, map: { data: { ...initialMapDataFixture, @@ -155,7 +195,8 @@ describe('MapNavigation - component', () => { const dispatchEventMock = jest.spyOn(PluginsEventBus, 'dispatchEvent'); renderComponent({ - models: MODELS_DATA_MOCK_WITH_MAIN_MAP, + project: { ...PROJECT_STATE }, + models: MODELS_DATA, map: { data: { ...initialMapDataFixture, @@ -175,14 +216,15 @@ describe('MapNavigation - component', () => { }); expect(dispatchEventMock).toHaveBeenCalledTimes(2); - expect(dispatchEventMock).toHaveBeenCalledWith('onSubmapClose', 5052); - expect(dispatchEventMock).toHaveBeenCalledWith('onSubmapOpen', 52); + expect(dispatchEventMock).toHaveBeenCalledWith('onSubmapClose', HISTAMINE_MAP_ID); + expect(dispatchEventMock).toHaveBeenCalledWith('onSubmapOpen', MAIN_MAP_ID); }); it('should not dispatch event if it closes not active map', async () => { const dispatchEventMock = jest.spyOn(PluginsEventBus, 'dispatchEvent'); renderComponent({ - models: MODELS_DATA_MOCK_WITH_MAIN_MAP, + project: PROJECT_STATE, + models: MODELS_DATA, map: { data: { ...initialMapDataFixture, @@ -207,7 +249,8 @@ describe('MapNavigation - component', () => { const dispatchEventMock = jest.spyOn(PluginsEventBus, 'dispatchEvent'); renderComponent({ - models: MODELS_DATA_MOCK_WITH_MAIN_MAP, + project: PROJECT_STATE, + models: MODELS_DATA, map: { data: { ...initialMapDataFixture, @@ -227,7 +270,7 @@ describe('MapNavigation - component', () => { }); expect(dispatchEventMock).toHaveBeenCalledTimes(2); - expect(dispatchEventMock).toHaveBeenCalledWith('onSubmapClose', 5052); + expect(dispatchEventMock).toHaveBeenCalledWith('onSubmapClose', HISTAMINE_MAP_ID); expect(dispatchEventMock).toHaveBeenCalledWith('onSubmapOpen', 5054); }); }); diff --git a/src/components/FunctionalArea/MapNavigation/MapNavigation.component.tsx b/src/components/FunctionalArea/MapNavigation/MapNavigation.component.tsx index e6904890f206ebdacb47bdb95c593a44687da1d2..380918b6d2e3f64441ff55579d62a4f5fb52be74 100644 --- a/src/components/FunctionalArea/MapNavigation/MapNavigation.component.tsx +++ b/src/components/FunctionalArea/MapNavigation/MapNavigation.component.tsx @@ -30,13 +30,13 @@ export const MapNavigation = (): JSX.Element => { if (isActive(map.modelId)) { dispatch( closeMapAndSetMainMapActive({ - modelId: mainMapModel.idObject, + modelId: mainMapModel.id, currentModelId: map.modelId, }), ); PluginsEventBus.dispatchEvent('onSubmapClose', map.modelId); - PluginsEventBus.dispatchEvent('onSubmapOpen', mainMapModel.idObject); + PluginsEventBus.dispatchEvent('onSubmapOpen', mainMapModel.id); } else { dispatch(closeMap({ modelId: map.modelId })); } diff --git a/src/components/FunctionalArea/Modal/EditOverlayModal/EditOverlayModal.component.test.tsx b/src/components/FunctionalArea/Modal/EditOverlayModal/EditOverlayModal.component.test.tsx index aef70523363da59b07be9b3e557582a676304c90..b06a5fe7b5517c484fb9242e0d101157edc0f2b0 100644 --- a/src/components/FunctionalArea/Modal/EditOverlayModal/EditOverlayModal.component.test.tsx +++ b/src/components/FunctionalArea/Modal/EditOverlayModal/EditOverlayModal.component.test.tsx @@ -184,8 +184,6 @@ describe('EditOverlayModal - component', () => { .onGet(apiPath.getAllUserOverlaysByCreatorQuery({ creator: 'test', publicOverlay: false })) .reply(HttpStatusCode.Ok, page); - // eslint-disable-next-line no-console - console.log(overlayFixture); const saveButton = screen.getByTestId('save-button'); expect(saveButton).toBeVisible(); await act(() => { diff --git a/src/components/FunctionalArea/Modal/LicenseModal/LicenseModal.component.tsx b/src/components/FunctionalArea/Modal/LicenseModal/LicenseModal.component.tsx index bdb79d2d85249e45549562b2d4a2d7bbef9856d8..d537b5877f7377442e320a7a06862bacb351af03 100644 --- a/src/components/FunctionalArea/Modal/LicenseModal/LicenseModal.component.tsx +++ b/src/components/FunctionalArea/Modal/LicenseModal/LicenseModal.component.tsx @@ -13,6 +13,7 @@ export const LicenseModal = (): React.ReactNode => { } return ( <div className="w-full overflow-auto border border-t-[#E1E0E6] bg-white p-[24px]"> + {/* eslint-disable-next-line react/no-danger */} <div dangerouslySetInnerHTML={{ __html: licenseDescription }} /> </div> ); diff --git a/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.test.ts b/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.test.ts index 2df46d7cbecdabf42c61a89f1ad3763da2e2b7ee..33e0afd0f1923344307fa346c7ac6c221d6c7389 100644 --- a/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.test.ts +++ b/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.test.ts @@ -18,6 +18,7 @@ import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreA import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { renderHook } from '@testing-library/react'; import MapBackgroundsEnum from '@/redux/map/map.enums'; +import { MAIN_MAP_ID } from '@/constants/mocks'; import { FIRST_ARRAY_ELEMENT, NOOP, @@ -55,7 +56,7 @@ describe('useOverviewImageLinkActions - hook', () => { map: { data: { ...initialMapDataFixture, - modelId: 5053, + modelId: MAIN_MAP_ID, }, loading: 'succeeded', error: { name: '', message: '' }, @@ -106,7 +107,7 @@ describe('useOverviewImageLinkActions - hook', () => { map: { data: { ...initialMapDataFixture, - modelId: 5053, + modelId: MAIN_MAP_ID, }, loading: 'succeeded', error: { name: '', message: '' }, @@ -164,7 +165,7 @@ describe('useOverviewImageLinkActions - hook', () => { map: { data: { ...initialMapDataFixture, - modelId: 5053, + modelId: MAIN_MAP_ID, }, loading: 'succeeded', error: { name: '', message: '' }, @@ -191,7 +192,7 @@ describe('useOverviewImageLinkActions - hook', () => { const actions = store.getActions(); expect(actions[FIRST_ARRAY_ELEMENT]).toStrictEqual({ payload: { - modelId: 5053, + modelId: MAIN_MAP_ID, }, type: 'map/setActiveMap', }); @@ -243,7 +244,7 @@ describe('useOverviewImageLinkActions - hook', () => { map: { data: { ...initialMapDataFixture, - modelId: 5053, + modelId: MAIN_MAP_ID, }, loading: 'succeeded', error: { name: '', message: '' }, @@ -270,7 +271,7 @@ describe('useOverviewImageLinkActions - hook', () => { const actions = store.getActions(); expect(actions[FIRST_ARRAY_ELEMENT]).toStrictEqual({ payload: { - modelId: 5053, + modelId: MAIN_MAP_ID, modelName: 'Core PD map', }, type: 'map/openMapAndSetActive', @@ -348,7 +349,7 @@ describe('useOverviewImageLinkActions - hook', () => { map: { data: { ...initialMapDataFixture, - modelId: 5053, + modelId: MAIN_MAP_ID, }, loading: 'succeeded', error: { name: '', message: '' }, @@ -394,7 +395,7 @@ describe('useOverviewImageLinkActions - hook', () => { map: { data: { ...initialMapDataFixture, - modelId: 5053, + modelId: MAIN_MAP_ID, position: { initial: { x: 15570.0, @@ -496,7 +497,7 @@ describe('useOverviewImageLinkActions - hook', () => { expect(dispatchEventMock).toHaveBeenCalledTimes(2); expect(dispatchEventMock).toHaveBeenCalledWith('onSubmapClose', 5054); - expect(dispatchEventMock).toHaveBeenCalledWith('onSubmapOpen', 5053); + expect(dispatchEventMock).toHaveBeenCalledWith('onSubmapOpen', MAIN_MAP_ID); }); it('should not dispatch event if provided submap to open is already opened', () => { const dispatchEventMock = jest.spyOn(PluginsEventBus, 'dispatchEvent'); @@ -520,7 +521,7 @@ describe('useOverviewImageLinkActions - hook', () => { map: { data: { ...initialMapDataFixture, - modelId: 5053, + modelId: MAIN_MAP_ID, position: { initial: { x: 15570.0, diff --git a/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.ts b/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.ts index 3b7aee8c0d297b86e612177ac145fa05398187b2..2efa284b51523cfdbe97ccd8ee5166a6165eb3c3 100644 --- a/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.ts +++ b/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.ts @@ -34,10 +34,10 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult openedMaps.some(map => map.modelId === modelId); const getModelById = (modelId: number): MapModel | undefined => - models.find(map => map.idObject === modelId); + models.find(map => map.id === modelId); const handleOpenMap = (model: MapModel): void => { - const modelId = model.idObject; + const modelId = model.id; const isMapOpened = checkIfMapAlreadyOpened(modelId); if (currentMapModelId !== modelId) { diff --git a/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsModalLayout/PublicationsModalLayout.component.test.tsx b/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsModalLayout/PublicationsModalLayout.component.test.tsx index d44c61bad6dba6ac0b6ad38e5b67dabaeb9f7c83..aa7755b5847b48ba5ab6d6b01f00fea9b15d576b 100644 --- a/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsModalLayout/PublicationsModalLayout.component.test.tsx +++ b/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsModalLayout/PublicationsModalLayout.component.test.tsx @@ -18,9 +18,9 @@ import { HttpStatusCode } from 'axios'; import { fetchElementData } from '../utils/fetchElementData'; import { PublicationsModalLayout } from './PublicationsModalLayout.component'; -const FIRST_MODEL_ID = MODELS_MOCK[FIRST_ARRAY_ELEMENT].idObject; -const SECOND_MODEL_ID = MODELS_MOCK[SECOND_ARRAY_ELEMENT].idObject; -const THIRD_MODEL_ID = MODELS_MOCK[THIRD_ARRAY_ELEMENT].idObject; +const FIRST_MODEL_ID = MODELS_MOCK[FIRST_ARRAY_ELEMENT].id; +const SECOND_MODEL_ID = MODELS_MOCK[SECOND_ARRAY_ELEMENT].id; +const THIRD_MODEL_ID = MODELS_MOCK[THIRD_ARRAY_ELEMENT].id; const FIRST_ELEMENT_ID = 100; const SECOND_ELEMENT_ID = 200; diff --git a/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsSearch/PublicationsSearch.component.tsx b/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsSearch/PublicationsSearch.component.tsx index 1c3f838d8edb79ef747dff88b55bc7b4b4f379da..dd90e7d2739b3749bcef54b53bf28775fc44b73c 100644 --- a/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsSearch/PublicationsSearch.component.tsx +++ b/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsSearch/PublicationsSearch.component.tsx @@ -42,7 +42,7 @@ export const PublicationsSearch = (): JSX.Element => { modelId: selectedId, }), ); - }, [debouncedValue, dispatch]); + }, [debouncedValue, dispatch, selectedId, sortColumn, sortOrder]); useEffect(() => { dispatch(setPublicationSearchValue(debouncedValue)); diff --git a/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/ElementsOnMapCell/ElementLink/ElementLink.component.test.tsx b/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/ElementsOnMapCell/ElementLink/ElementLink.component.test.tsx index 9ed58cb2b84d2ad88a7fdaedc5461ee34c1eaaaf..97d2050f743d011cc65b2ea63872b71861e40ceb 100644 --- a/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/ElementsOnMapCell/ElementLink/ElementLink.component.test.tsx +++ b/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/ElementsOnMapCell/ElementLink/ElementLink.component.test.tsx @@ -111,7 +111,7 @@ describe('ElementLink - component', () => { data: [ { ...modelsFixture[FIRST_ARRAY_ELEMENT], - idObject: TARGET_ELEMENT.modelId, + id: TARGET_ELEMENT.modelId, }, ], }, @@ -192,7 +192,7 @@ describe('ElementLink - component', () => { data: [ { ...modelsFixture[FIRST_ARRAY_ELEMENT], - idObject: TARGET_ELEMENT.modelId, + id: TARGET_ELEMENT.modelId, }, ], }, @@ -200,7 +200,7 @@ describe('ElementLink - component', () => { ...INITIAL_STORE_STATE_MOCK.map, data: { ...INITIAL_STORE_STATE_MOCK.map.data, - modelId: modelsFixture[FIRST_ARRAY_ELEMENT].idObject, + modelId: modelsFixture[FIRST_ARRAY_ELEMENT].id, }, openedMaps: [ { diff --git a/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/FilterBySubmapHeader/FilterBySubmapHeader.test.tsx b/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/FilterBySubmapHeader/FilterBySubmapHeader.test.tsx index 6dfca3c78f23ed04dfc05793df00d544d0842569..f238cef35c95fcd03152b257108fbaed3574c21e 100644 --- a/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/FilterBySubmapHeader/FilterBySubmapHeader.test.tsx +++ b/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/FilterBySubmapHeader/FilterBySubmapHeader.test.tsx @@ -131,7 +131,7 @@ describe('FilterBySubmapHeader - component', () => { expect(actions[FIRST_ARRAY_ELEMENT].type).toBe('publications/setSelectedModelId'); const selectedModelId = actions[FIRST_ARRAY_ELEMENT].payload; - expect(selectedModelId).toBe(String(MODELS_MOCK[FIRST_ARRAY_ELEMENT].idObject)); + expect(selectedModelId).toBe(String(MODELS_MOCK[FIRST_ARRAY_ELEMENT].id)); }); it('should dispatch getPublications action', async () => { const mockStore = configureMockStore([thunk]); diff --git a/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx b/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx index 4cc91adc374f0eb61ccc9f266a14706386f2fe58..267ad43924cfcaf50fcf840802cd121fd05a84a1 100644 --- a/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx +++ b/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx @@ -19,6 +19,7 @@ import { } from '@/utils/testing/getReduxWrapperWithStore'; import { act, render, screen } from '@testing-library/react'; import MapBackgroundsEnum from '@/redux/map/map.enums'; +import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; import { AssociatedSubmap } from './AssociatedSubmap.component'; const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { @@ -36,9 +37,6 @@ const renderComponent = (initialStoreState: InitialStoreState = {}): { store: St ); }; -const MAIN_MAP_ID = 5053; -const HISTAMINE_MAP_ID = 5052; - describe('AssociatedSubmap - component', () => { it('should not display component when can not find asociated map model', () => { renderComponent({ diff --git a/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.tsx b/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.tsx index 659ff1931abd873664b21b77246ef41e1eba86d2..ae4216066e9de25a9254ce5ddcc165a6e218728e 100644 --- a/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.tsx +++ b/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.tsx @@ -6,7 +6,7 @@ import { Button } from '@/shared/Button'; export const AssociatedSubmap = (): React.ReactNode => { const relatedSubmap = useAppSelector(currentDrawerBioEntityRelatedSubmapSelector); const { openSubmap } = useOpenSubmap({ - modelId: relatedSubmap?.idObject, + modelId: relatedSubmap?.id, modelName: relatedSubmap?.name, }); diff --git a/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx b/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx index 4c3600732baaae8b425afc46d90debcc7d291a04..7b3e3ba196c2f8c4af9ea8d3b8e1f030baeb2eae 100644 --- a/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx +++ b/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx @@ -77,6 +77,7 @@ export const BioEntityDrawer = (): React.ReactNode => { <hr className="border-b border-b-divide" /> <div className="text-sm font-normal" + /* eslint-disable-next-line react/no-danger */ dangerouslySetInnerHTML={{ __html: bioEntityData.notes }} /> </span> diff --git a/src/components/Map/Drawer/BioEntityDrawer/OverlayData/OverlayData.component.test.tsx b/src/components/Map/Drawer/BioEntityDrawer/OverlayData/OverlayData.component.test.tsx index 3704c38f3ff595b95f78a5aa0760005bb08b95bf..c03ea1423ece0344fb6bdc0c508f8d4832dd2d76 100644 --- a/src/components/Map/Drawer/BioEntityDrawer/OverlayData/OverlayData.component.test.tsx +++ b/src/components/Map/Drawer/BioEntityDrawer/OverlayData/OverlayData.component.test.tsx @@ -55,7 +55,7 @@ describe('OverlayData - component', () => { ...INITIAL_STORE_STATE_MOCK, map: { ...initialMapStateFixture, - data: { ...initialMapStateFixture.data, modelId: CORE_PD_MODEL_MOCK.idObject }, + data: { ...initialMapStateFixture.data, modelId: CORE_PD_MODEL_MOCK.id }, }, overlays: { ...INITIAL_STORE_STATE_MOCK.overlays, @@ -86,11 +86,11 @@ describe('OverlayData - component', () => { overlaysId: [OVERLAY_ID], data: { [OVERLAY_ID]: { - [CORE_PD_MODEL_MOCK.idObject]: [ + [CORE_PD_MODEL_MOCK.id]: [ { ...BIO_ENTITY, geneVariants: GENE_VARIANTS_MOCK, - modelId: CORE_PD_MODEL_MOCK.idObject, + modelId: CORE_PD_MODEL_MOCK.id, overlayId: OVERLAY_ID, }, ], @@ -127,7 +127,7 @@ describe('OverlayData - component', () => { ...INITIAL_STORE_STATE_MOCK, map: { ...initialMapStateFixture, - data: { ...initialMapStateFixture.data, modelId: CORE_PD_MODEL_MOCK.idObject }, + data: { ...initialMapStateFixture.data, modelId: CORE_PD_MODEL_MOCK.id }, }, overlays: { ...INITIAL_STORE_STATE_MOCK.overlays, @@ -158,11 +158,11 @@ describe('OverlayData - component', () => { overlaysId: [OVERLAY_ID], data: { [OVERLAY_ID]: { - [CORE_PD_MODEL_MOCK.idObject]: [ + [CORE_PD_MODEL_MOCK.id]: [ { ...BIO_ENTITY, geneVariants: GENE_VARIANTS_MOCK, - modelId: CORE_PD_MODEL_MOCK.idObject, + modelId: CORE_PD_MODEL_MOCK.id, overlayId: OVERLAY_ID, }, ], @@ -203,7 +203,7 @@ describe('OverlayData - component', () => { ...INITIAL_STORE_STATE_MOCK, map: { ...initialMapStateFixture, - data: { ...initialMapStateFixture.data, modelId: CORE_PD_MODEL_MOCK.idObject }, + data: { ...initialMapStateFixture.data, modelId: CORE_PD_MODEL_MOCK.id }, }, overlays: { ...INITIAL_STORE_STATE_MOCK.overlays, @@ -234,11 +234,11 @@ describe('OverlayData - component', () => { overlaysId: [OVERLAY_ID], data: { [OVERLAY_ID]: { - [CORE_PD_MODEL_MOCK.idObject]: [ + [CORE_PD_MODEL_MOCK.id]: [ { ...BIO_ENTITY, geneVariants: GENE_VARIANTS_MOCK, - modelId: CORE_PD_MODEL_MOCK.idObject, + modelId: CORE_PD_MODEL_MOCK.id, overlayId: OVERLAY_ID, name: 'element name', }, diff --git a/src/components/Map/Drawer/ExportDrawer/Elements/Elements.component.test.tsx b/src/components/Map/Drawer/ExportDrawer/Elements/Elements.component.test.tsx index 9fa8624b161e701d4836820a0d008319f53c1aa9..e330724197fd44992b57d51da0d3ee6b871d42d2 100644 --- a/src/components/Map/Drawer/ExportDrawer/Elements/Elements.component.test.tsx +++ b/src/components/Map/Drawer/ExportDrawer/Elements/Elements.component.test.tsx @@ -201,7 +201,7 @@ describe('Elements - component', () => { const firstAction = actions[0]; expect(firstAction.meta.arg).toEqual({ columns: ELEMENTS_COLUMNS, - submaps: modelsFixture.map(item => item.idObject), + submaps: modelsFixture.map(item => item.id), annotations: ['compartment_label'], includedCompartmentIds: [FIRST_COMPARMENT_PATHWAY_ID], excludedCompartmentIds: [SECOND_COMPARMENT_PATHWAY_ID], diff --git a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx index 295e2aee07cf4443963e5282da5fa57cfb8ead60..906dd9ee6fe55e9aaea12c5907df5ef2e9204c63 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx +++ b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx @@ -79,7 +79,7 @@ export const Export = ({ children }: ExportProps): JSX.Element => { const handleDownloadGraphics = useCallback(async () => { const modelId = models?.[FIRST_ARRAY_ELEMENT]?.id; - const model = currentModels.find(currentModel => currentModel.idObject === Number(modelId)); + const model = currentModels.find(currentModel => currentModel.id === Number(modelId)); const url = getGraphicsDownloadUrl({ backgroundId: currentBackground?.id, @@ -93,7 +93,7 @@ export const Export = ({ children }: ExportProps): JSX.Element => { if (url) { window.open(url); } - }, [models, imageFormats, currentBackground, currentModels, imageSize.width]); + }, [models, imageFormats, currentBackground, currentModels, imageSize.width, overlays]); const handleDownloadCurrentView = useCallback(async () => { const url = getGraphicsDownloadUrl({ @@ -108,7 +108,7 @@ export const Export = ({ children }: ExportProps): JSX.Element => { if (url) { window.open(url); } - }, [selectedModelId, imageFormats, currentBackground]); + }, [selectedModelId, imageFormats, currentBackground, overlays]); const globalContextDataValue = useMemo( () => ({ @@ -143,7 +143,13 @@ export const Export = ({ children }: ExportProps): JSX.Element => { handleDownloadCurrentView, data: globalContextDataValue, }), - [handleDownloadElements, handleDownloadNetwork, globalContextDataValue, handleDownloadGraphics], + [ + handleDownloadElements, + handleDownloadNetwork, + globalContextDataValue, + handleDownloadGraphics, + handleDownloadCurrentView, + ], ); return <ExportContext.Provider value={globalContextValue}>{children}</ExportContext.Provider>; diff --git a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useExportGraphicsSelectedModel.test.tsx b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useExportGraphicsSelectedModel.test.tsx index 20ac3edf4839feec27757384638b0323ad8d4ace..86b7d60235ba33a3d0c295824a959093c98fa48e 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useExportGraphicsSelectedModel.test.tsx +++ b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useExportGraphicsSelectedModel.test.tsx @@ -44,7 +44,7 @@ describe('useExportGraphicsSelectedModel - util', () => { ...EXPORT_CONTEXT_DEFAULT_VALUE.data, models: [ { - id: selectedModel.idObject.toString(), + id: selectedModel.id.toString(), label: selectedModel.name, }, ], diff --git a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useExportGraphicsSelectedModel.ts b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useExportGraphicsSelectedModel.ts index 5ee35b4c5e7f3f698e20bcc2563ca9883ec21212..b2e18ebe5fc565ba818ae959e152d9fb0c252eb1 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useExportGraphicsSelectedModel.ts +++ b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useExportGraphicsSelectedModel.ts @@ -14,5 +14,5 @@ export const useExportGraphicsSelectedModel = (): MapModel | undefined => { return undefined; } - return models.find(model => model.idObject === Number(currentSelectedModelId)); + return models.find(model => model.id === Number(currentSelectedModelId)); }; diff --git a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useImageSize.test.ts b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useImageSize.test.ts index a182496ec28a34e4a70556cf03a87ac885a16b83..11e97e36f2a7ca8d9e65258b46e131af1ff341fc 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useImageSize.test.ts +++ b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useImageSize.test.ts @@ -49,7 +49,7 @@ describe('useImageSize - hook', () => { ...EXPORT_CONTEXT_DEFAULT_VALUE.data, models: [ { - id: selectedModel.idObject.toString(), + id: selectedModel.id.toString(), label: selectedModel.name, }, ], @@ -90,7 +90,7 @@ describe('useImageSize - hook', () => { ...EXPORT_CONTEXT_DEFAULT_VALUE.data, models: [ { - id: selectedModel.idObject.toString(), + id: selectedModel.id.toString(), label: selectedModel.name, }, ], @@ -166,7 +166,7 @@ describe('useImageSize - hook', () => { ...EXPORT_CONTEXT_DEFAULT_VALUE.data, models: [ { - id: selectedModel.idObject.toString(), + id: selectedModel.id.toString(), label: selectedModel.name, }, ], diff --git a/src/components/Map/Drawer/ExportDrawer/ExportCompound/Submap/Submap.component.tsx b/src/components/Map/Drawer/ExportDrawer/ExportCompound/Submap/Submap.component.tsx index 21e1048d0de165e0554bb4dbc30cf3bc1b68ace5..c3415d75c169bf92b9a27005e8498a8c9d93215a 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportCompound/Submap/Submap.component.tsx +++ b/src/components/Map/Drawer/ExportDrawer/ExportCompound/Submap/Submap.component.tsx @@ -14,8 +14,8 @@ export const Submap = (): React.ReactNode => { const loadingModels = useAppSelector(loadingModelsSelector); const isPending = loadingModels === 'pending'; - const mappedElementAnnotations = models.map(({ idObject, name }) => ({ - id: `${idObject}`, + const mappedElementAnnotations = models.map(({ id, name }) => ({ + id: `${id}`, label: name, })); diff --git a/src/components/Map/Drawer/ExportDrawer/ExportDrawer.component.utils.tsx b/src/components/Map/Drawer/ExportDrawer/ExportDrawer.component.utils.tsx index 20e5e8711bc36f2a2c962bf1a599296c59e6f408..4dd9af712f3a00b748b22d0f5aa75982ec695320 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportDrawer.component.utils.tsx +++ b/src/components/Map/Drawer/ExportDrawer/ExportDrawer.component.utils.tsx @@ -3,5 +3,5 @@ import { MapModel } from '@/types/models'; export const getModelsIds = (models: MapModel[] | undefined): number[] => { if (!models) return []; - return models.map(model => model.idObject); + return models.map(model => model.id); }; diff --git a/src/components/Map/Drawer/ExportDrawer/ExportDrawer.utils.test.ts b/src/components/Map/Drawer/ExportDrawer/ExportDrawer.utils.test.ts index ee1aa52f9e3194b17cbdfddc9b963357211afc37..576f40406aa4fbc4123603ea8d4184324ebcba93 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportDrawer.utils.test.ts +++ b/src/components/Map/Drawer/ExportDrawer/ExportDrawer.utils.test.ts @@ -1,7 +1,7 @@ import { modelsFixture } from '@/models/fixtures/modelsFixture'; import { getModelsIds } from './ExportDrawer.component.utils'; -const MODELS_IDS = modelsFixture.map(item => item.idObject); +const MODELS_IDS = modelsFixture.map(item => item.id); describe('getModelsIds', () => { it('should return an empty array if models are not provided', () => { diff --git a/src/components/Map/Drawer/ExportDrawer/Network/Network.component.test.tsx b/src/components/Map/Drawer/ExportDrawer/Network/Network.component.test.tsx index 4bf77ac6c6bfd29c2bc9d3d2212198fedfee3f91..2fddcfedfc55f45e04a0c57d1612acb2005c3e82 100644 --- a/src/components/Map/Drawer/ExportDrawer/Network/Network.component.test.tsx +++ b/src/components/Map/Drawer/ExportDrawer/Network/Network.component.test.tsx @@ -204,7 +204,7 @@ describe('Network - component', () => { const firstAction = actions[0]; expect(firstAction.meta.arg).toEqual({ columns: NETWORK_COLUMNS, - submaps: modelsFixture.map(item => item.idObject), + submaps: modelsFixture.map(item => item.id), annotations: ['reaction'], includedCompartmentIds: [FIRST_COMPARMENT_PATHWAY_ID], excludedCompartmentIds: [SECOND_COMPARMENT_PATHWAY_ID], diff --git a/src/components/Map/Drawer/OverlaysDrawer/GeneralOverlays/OverlayListItem/OverlayListItem.component.test.tsx b/src/components/Map/Drawer/OverlaysDrawer/GeneralOverlays/OverlayListItem/OverlayListItem.component.test.tsx index 71349615ae25069bf3900598d9527ee86a47fbe8..d1080df9596b209439b1eaed1019bd47e9fef9e7 100644 --- a/src/components/Map/Drawer/OverlaysDrawer/GeneralOverlays/OverlayListItem/OverlayListItem.component.test.tsx +++ b/src/components/Map/Drawer/OverlaysDrawer/GeneralOverlays/OverlayListItem/OverlayListItem.component.test.tsx @@ -18,6 +18,7 @@ import { CORE_PD_MODEL_MOCK } from '@/models/mocks/modelsMock'; import { MODELS_INITIAL_STATE_MOCK } from '@/redux/models/models.mock'; import { parseOverlayBioEntityToOlRenderingFormat } from '@/redux/overlayBioEntity/overlayBioEntity.utils'; import { BASE_API_URL } from '@/constants'; +import { MAIN_MAP_ID } from '@/constants/mocks'; import { OverlayListItem } from './OverlayListItem.component'; const mockedAxiosNewClient = mockNetworkNewAPIResponse(); @@ -51,7 +52,6 @@ describe('OverlayListItem - component', () => { describe('view overlays', () => { it('should trigger view overlays on view button click and switch background to Empty if available', async () => { const OVERLAY_ID = 21; - const MODEL_ID = 5053; const { store } = renderComponent({ map: initialMapStateFixture, backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, @@ -59,7 +59,7 @@ describe('OverlayListItem - component', () => { models: { ...MODELS_INITIAL_STATE_MOCK, data: [CORE_PD_MODEL_MOCK] }, }); mockedAxiosNewClient - .onGet(apiPath.getOverlayBioEntity({ overlayId: OVERLAY_ID, modelId: MODEL_ID })) + .onGet(apiPath.getOverlayBioEntity({ overlayId: OVERLAY_ID, modelId: MAIN_MAP_ID })) .reply(HttpStatusCode.Ok, overlayBioEntityFixture); expect(store.getState().map.data.backgroundId).toBe(DEFAULT_BACKGROUND_ID); @@ -72,7 +72,10 @@ describe('OverlayListItem - component', () => { expect(store.getState().map.data.backgroundId).toBe(EMPTY_BACKGROUND_ID); expect(store.getState().overlayBioEntity.data).toEqual({ [OVERLAY_ID]: { - [MODEL_ID]: parseOverlayBioEntityToOlRenderingFormat(overlayBioEntityFixture, OVERLAY_ID), + [MAIN_MAP_ID]: parseOverlayBioEntityToOlRenderingFormat( + overlayBioEntityFixture, + OVERLAY_ID, + ), }, }); }); diff --git a/src/components/Map/Drawer/OverlaysDrawer/UserOverlayForm/hooks/useUserOverlayForm.ts b/src/components/Map/Drawer/OverlaysDrawer/UserOverlayForm/hooks/useUserOverlayForm.ts index 7e2bb34ee0302432ceede4ff3867147cb8beaf08..5229c9fa0cb374030ed3d5ae294d07d0062f5331 100644 --- a/src/components/Map/Drawer/OverlaysDrawer/UserOverlayForm/hooks/useUserOverlayForm.ts +++ b/src/components/Map/Drawer/OverlaysDrawer/UserOverlayForm/hooks/useUserOverlayForm.ts @@ -100,12 +100,8 @@ export const useUserOverlayForm = (): ReturnType => { filename = 'unknown.txt'; // Elements list is sent to the backend as a file, so we need to create a filename for the elements list. } - // eslint-disable-next-line no-console - console.log('x1'); if (!overlayContent || !projectId || !name) return; - // eslint-disable-next-line no-console - console.log('x2'); dispatch( addOverlay({ content: overlayContent, @@ -116,24 +112,12 @@ export const useUserOverlayForm = (): ReturnType => { type: type.id, }), ); - // eslint-disable-next-line no-console - console.log('x3'); setName(''); - // eslint-disable-next-line no-console - console.log('x3'); setDescription(''); - // eslint-disable-next-line no-console - console.log('x4'); setElementsList(''); - // eslint-disable-next-line no-console - console.log('x5'); setOverlayContent(''); - // eslint-disable-next-line no-console - console.log('x6'); setUploadedFile(null); - // eslint-disable-next-line no-console - console.log('x7'); }; return { diff --git a/src/components/Map/Drawer/ProjectInfoDrawer/ProjectInfoDrawer.component.test.tsx b/src/components/Map/Drawer/ProjectInfoDrawer/ProjectInfoDrawer.component.test.tsx index 1c24ab14aa18f6f2113a54fcf786b178484fa3e2..e887c747d55ec60341f88c3f75bae5ecc7463e1d 100644 --- a/src/components/Map/Drawer/ProjectInfoDrawer/ProjectInfoDrawer.component.test.tsx +++ b/src/components/Map/Drawer/ProjectInfoDrawer/ProjectInfoDrawer.component.test.tsx @@ -9,9 +9,16 @@ import { StoreType } from '@/redux/store'; import { MODEL_WITH_DESCRIPTION } from '@/models/mocks/modelsMock'; import { ProjectInfoDrawer } from './ProjectInfoDrawer.component'; +const PROJECT = { + ...projectFixture, + topMap: { + id: MODEL_WITH_DESCRIPTION.id, + }, +}; + const MOCKED_STORE: InitialStoreState = { project: { - data: { ...projectFixture }, + data: PROJECT, loading: 'idle', error: new Error(), projectId: '', diff --git a/src/components/Map/Drawer/ReactionDrawer/ReactionDrawer.component.tsx b/src/components/Map/Drawer/ReactionDrawer/ReactionDrawer.component.tsx index 3ab0e0dfdc18209acd093d5c80473c56de155ddb..00d2128e8b4a2bab323c1dbbdc2b3cc2c46d592d 100644 --- a/src/components/Map/Drawer/ReactionDrawer/ReactionDrawer.component.tsx +++ b/src/components/Map/Drawer/ReactionDrawer/ReactionDrawer.component.tsx @@ -40,6 +40,7 @@ export const ReactionDrawer = (): React.ReactNode => { {reaction.notes && ( <div className="text-sm font-normal" + /* eslint-disable-next-line react/no-danger */ dangerouslySetInnerHTML={{ __html: reaction.notes }} /> )} diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/BioEntitiesResultsList/BioEntitiesPinsList/BioEntitiesPinsListItem/BioEntitiesPinsListItem.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/BioEntitiesResultsList/BioEntitiesPinsList/BioEntitiesPinsListItem/BioEntitiesPinsListItem.component.test.tsx index 61c33f6c8b7ecb9f02939d0a2a766ded7cd65d1f..f5f24509780ac842173be756e754697d0be0c17d 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/BioEntitiesResultsList/BioEntitiesPinsList/BioEntitiesPinsListItem/BioEntitiesPinsListItem.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/BioEntitiesResultsList/BioEntitiesPinsList/BioEntitiesPinsListItem/BioEntitiesPinsListItem.component.test.tsx @@ -14,6 +14,7 @@ import { act } from 'react-dom/test-utils'; import { MockStoreEnhanced } from 'redux-mock-store'; import { getTypeBySBOTerm } from '@/utils/bioEntity/getTypeBySBOTerm'; import { newReactionsFixture } from '@/models/fixtures/newReactionsFixture'; +import { HISTAMINE_MAP_ID } from '@/constants/mocks'; import { BioEntitiesPinsListItem } from './BioEntitiesPinsListItem.component'; import { PinListBioEntity } from './BioEntitiesPinsListItem.types'; @@ -131,7 +132,7 @@ describe('BioEntitiesPinsListItem - component ', () => { ...MAP_INITIAL_STATE, data: { ...MAP_INITIAL_STATE.data, - modelId: 5052, + modelId: HISTAMINE_MAP_ID, size: { width: 256, height: 256, @@ -182,7 +183,7 @@ describe('BioEntitiesPinsListItem - component ', () => { ...MAP_INITIAL_STATE, data: { ...MAP_INITIAL_STATE.data, - modelId: 5052, + modelId: HISTAMINE_MAP_ID, size: { width: 256, height: 256, @@ -234,7 +235,7 @@ describe('BioEntitiesPinsListItem - component ', () => { ...MAP_INITIAL_STATE, data: { ...MAP_INITIAL_STATE.data, - modelId: 5052, + modelId: HISTAMINE_MAP_ID, size: { width: 256, height: 256, @@ -308,7 +309,7 @@ describe('BioEntitiesPinsListItem - component ', () => { ...MAP_INITIAL_STATE, data: { ...MAP_INITIAL_STATE.data, - modelId: 5052, + modelId: HISTAMINE_MAP_ID, size: { width: 256, height: 256, diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx index 0cc8a551c410b9c1c0fbef23d8f51e3b7387d4d7..62654f694d065b89073cbddd20f82e26078c8163 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx @@ -14,10 +14,9 @@ import { openedMapsThreeSubmapsFixture, } from '@/redux/map/map.fixtures'; import MapBackgroundsEnum from '@/redux/map/map.enums'; +import { MAIN_MAP_ID } from '@/constants/mocks'; import { BioEntitiesSubmapItem } from './BioEntitiesSubmapItem.component'; -const CORE_MAP_ID = 5053; - const SECOND_STEP = 2; const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { @@ -28,7 +27,7 @@ const renderComponent = (initialStoreState: InitialStoreState = {}): { store: St <Wrapper> <BioEntitiesSubmapItem mapName={MODELS_MOCK_SHORT[0].name} - mapId={MODELS_MOCK_SHORT[0].idObject} + mapId={MODELS_MOCK_SHORT[0].id} numberOfEntities={21} bioEntities={bioEntitiesContentFixture} /> @@ -112,7 +111,7 @@ describe('BioEntitiesSubmapItem - component', () => { expect(modelId).toBe(0); expect(openedMaps).not.toContainEqual({ - modelId: CORE_MAP_ID, + modelId: MAIN_MAP_ID, modelName: 'Core PD map', lastPosition: { x: 0, y: 0, z: 0 }, }); @@ -128,12 +127,12 @@ describe('BioEntitiesSubmapItem - component', () => { } = store.getState().map; expect(newOpenedMaps).toContainEqual({ - modelId: CORE_MAP_ID, + modelId: MAIN_MAP_ID, modelName: 'Core PD map', lastPosition: { x: 0, y: 0, z: 0 }, }); - expect(newModelId).toBe(CORE_MAP_ID); + expect(newModelId).toBe(MAIN_MAP_ID); }); it("should set map active if it's already opened", async () => { const { store } = renderComponent({ @@ -154,7 +153,7 @@ describe('BioEntitiesSubmapItem - component', () => { map: { data: { ...initialMapDataFixture, - modelId: CORE_MAP_ID, + modelId: MAIN_MAP_ID, }, loading: 'succeeded', error: { name: '', message: '' }, @@ -179,6 +178,6 @@ describe('BioEntitiesSubmapItem - component', () => { // eslint-disable-next-line no-magic-numbers expect(histamineMap.length).toBe(1); - expect(modelId).toBe(CORE_MAP_ID); + expect(modelId).toBe(MAIN_MAP_ID); }); }); diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/ChemicalsAccordion/ChemicalsAccordion.component.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/ChemicalsAccordion/ChemicalsAccordion.component.tsx index b4d479e500a8fae8bf0ad5419677e7b604223788..9b9e97a41ea4fefd8c8ade5ba2047e1aab3ba233 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/ChemicalsAccordion/ChemicalsAccordion.component.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/ChemicalsAccordion/ChemicalsAccordion.component.tsx @@ -33,7 +33,7 @@ export const ChemicalsAccordion = (): JSX.Element => { ); let existingChemicalTargets = 0; - list.forEach(function (drugTargetList) { + list.forEach(drugTargetList => { existingChemicalTargets += drugTargetList.length; }); diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/DrugsAccordion/DrugsAccordion.component.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/DrugsAccordion/DrugsAccordion.component.tsx index 289dfffe6c78bb69dffcd9d6b42c1ea7e6475750..53d1807c502c60aac29bac5d57fefdc484f92550 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/DrugsAccordion/DrugsAccordion.component.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/DrugsAccordion/DrugsAccordion.component.tsx @@ -33,7 +33,7 @@ export const DrugsAccordion = (): JSX.Element => { drug.targets.filter(target => target.targetElements.length > ZERO), ); let existingDrugTargets = 0; - list.forEach(function (drugTargetList) { + list.forEach(drugTargetList => { existingDrugTargets += drugTargetList.length; }); diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx index 9cfb68d823ee390908778fe25bb3c5a69fefcf72..23c0490f20fa15c7fdc196865b8b56b394d5e94b 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx @@ -12,6 +12,7 @@ import { MODELS_DATA_MOCK_WITH_MAIN_MAP } from '@/redux/models/models.mock'; import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreActionsListener'; import { MockStoreEnhanced } from 'redux-mock-store'; import MapBackgroundsEnum from '@/redux/map/map.enums'; +import { MAIN_MAP_ID } from '@/constants/mocks'; import { PinTypeWithNone } from '../PinsList.types'; import { PinsListItem } from './PinsListItem.component'; @@ -33,7 +34,7 @@ const INITIAL_STORE_STATE: InitialStoreState = { map: { data: { ...initialMapDataFixture, - modelId: 5053, + modelId: MAIN_MAP_ID, }, loading: 'succeeded', error: { message: '', name: '' }, diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.utils.ts b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.utils.ts index bbc87ce8971d920fe9086d6eb0cc88ee5ce7f3e8..26f457761b94201d5e7c45aef0e0270376aef058 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.utils.ts +++ b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.utils.ts @@ -30,7 +30,7 @@ export const getListOfAvailableSubmaps = ( const data: AvailableSubmaps = { id: submap.id, modelId: submap.model, - name: models.find(model => model.idObject === submap.model)?.name || '', + name: models.find(model => model.id === submap.model)?.name || '', }; return data; diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/hooks/useVisiblePinsPolygonCoordinates.test.ts b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/hooks/useVisiblePinsPolygonCoordinates.test.ts index f45826095806be323410a5ce0176199c35d1786d..56cee949994a68310bb02dd91d9e05bf69b67a9f 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/hooks/useVisiblePinsPolygonCoordinates.test.ts +++ b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/hooks/useVisiblePinsPolygonCoordinates.test.ts @@ -3,6 +3,7 @@ import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithSto import { renderHook } from '@testing-library/react'; import { MAP_INITIAL_STATE } from '@/redux/map/map.constants'; import { bioEntityContentFixture } from '@/models/fixtures/bioEntityContentsFixture'; +import { HISTAMINE_MAP_ID } from '@/constants/mocks'; import { useVisiblePinsPolygonCoordinates } from './useVisiblePinsPolygonCoordinates'; describe('useVisiblePinsPolygonCoordinates - hook', () => { @@ -12,7 +13,7 @@ describe('useVisiblePinsPolygonCoordinates - hook', () => { ...MAP_INITIAL_STATE, data: { ...MAP_INITIAL_STATE.data, - modelId: 5052, + modelId: HISTAMINE_MAP_ID, size: { width: 256, height: 256, @@ -36,7 +37,7 @@ describe('useVisiblePinsPolygonCoordinates - hook', () => { ...MAP_INITIAL_STATE, data: { ...MAP_INITIAL_STATE.data, - modelId: 5052, + modelId: HISTAMINE_MAP_ID, size: { width: 256, height: 256, @@ -73,7 +74,7 @@ describe('useVisiblePinsPolygonCoordinates - hook', () => { ...MAP_INITIAL_STATE, data: { ...MAP_INITIAL_STATE.data, - modelId: 5052, + modelId: HISTAMINE_MAP_ID, size: { width: 256, height: 256, @@ -97,14 +98,14 @@ describe('useVisiblePinsPolygonCoordinates - hook', () => { }, { ...bioEntityContentFixture.bioEntity, - model: 5052, + model: HISTAMINE_MAP_ID, x: 12, y: 25, z: 1, }, { ...bioEntityContentFixture.bioEntity, - model: 5052, + model: HISTAMINE_MAP_ID, x: 16, y: 16, z: 1, diff --git a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.test.tsx b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.test.tsx index a30986f5e018ce2af17e0dfd92dcf99a029c0bad..4789c9c57012174b035bc36d4296f1e8c45600e4 100644 --- a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.test.tsx +++ b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.test.tsx @@ -13,10 +13,11 @@ import { getReduxWrapperWithStore, } from '@/utils/testing/getReduxWrapperWithStore'; import { act, render, renderHook, screen } from '@testing-library/react'; +import { HISTAMINE_MAP_ID } from '@/constants/mocks'; import { DownloadSubmap } from './DownloadSubmap.component'; import { GetSubmapDownloadUrl, useGetSubmapDownloadUrl } from './utils/useGetSubmapDownloadUrl'; -const VALID_MODEL_ID = 5052; +const VALID_MODEL_ID = HISTAMINE_MAP_ID; const VALID_BACKGROUND_ID = 53; const VALID_MAX_ZOOM = 9; @@ -39,7 +40,7 @@ const getState = (): RootState => ({ data: [ { ...modelsFixture[FIRST_ARRAY_ELEMENT], - idObject: VALID_MODEL_ID, + id: VALID_MODEL_ID, }, ], }, diff --git a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.tsx b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.tsx index a498e16e65f575441b73fbc0dd0181160dd1f03f..12d1f66539f740499f12d34d0514aafe23eecbb5 100644 --- a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.tsx +++ b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.tsx @@ -22,10 +22,10 @@ export const DownloadSubmap = (): React.ReactNode => { }); const downloadSubmap = (handler: string) => { - return function () { + return () => { closeMenu(); setIsDownloading(true); - downloadFileFromUrl(getSubmapDownloadUrl({ handler })).finally(function () { + downloadFileFromUrl(getSubmapDownloadUrl({ handler })).finally(() => { setIsDownloading(false); }); }; diff --git a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.test.ts b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.test.ts index c8f335bff701d4fdeef65f9f815dcfe6dbc1fab2..8bb6e92d15dee44b86b3900049ae688d27d70c61 100644 --- a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.test.ts +++ b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.test.ts @@ -6,10 +6,11 @@ import { INITIAL_STORE_STATE_MOCK } from '@/redux/root/root.fixtures'; import { RootState } from '@/redux/store'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { renderHook } from '@testing-library/react'; +import { HISTAMINE_MAP_ID } from '@/constants/mocks'; import { useGetSubmapDownloadUrl } from './useGetSubmapDownloadUrl'; const VALID_HANDLER = 'lcsb.mapviewer.wikipathway.GpmlParser'; -const VALID_MODEL_ID = 5052; +const VALID_MODEL_ID = HISTAMINE_MAP_ID; const VALID_BACKGROUND_ID = 53; const VALID_MAX_ZOOM = 9; @@ -40,7 +41,7 @@ const getState = ({ data: [ { ...modelsFixture[FIRST_ARRAY_ELEMENT], - idObject: VALID_MODEL_ID, + id: VALID_MODEL_ID, }, ], }, @@ -110,7 +111,7 @@ describe('useGetSubmapDownloadUrl - hook', () => { } = renderHook(() => useGetSubmapDownloadUrl(), { wrapper: Wrapper }); expect(getSubmapDownloadUrl({ handler: VALID_HANDLER })).toBe( - `${BASE_API_URL}/projects/${PROJECT_ID}/models/5052:downloadModel?backgroundOverlayId=53&handlerClass=lcsb.mapviewer.wikipathway.GpmlParser&zoomLevel=9`, + `${BASE_API_URL}/projects/${PROJECT_ID}/models/${HISTAMINE_MAP_ID}:downloadModel?backgroundOverlayId=53&handlerClass=lcsb.mapviewer.wikipathway.GpmlParser&zoomLevel=9`, ); }); }); diff --git a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.ts b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.ts index e003af360c856d2e254ea8f0a1252391c7e6610d..397f7aad93a821a14f6304d4bf29e8238d2653c7 100644 --- a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.ts +++ b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.ts @@ -12,7 +12,7 @@ export const useGetSubmapDownloadUrl = (): GetSubmapDownloadUrl => { const mapSize = useSelector(mapDataSizeSelector); const getSubmapDownloadUrl: GetSubmapDownloadUrl = ({ handler }) => { - const allParamsValid = [model?.idObject, background?.id, mapSize.maxZoom, handler].reduce( + const allParamsValid = [model?.id, background?.id, mapSize.maxZoom, handler].reduce( (a, b) => Boolean(a) && Boolean(b), true, ); @@ -20,7 +20,7 @@ export const useGetSubmapDownloadUrl = (): GetSubmapDownloadUrl => { return ''; } - return `${BASE_API_URL}/projects/${PROJECT_ID}/models/${model?.idObject}:downloadModel?backgroundOverlayId=${background?.id}&handlerClass=${handler}&zoomLevel=${mapSize.maxZoom}`; + return `${BASE_API_URL}/projects/${PROJECT_ID}/models/${model?.id}:downloadModel?backgroundOverlayId=${background?.id}&handlerClass=${handler}&zoomLevel=${mapSize.maxZoom}`; }; return getSubmapDownloadUrl; diff --git a/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.test.tsx b/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.test.tsx index 825bccfd7441dd09caaa53cd50835a3434179759..492be6cb5910fe4cd26897c06eb0fbd14429e30b 100644 --- a/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.test.tsx +++ b/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.test.tsx @@ -12,11 +12,9 @@ import { openedMapsThreeSubmapsFixture, } from '@/redux/map/map.fixtures'; import MapBackgroundsEnum from '@/redux/map/map.enums'; +import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; import { SubmapsDrawer } from './SubmapsDrawer'; -const MAIN_MAP_ID = 5053; -const HISTAMINE_MAP_ID = 5052; - const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState); diff --git a/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.tsx b/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.tsx index c5c87a33f89d1ab2d1796b7a3ac223b6525788b5..c487a72df9319a2c486577fd48008df526203cb8 100644 --- a/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.tsx +++ b/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.tsx @@ -18,14 +18,14 @@ export const SubmapsDrawer = (): JSX.Element => { openedMaps.some(map => map.modelId === modelId); const onSubmapOpenClick = (model: MapModel): void => { - if (isMapAlreadyOpened(model.idObject)) { - dispatch(setActiveMap({ modelId: model.idObject })); + if (isMapAlreadyOpened(model.id)) { + dispatch(setActiveMap({ modelId: model.id })); } else { - dispatch(openMapAndSetActive({ modelId: model.idObject, modelName: model.name })); + dispatch(openMapAndSetActive({ modelId: model.id, modelName: model.name })); } - if (currentModelId !== model.idObject) { + if (currentModelId !== model.id) { PluginsEventBus.dispatchEvent('onSubmapClose', currentModelId); - PluginsEventBus.dispatchEvent('onSubmapOpen', model.idObject); + PluginsEventBus.dispatchEvent('onSubmapOpen', model.id); } }; @@ -35,7 +35,7 @@ export const SubmapsDrawer = (): JSX.Element => { <ul className="h-[calc(100%-93px)] max-h-[calc(100%-93px)] overflow-y-auto px-6"> {models.map(model => ( <SubmapItem - key={model.idObject} + key={model.id} modelName={model.name} onOpenClick={(): void => onSubmapOpenClick(model)} /> diff --git a/src/components/Map/MapAdditionalActions/utils/useAdditionalActions.test.ts b/src/components/Map/MapAdditionalActions/utils/useAdditionalActions.test.ts index 8e9ca7df324838ca3c93f6bbc0e33b19dcf05b36..a65473f78ad8b2a81a928c70a09d292d72dc70e1 100644 --- a/src/components/Map/MapAdditionalActions/utils/useAdditionalActions.test.ts +++ b/src/components/Map/MapAdditionalActions/utils/useAdditionalActions.test.ts @@ -170,7 +170,7 @@ describe('useAddtionalActions - hook', () => { ...MAP_CONFIG.zoom, tileSize: 256, }, - modelId: modelsFixture[0].idObject, + modelId: modelsFixture[0].id, }, }, }); @@ -236,7 +236,7 @@ describe('useAddtionalActions - hook', () => { ...MAP_CONFIG.zoom, tileSize: 256, }, - modelId: modelsFixture[0].idObject, + modelId: modelsFixture[0].id, }, }, }); diff --git a/src/components/Map/MapAdditionalActions/utils/useVisibleBioEntitiesPolygonCoordinates.test.ts b/src/components/Map/MapAdditionalActions/utils/useVisibleBioEntitiesPolygonCoordinates.test.ts index 8f84e5d6f681e7d13ea4f2e0ecd3f5326fd4b665..7cfb93047a9a73ad2edca9f6b92c8dde539c1120 100644 --- a/src/components/Map/MapAdditionalActions/utils/useVisibleBioEntitiesPolygonCoordinates.test.ts +++ b/src/components/Map/MapAdditionalActions/utils/useVisibleBioEntitiesPolygonCoordinates.test.ts @@ -9,6 +9,7 @@ import { INITIAL_STORE_STATE_MOCK } from '@/redux/root/root.fixtures'; import { RootState } from '@/redux/store'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { renderHook } from '@testing-library/react'; +import { HISTAMINE_MAP_ID } from '@/constants/mocks'; import { CHEMICALS_INITIAL_STATE_MOCK } from '../../../../redux/chemicals/chemicals.mock'; import { DRUGS_INITIAL_STATE_MOCK } from '../../../../redux/drugs/drugs.mock'; import { DEFAULT_POSITION, MAIN_MAP, MAP_INITIAL_STATE } from '../../../../redux/map/map.constants'; @@ -43,7 +44,7 @@ const getInitalState = ( data: [ { ...modelsFixture[0], - idObject: 5052, + id: HISTAMINE_MAP_ID, }, ], }, @@ -51,7 +52,7 @@ const getInitalState = ( ...MAP_INITIAL_STATE, data: { ...MAP_INITIAL_STATE.data, - modelId: 5052, + modelId: HISTAMINE_MAP_ID, size: { width: 256, height: 256, @@ -60,7 +61,9 @@ const getInitalState = ( maxZoom: 1, }, }, - openedMaps: [{ modelId: 5052, modelName: MAIN_MAP, lastPosition: DEFAULT_POSITION }], + openedMaps: [ + { modelId: HISTAMINE_MAP_ID, modelName: MAIN_MAP, lastPosition: DEFAULT_POSITION }, + ], }, bioEntity: { ...BIOENTITY_INITIAL_STATE_MOCK, @@ -72,7 +75,7 @@ const getInitalState = ( ...bioEntityContentFixture, bioEntity: { ...bioEntityContentFixture.bioEntity, - model: 5052, + model: HISTAMINE_MAP_ID, x: 16, y: 16, z: 1, @@ -98,7 +101,7 @@ const getInitalState = ( targetElements: [ { ...chemicalsFixture[0].targets[0].targetElements[0], - model: 5052, + model: HISTAMINE_MAP_ID, x: 32, y: 32, z: 1, @@ -122,7 +125,7 @@ const getInitalState = ( targetElements: [ { ...chemicalsFixture[0].targets[0].targetElements[0], - model: 5052, + model: HISTAMINE_MAP_ID, x: 8, y: 2, z: 9, @@ -151,7 +154,7 @@ const getInitalState = ( targetElements: [ { ...drugsFixture[0].targets[0].targetElements[0], - model: 5052, + model: HISTAMINE_MAP_ID, x: 128, y: 128, z: 1, @@ -175,7 +178,7 @@ const getInitalState = ( targetElements: [ { ...drugsFixture[0].targets[0].targetElements[0], - model: 5052, + model: HISTAMINE_MAP_ID, x: 100, y: 50, z: 4, diff --git a/src/hooks/useOpenSubmaps.ts b/src/hooks/useOpenSubmaps.ts index 85956836f72bfc8e12ef93519e6a1a3cbd7b2e2a..15b798d3604cc6c151ffaeeaac25f7bf2c34b46e 100644 --- a/src/hooks/useOpenSubmaps.ts +++ b/src/hooks/useOpenSubmaps.ts @@ -26,7 +26,7 @@ export const useOpenSubmap = ({ const currentModelId = useAppSelector(mapModelIdSelector); const isMapAlreadyOpened = openedMaps.some(map => map.modelId === modelId); - const isMapExist = models.some(model => model.idObject === modelId); + const isMapExist = models.some(model => model.id === modelId); const isItPossibleToOpenMap = modelId && modelName && isMapExist; const openSubmap = useCallback(() => { diff --git a/src/models/fixtures/modelsFixture.ts b/src/models/fixtures/modelsFixture.ts index 91bc15d71cd0b9d631fe2ceb68aa3f09ee9e557d..619692f27ae99014df726e1990af6bd4588defe5 100644 --- a/src/models/fixtures/modelsFixture.ts +++ b/src/models/fixtures/modelsFixture.ts @@ -1,15 +1,23 @@ import { ZOD_SEED } from '@/constants'; import { mapModelSchema } from '@/models/modelSchema'; -import { z } from 'zod'; // eslint-disable-next-line import/no-extraneous-dependencies import { createFixture } from 'zod-fixture'; +import { pageableSchema } from '@/models/pageableSchema'; +import { z } from 'zod'; -export const modelsFixture = createFixture(z.array(mapModelSchema), { +export const singleModelFixture = createFixture(mapModelSchema, { seed: ZOD_SEED, array: { min: 3, max: 3 }, }); -export const singleModelFixture = createFixture(mapModelSchema, { +export const modelsPageFixture = createFixture(pageableSchema(mapModelSchema), { seed: ZOD_SEED, array: { min: 3, max: 3 }, }); + +export const modelsFixture = createFixture(z.array(mapModelSchema), { + seed: ZOD_SEED, + array: { min: 3, max: 3 }, +}); + +modelsPageFixture.content = modelsFixture; diff --git a/src/models/mocks/modelsMock.ts b/src/models/mocks/modelsMock.ts index 53dac6b905d13af4459fa88d7a1f9e3fde5f8012..85e29299d2ef570b571c45a83bb73eec8e362a02 100644 --- a/src/models/mocks/modelsMock.ts +++ b/src/models/mocks/modelsMock.ts @@ -1,8 +1,9 @@ import { MapModel } from '@/types/models'; +import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; export const MODELS_MOCK: MapModel[] = [ { - idObject: 5053, + id: MAIN_MAP_ID, width: 26779.25, height: 13503.0, defaultCenterX: null, @@ -19,7 +20,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 9, }, { - idObject: 5052, + id: HISTAMINE_MAP_ID, width: 3511.09375, height: 1312.125, defaultCenterX: null, @@ -36,7 +37,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 6, }, { - idObject: 5054, + id: 5054, width: 1652.75, height: 1171.9429798877356, defaultCenterX: null, @@ -53,7 +54,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 5, }, { - idObject: 5055, + id: 5055, width: 2473.8078571428596, height: 1143.0, defaultCenterX: null, @@ -70,7 +71,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 6, }, { - idObject: 5056, + id: 5056, width: 1975.0, height: 1950.0, defaultCenterX: null, @@ -88,7 +89,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 5, }, { - idObject: 5057, + id: 5057, width: 21838.0, height: 10376.0, defaultCenterX: null, @@ -106,7 +107,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 9, }, { - idObject: 5058, + id: 5058, width: 5170.0, height: 1535.1097689075634, defaultCenterX: null, @@ -123,7 +124,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 7, }, { - idObject: 5059, + id: 5059, width: 4556.0, height: 2852.0, defaultCenterX: null, @@ -141,7 +142,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 7, }, { - idObject: 5060, + id: 5060, width: 2500.0, height: 1238.25, defaultCenterX: null, @@ -159,7 +160,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 6, }, { - idObject: 5061, + id: 5061, width: 1289.0, height: 1572.2941176470588, defaultCenterX: null, @@ -177,7 +178,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 5, }, { - idObject: 5062, + id: 5062, width: 1220.0, height: 1395.0, defaultCenterX: null, @@ -195,7 +196,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 5, }, { - idObject: 5063, + id: 5063, width: 9215.0, height: 3880.0, defaultCenterX: null, @@ -212,7 +213,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 8, }, { - idObject: 5064, + id: 5064, width: 9102.0, height: 4544.0, defaultCenterX: null, @@ -229,7 +230,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 8, }, { - idObject: 5065, + id: 5065, width: 1639.0, height: 1814.0, defaultCenterX: null, @@ -247,7 +248,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 5, }, { - idObject: 5066, + id: 5066, width: 2823.0, height: 1695.5, defaultCenterX: null, @@ -265,7 +266,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 6, }, { - idObject: 5067, + id: 5067, width: 1980.0, height: 1740.0, defaultCenterX: null, @@ -282,7 +283,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 5, }, { - idObject: 5068, + id: 5068, width: 10312.75, height: 4172.15625, defaultCenterX: null, @@ -300,7 +301,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 8, }, { - idObject: 5069, + id: 5069, width: 4368.5, height: 1644.0, defaultCenterX: null, @@ -317,7 +318,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 7, }, { - idObject: 5070, + id: 5070, width: 5092.0, height: 2947.0, defaultCenterX: null, @@ -334,7 +335,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 7, }, { - idObject: 5071, + id: 5071, width: 5497.5, height: 3699.25, defaultCenterX: null, @@ -351,7 +352,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 7, }, { - idObject: 5072, + id: 5072, width: 11529.0, height: 6911.0, defaultCenterX: null, @@ -369,7 +370,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 8, }, { - idObject: 5073, + id: 5073, width: 8081.0, height: 5096.0, defaultCenterX: null, @@ -386,7 +387,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 7, }, { - idObject: 5074, + id: 5074, width: 4498.0, height: 2653.0, defaultCenterX: null, @@ -406,7 +407,7 @@ export const MODELS_MOCK: MapModel[] = [ export const MODELS_MOCK_SHORT: MapModel[] = [ { - idObject: 5053, + id: MAIN_MAP_ID, width: 26779.25, height: 13503.0, defaultCenterX: null, @@ -423,7 +424,7 @@ export const MODELS_MOCK_SHORT: MapModel[] = [ maxZoom: 9, }, { - idObject: 5052, + id: HISTAMINE_MAP_ID, width: 3511.09375, height: 1312.125, defaultCenterX: null, @@ -440,7 +441,7 @@ export const MODELS_MOCK_SHORT: MapModel[] = [ maxZoom: 6, }, { - idObject: 5054, + id: 5054, width: 1652.75, height: 1171.9429798877356, defaultCenterX: null, @@ -459,7 +460,7 @@ export const MODELS_MOCK_SHORT: MapModel[] = [ ]; export const CORE_PD_MODEL_MOCK: MapModel = { - idObject: 5053, + id: MAIN_MAP_ID, width: 26779.25, height: 13503.0, defaultCenterX: null, @@ -478,7 +479,7 @@ export const CORE_PD_MODEL_MOCK: MapModel = { }; export const MODEL_WITH_DESCRIPTION: MapModel = { - idObject: 5056, + id: 5056, width: 1975.0, height: 1950.0, defaultCenterX: null, diff --git a/src/models/mocks/overviewImageMocks.ts b/src/models/mocks/overviewImageMocks.ts index 21571fc163bfd0a898ec8f9cd0d1f93724be5ee4..9d2b67cc00d9a03589e99899edb6c1135fa7cf17 100644 --- a/src/models/mocks/overviewImageMocks.ts +++ b/src/models/mocks/overviewImageMocks.ts @@ -1,5 +1,6 @@ import { PROJECT_OVERVIEW_IMAGE_MOCK } from '@/redux/project/project.mock'; import { OverviewImageLinkImage, OverviewImageLinkModel } from '@/types/models'; +import { MAIN_MAP_ID } from '@/constants/mocks'; export const OVERVIEW_LINK_IMAGE_MOCK: OverviewImageLinkImage = { id: 1, @@ -14,6 +15,6 @@ export const OVERVIEW_LINK_MODEL_MOCK: OverviewImageLinkModel = { zoomLevel: 5, xCoord: 15570.0, yCoord: 3016.0, - linkedModel: 5053, + linkedModel: MAIN_MAP_ID, // type: 'OverviewImageLink', }; diff --git a/src/models/modelSchema.ts b/src/models/modelSchema.ts index 107579d0d2886902df25d0e85cc816e995c603a8..feb8817bcdb664796a79c9d55813baca5a44a173 100644 --- a/src/models/modelSchema.ts +++ b/src/models/modelSchema.ts @@ -1,13 +1,14 @@ import { z } from 'zod'; +import { pageableSchema } from '@/models/pageableSchema'; import { authorSchema } from './authorSchema'; import { referenceSchema } from './referenceSchema'; export const mapModelSchema = z.object({ + /** map id */ + id: z.number(), /** name of the map */ name: z.string(), description: z.string(), - /** map id */ - idObject: z.number(), /** map width */ width: z.number(), /** map height */ @@ -20,7 +21,7 @@ export const mapModelSchema = z.object({ defaultCenterY: z.number().nullable(), /** default zoom level used in frontend visualization */ defaultZoomLevel: z.number().nullable(), - /** minimum zoom level availbale for the map */ + /** minimum zoom level available for the map */ minZoom: z.number(), /** maximum zoom level available for the map */ maxZoom: z.number(), @@ -30,3 +31,5 @@ export const mapModelSchema = z.object({ modificationDates: z.array(z.string()), vectorRendering: z.boolean().optional(), }); + +export const mapModelsSchema = pageableSchema(mapModelSchema); diff --git a/src/models/projectSchema.ts b/src/models/projectSchema.ts index 39862947ce2adb12652bc9c91eca96ee77ad35a8..eeb1f6f33a0212a9b77638bce5ec4ca39509f014 100644 --- a/src/models/projectSchema.ts +++ b/src/models/projectSchema.ts @@ -5,6 +5,7 @@ import { organism } from './organism'; import { overviewImageView } from './overviewImageView'; export const projectSchema = z.object({ + id: z.number().int().nonnegative(), version: z.string(), disease: disease.nullable(), diseaseName: z.string().nullable(), @@ -27,4 +28,7 @@ export const projectSchema = z.object({ license: z.optional(licenseSchema).nullable(), customLicenseName: z.string(), customLicenseUrl: z.string(), + topMap: z.object({ + id: z.number().int().nonnegative(), + }), }); diff --git a/src/redux/apiPath.ts b/src/redux/apiPath.ts index fa826b6a690c630591a171db2e29e8931a0aded6..7fce4e2cae2ab471cf9a7f9839d4172984c83444 100644 --- a/src/redux/apiPath.ts +++ b/src/redux/apiPath.ts @@ -43,8 +43,8 @@ export const apiPath = { `projects/${PROJECT_ID}/drugs:search?columns=${columns}&target=${target}`, getChemicalsStringWithColumnsTarget: (columns: string, target: string): string => `projects/${PROJECT_ID}/chemicals:search?columns=${columns}&target=${target}`, - getModelsString: (): string => `projects/${PROJECT_ID}/models/`, - getModelElementsForModel: (modelId: number): string => + getModelsString: (): string => `projects/${PROJECT_ID}/maps/?size=10000`, + getModelElements: (modelId: number): string => `projects/${PROJECT_ID}/maps/${modelId}/bioEntities/elements/?size=10000`, getShapes: (): string => `projects/${PROJECT_ID}/shapes/`, getLineTypes: (): string => `projects/${PROJECT_ID}/lineTypes/`, diff --git a/src/redux/bioEntity/bioEntity.mock.ts b/src/redux/bioEntity/bioEntity.mock.ts index dbc164d28b70e92c40e6192050db8029e044defc..929790fa1834f0f2e07fe5fe9659b407c9a144e6 100644 --- a/src/redux/bioEntity/bioEntity.mock.ts +++ b/src/redux/bioEntity/bioEntity.mock.ts @@ -2,6 +2,7 @@ import { DEFAULT_ERROR } from '@/constants/errors'; import { bioEntityContentFixture } from '@/models/fixtures/bioEntityContentsFixture'; import { MultiSearchData } from '@/types/fetchDataState'; import { BioEntity, BioEntityContent } from '@/types/models'; +import { HISTAMINE_MAP_ID } from '@/constants/mocks'; import { BioEntityContentsState } from './bioEntity.types'; export const BIOENTITY_INITIAL_STATE_MOCK: BioEntityContentsState = { @@ -18,7 +19,7 @@ export const BIOENTITY_INITIAL_STATE_MOCK: BioEntityContentsState = { export const BIO_ENTITY_LINKING_TO_SUBMAP: BioEntity = { ...bioEntityContentFixture.bioEntity, submodel: { - mapId: 5052, + mapId: HISTAMINE_MAP_ID, type: 'DONWSTREAM_TARGETS', }, }; diff --git a/src/redux/bioEntity/bioEntity.selectors.ts b/src/redux/bioEntity/bioEntity.selectors.ts index 5ad5c7668ee5a09f21207d172d600f6116c929a7..eb4e8f218b0c6a73fdd04872143f2e095dc62b4c 100644 --- a/src/redux/bioEntity/bioEntity.selectors.ts +++ b/src/redux/bioEntity/bioEntity.selectors.ts @@ -99,7 +99,7 @@ export const searchedFromMapBioEntityElementRelatedSubmapSelector = createSelect searchedFromMapBioEntityElement, modelsDataSelector, (bioEntity, models): MapModel | undefined => - models.find(({ idObject }) => idObject === bioEntity?.submodel?.mapId), + models.find(({ id }) => id === bioEntity?.submodel?.mapId), ); export const loadingBioEntityStatusSelector = createSelector( @@ -176,12 +176,12 @@ export const bioEntitiesPerModelSelector = createSelector( (bioEntities, models) => { const bioEntitiesPerModelPerSearchElement = (models || []).map(model => { const bioEntitiesInGivenModel = (bioEntities?.data || []).filter( - entity => model.idObject === entity.bioEntity.model, + entity => model.id === entity.bioEntity.model, ); return { modelName: model.name, - modelId: model.idObject, + modelId: model.id, numberOfEntities: bioEntitiesInGivenModel.length, bioEntities: bioEntitiesInGivenModel, }; @@ -279,7 +279,7 @@ export const currentDrawerBioEntityRelatedSubmapSelector = createSelector( currentDrawerBioEntitySelector, modelsDataSelector, (bioEntity, models): MapModel | undefined => - models.find(({ idObject }) => idObject === bioEntity?.submodel?.mapId), + models.find(({ id }) => id === bioEntity?.submodel?.mapId), ); export const allSubmapConnectionsBioEntityOfCurrentSubmapWithRealConnectionsSelector = diff --git a/src/redux/compartmentPathways/compartmentPathways.mock.ts b/src/redux/compartmentPathways/compartmentPathways.mock.ts index 6d62817d1c2ee3f81c4fd806f37996c7c2ed99ff..8d088c4c54077c0db8aab5c76b358989c45c8229 100644 --- a/src/redux/compartmentPathways/compartmentPathways.mock.ts +++ b/src/redux/compartmentPathways/compartmentPathways.mock.ts @@ -1,4 +1,5 @@ import { MapModel } from '@/types/models'; +import { MAIN_MAP_ID } from '@/constants/mocks'; import { CompartmentPathwaysState } from './compartmentPathways.types'; export const COMPARTMENT_PATHWAYS_INITIAL_STATE_MOCK: CompartmentPathwaysState = { @@ -8,7 +9,7 @@ export const COMPARTMENT_PATHWAYS_INITIAL_STATE_MOCK: CompartmentPathwaysState = }; export const MODELS_MOCK: MapModel[] = [ { - idObject: 5053, + id: MAIN_MAP_ID, width: 26779.25, height: 13503.0, defaultCenterX: null, @@ -25,7 +26,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 9, }, { - idObject: 5054, + id: 5054, width: 26779.25, height: 13503.0, defaultCenterX: null, @@ -45,7 +46,7 @@ export const MODELS_MOCK: MapModel[] = [ export const MODELS_MOCK_SHORT: MapModel[] = [ { - idObject: 5050, + id: 5050, width: 26779.25, height: 13503.0, defaultCenterX: null, diff --git a/src/redux/compartmentPathways/compartmentPathways.reducers.test.ts b/src/redux/compartmentPathways/compartmentPathways.reducers.test.ts index 1df36392927a3d24ea6fd7b64d7e11043c11a205..8cfdf6eedbab0ddce7bc5c5fa3212d7b733bc3d5 100644 --- a/src/redux/compartmentPathways/compartmentPathways.reducers.test.ts +++ b/src/redux/compartmentPathways/compartmentPathways.reducers.test.ts @@ -12,6 +12,7 @@ import { } from '@/models/fixtures/compartmentPathways'; import { getModelsIds } from '@/components/Map/Drawer/ExportDrawer/ExportDrawer.component.utils'; import { unwrapResult } from '@reduxjs/toolkit'; +import { MAIN_MAP_ID } from '@/constants/mocks'; import { apiPath } from '../apiPath'; import compartmentPathwaysReducer from './compartmentPathways.slice'; import { CompartmentPathwaysState } from './compartmentPathways.types'; @@ -62,7 +63,7 @@ describe('compartmentPathways reducer', () => { it('should update store after succesful getCompartmentPathways query', async () => { mockedAxiosClient - .onGet(apiPath.getCompartmentPathwaysIds(5053)) + .onGet(apiPath.getCompartmentPathwaysIds(MAIN_MAP_ID)) .reply(HttpStatusCode.Ok, compartmentPathwaysFixture); mockedAxiosClient .onGet(apiPath.getCompartmentPathwaysIds(5054)) @@ -98,7 +99,7 @@ describe('compartmentPathways reducer', () => { it('should update store after failed getCompartmentPathways query', async () => { mockedAxiosClient - .onGet(apiPath.getCompartmentPathwaysIds(5053)) + .onGet(apiPath.getCompartmentPathwaysIds(MAIN_MAP_ID)) .reply(HttpStatusCode.NotFound, []); mockedAxiosClient .onGet(apiPath.getCompartmentPathwayDetails([])) diff --git a/src/redux/compartmentPathways/compartmentPathways.thunks.test.ts b/src/redux/compartmentPathways/compartmentPathways.thunks.test.ts index 407eb70d6a20ff4abb36a2408b2a0eb388c084b3..891eeb38c70c9a8659d6123f3592c8e8305f27e3 100644 --- a/src/redux/compartmentPathways/compartmentPathways.thunks.test.ts +++ b/src/redux/compartmentPathways/compartmentPathways.thunks.test.ts @@ -11,6 +11,7 @@ import { compartmentPathwaysOverLimitFixture, } from '@/models/fixtures/compartmentPathways'; import { getModelsIds } from '@/components/Map/Drawer/ExportDrawer/ExportDrawer.component.utils'; +import { MAIN_MAP_ID } from '@/constants/mocks'; import { apiPath } from '../apiPath'; import compartmentPathwaysReducer from './compartmentPathways.slice'; import { CompartmentPathwaysState } from './compartmentPathways.types'; @@ -57,7 +58,7 @@ describe('compartmentPathways thunk', () => { }); it('should handle sendCompartmentPathwaysIds request properly if it is more than 100 ids', async () => { mockedAxiosClient - .onGet(apiPath.getCompartmentPathwaysIds(5053)) + .onGet(apiPath.getCompartmentPathwaysIds(MAIN_MAP_ID)) .reply(HttpStatusCode.Ok, compartmentPathwaysFixture); mockedAxiosClient .onGet(apiPath.getCompartmentPathwaysIds(5054)) @@ -93,7 +94,7 @@ describe('compartmentPathways thunk', () => { it('should not do a network request sendCompartmentPathwaysIds if it is less than 100 ids', async () => { const ONE_MODEL = MODELS_MOCK_SHORT[0]; - const ID = ONE_MODEL.idObject; + const ID = ONE_MODEL.id; mockedAxiosClient .onGet(apiPath.getCompartmentPathwaysIds(ID)) @@ -107,7 +108,7 @@ describe('compartmentPathways thunk', () => { .onPost(apiPath.sendCompartmentPathwaysIds()) .reply(HttpStatusCode.Ok, compartmentPathwaysDetailsFixture); - const compartmentPathwaysPromise = store.dispatch(getCompartmentPathways([ONE_MODEL.idObject])); + const compartmentPathwaysPromise = store.dispatch(getCompartmentPathways([ONE_MODEL.id])); const { loading, data } = store.getState().compartmentPathways; diff --git a/src/redux/map/map.fixtures.ts b/src/redux/map/map.fixtures.ts index 268b7f9db2dcee081ac83c53235500c70d028863..21674c65af5aac7d322980696da5e9acf65c84ed 100644 --- a/src/redux/map/map.fixtures.ts +++ b/src/redux/map/map.fixtures.ts @@ -1,6 +1,7 @@ import { DEFAULT_ERROR } from '@/constants/errors'; import { MODEL_ID_DEFAULT } from '@/redux/map/map.constants'; import MapBackgroundsEnum from '@/redux/map/map.enums'; +import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; import { MapData, MapState, OppenedMap } from './map.types'; export const openedMapsInitialValueFixture: OppenedMap[] = [ @@ -8,8 +9,12 @@ export const openedMapsInitialValueFixture: OppenedMap[] = [ ]; export const openedMapsThreeSubmapsFixture: OppenedMap[] = [ - { modelId: 5053, modelName: 'Main map', lastPosition: { x: 0, y: 0, z: 0 } }, - { modelId: 5052, modelName: 'Histamine signaling', lastPosition: { x: 0, y: 0, z: 0 } }, + { modelId: MAIN_MAP_ID, modelName: 'Main map', lastPosition: { x: 0, y: 0, z: 0 } }, + { + modelId: HISTAMINE_MAP_ID, + modelName: 'Histamine signaling', + lastPosition: { x: 0, y: 0, z: 0 }, + }, { modelId: 5054, modelName: 'PRKN substrates', lastPosition: { x: 0, y: 0, z: 0 } }, ]; diff --git a/src/redux/map/map.thunks.test.ts b/src/redux/map/map.thunks.test.ts index c8bd15b1daf46ccec5383edbd55f11f352cf4548..b44d0fd824b9540377b335ebefaded9cd727a8b7 100644 --- a/src/redux/map/map.thunks.test.ts +++ b/src/redux/map/map.thunks.test.ts @@ -1,6 +1,11 @@ import { MODELS_MOCK } from '@/models/mocks/modelsMock'; /* eslint-disable no-magic-numbers */ import { QueryData } from '@/types/query'; +import { projectFixture } from '@/models/fixtures/projectFixture'; +import { Project } from '@/types/models'; +import { PROJECT_STATE_INITIAL_MOCK } from '@/redux/project/project.mock'; +import { ProjectState } from '@/redux/project/project.types'; +import { MAIN_MAP_ID } from '@/constants/mocks'; import { BACKGROUNDS_MOCK, BACKGROUND_INITIAL_STATE_MOCK } from '../backgrounds/background.mock'; import { MODELS_INITIAL_STATE_MOCK } from '../models/models.mock'; import { INITIAL_STORE_STATE_MOCK } from '../root/root.fixtures'; @@ -45,8 +50,19 @@ const QUERY_DATA_WITH_POSITION: QueryData = { perfectMatch: false, }; +const PROJECT: Project = { + ...projectFixture, + topMap: { id: MAIN_MAP_ID }, +}; + +const PROJECT_STATE: ProjectState = { + ...PROJECT_STATE_INITIAL_MOCK, + data: PROJECT, +}; + const STATE_WITH_MODELS: RootState = { ...INITIAL_STORE_STATE_MOCK, + project: { ...PROJECT_STATE }, models: { ...MODELS_INITIAL_STATE_MOCK, data: MODELS_MOCK }, }; @@ -117,7 +133,7 @@ describe('map thunks - utils', () => { it('should return correct map size and modelId if query params do not include modelId', () => { const payload = getInitMapSizeAndModelId(STATE_WITH_MODELS, EMPTY_QUERY_DATA); expect(payload).toEqual({ - modelId: 5053, + modelId: MAIN_MAP_ID, size: { height: 13503, maxZoom: 9, @@ -133,7 +149,7 @@ describe('map thunks - utils', () => { modelId: 1234567, }); expect(payload).toEqual({ - modelId: 5053, + modelId: MAIN_MAP_ID, size: { height: 13503, maxZoom: 9, @@ -150,13 +166,16 @@ describe('map thunks - utils', () => { const openedMaps = getOpenedMaps( { ...STATE_WITH_MODELS, - map: { ...initialMapStateFixture, data: { ...initialMapDataFixture, modelId: 5053 } }, + map: { + ...initialMapStateFixture, + data: { ...initialMapDataFixture, modelId: MAIN_MAP_ID }, + }, }, EMPTY_QUERY_DATA, ); expect(openedMaps).toEqual([ - { lastPosition: { x: 0, y: 0, z: 0 }, modelId: 5053, modelName: 'Main map' }, + { lastPosition: { x: 0, y: 0, z: 0 }, modelId: MAIN_MAP_ID, modelName: 'Main map' }, ]); }); it('should return main map and opened submap', () => { @@ -169,7 +188,7 @@ describe('map thunks - utils', () => { ); expect(openedMaps).toEqual([ - { lastPosition: { x: 0, y: 0, z: 0 }, modelId: 5053, modelName: 'Main map' }, + { lastPosition: { x: 0, y: 0, z: 0 }, modelId: MAIN_MAP_ID, modelName: 'Main map' }, { lastPosition: { x: 0, diff --git a/src/redux/map/map.thunks.ts b/src/redux/map/map.thunks.ts index fb0f3dc69a73c3041973f3c97340ff204cc55270..363b1d9c02c8479a01abf2a8f91078125c52b621 100644 --- a/src/redux/map/map.thunks.ts +++ b/src/redux/map/map.thunks.ts @@ -67,14 +67,14 @@ export const getBackgroundId = (state: RootState, queryData: QueryData): number export const getModelId = (state: RootState, queryData: QueryData): number => { const mainMapModel = mainMapModelSelector(state); const models = modelsDataSelector(state); - let modelId = queryData?.modelId || mainMapModel?.idObject || ZERO; + let modelId = queryData?.modelId || mainMapModel?.id || ZERO; if (models.length > 0) { if ( models.filter(model => { - return model.idObject === modelId; + return model.id === modelId; }).length === 0 ) { - modelId = models[ZERO].idObject; + modelId = models[ZERO].id; } } return modelId; @@ -103,14 +103,14 @@ export const getInitMapPosition = (state: RootState, queryData: QueryData): Posi if (mergedPosition.z && mergedPosition.z !== defaultPosition.z) { PluginsEventBus.dispatchEvent('onZoomChanged', { - modelId: currentModel.idObject, + modelId: currentModel.id, zoom: mergedPosition.z, }); } if (mergedPosition.x !== defaultPosition.x || mergedPosition.y !== defaultPosition.y) { PluginsEventBus.dispatchEvent('onCenterChanged', { - modelId: currentModel.idObject, + modelId: currentModel.id, x: mergedPosition.x, y: mergedPosition.y, }); @@ -130,12 +130,12 @@ export const getInitMapSizeAndModelId = ( const modelId = getModelId(state, queryData); const currentModel = modelByIdSelector(state, modelId); - if (modelId !== mainMapModel?.idObject) { + if (modelId !== mainMapModel?.id) { PluginsEventBus.dispatchEvent('onSubmapOpen', modelId); } return { - modelId: currentModel?.idObject || ZERO, + modelId: currentModel?.id || ZERO, size: { width: currentModel?.width || ZERO, height: currentModel?.height || ZERO, @@ -147,20 +147,18 @@ export const getInitMapSizeAndModelId = ( }; export const getOpenedMaps = (state: RootState, queryData: QueryData): OppenedMap[] => { - const FIRST = 0; - const models = modelsDataSelector(state); const currentModel = currentModelSelector(state); - const mainMapId = models?.[FIRST]?.idObject || ZERO; + const mainMap = mainMapModelSelector(state); const openedMaps: OppenedMap[] = [ - { modelId: mainMapId, modelName: MAIN_MAP, lastPosition: DEFAULT_POSITION }, + { modelId: mainMap.id, modelName: MAIN_MAP, lastPosition: DEFAULT_POSITION }, ]; - const isMainMapSetAsCurrentModel = currentModel?.idObject !== mainMapId; + const isMainMapSetAsCurrentModel = currentModel?.id !== mainMap.id; if (isMainMapSetAsCurrentModel) { openedMaps.push({ - modelId: currentModel?.idObject || ZERO, + modelId: currentModel?.id || ZERO, modelName: currentModel?.name || '', lastPosition: { ...DEFAULT_POSITION, ...queryData.initialPosition }, }); diff --git a/src/redux/map/middleware/getUpdatedModel.test.ts b/src/redux/map/middleware/getUpdatedModel.test.ts index 65cd7f25616a14c8722c967f7bf850fd70174629..c3d4ca2a4863807a5213d9fb53d1200e9c0cd9e7 100644 --- a/src/redux/map/middleware/getUpdatedModel.test.ts +++ b/src/redux/map/middleware/getUpdatedModel.test.ts @@ -18,7 +18,7 @@ describe('getUpdatedModel - util', () => { const action = { type: MIDDLEWARE_ALLOWED_ACTIONS[0], payload: { - modelId: model.idObject, + modelId: model.id, }, }; diff --git a/src/redux/map/middleware/getUpdatedModel.ts b/src/redux/map/middleware/getUpdatedModel.ts index 4302c5525250f2d1fe9f980a5359d897ab3f3ef6..a2b25dc7fdad944927f29bfed1cb319f5c128462 100644 --- a/src/redux/map/middleware/getUpdatedModel.ts +++ b/src/redux/map/middleware/getUpdatedModel.ts @@ -8,5 +8,5 @@ export const getUpdatedModel = (action: Action, state: RootState): MapModel | un const models = modelsDataSelector(state); const payloadModelId = getModelIdFromAction(action); - return models.find(model => model.idObject === payloadModelId); + return models.find(model => model.id === payloadModelId); }; diff --git a/src/redux/map/middleware/map.middleware.test.ts b/src/redux/map/middleware/map.middleware.test.ts index 835c5e2ddcabf9d581cbaf1760731d34fb248b7b..cb928afd24b3272fe030444861946c6c5ceaf95a 100644 --- a/src/redux/map/middleware/map.middleware.test.ts +++ b/src/redux/map/middleware/map.middleware.test.ts @@ -61,7 +61,7 @@ const { store } = getReduxWrapperWithStore({ ...defaultSliceState, data: { ...MAP_DATA_INITIAL_STATE, - modelId: modelsFixture[0].idObject, + modelId: modelsFixture[0].id, }, openedMaps: OPENED_MAPS_INITIAL_STATE, backgroundType: MapBackgroundsEnum.SEMANTIC, @@ -94,7 +94,7 @@ describe('map middleware', () => { const action = { payload: { - modelId: model.idObject, + modelId: model.id, }, type: actionType, }; @@ -112,7 +112,7 @@ describe('map middleware', () => { const model = modelsFixture[0]; const action = { payload: { - modelId: model.idObject, + modelId: model.id, }, type: actionType, }; diff --git a/src/redux/map/middleware/map.middleware.ts b/src/redux/map/middleware/map.middleware.ts index 92fce878e1bd98a817f7004acb633ef24f1f619e..bacbb729dd6ff290e3861487912d61f071d9ea32 100644 --- a/src/redux/map/middleware/map.middleware.ts +++ b/src/redux/map/middleware/map.middleware.ts @@ -32,7 +32,7 @@ export const mapDataMiddlewareListener = async ( } const background = currentBackgroundSelector(state); - const modelId = updatedModel.idObject; + const modelId = updatedModel.id; const lastPosition = mapOpenedMapPositionByIdSelector(state, modelId); const updatedMapData = getUpdatedMapData({ model: updatedModel, diff --git a/src/redux/modelElements/modelElements.reducers.test.ts b/src/redux/modelElements/modelElements.reducers.test.ts index fc5c5a6fe505f8861e49553e2ace08268f6791eb..c6c516372c6c6f027709aab7fde2993af47aa3c5 100644 --- a/src/redux/modelElements/modelElements.reducers.test.ts +++ b/src/redux/modelElements/modelElements.reducers.test.ts @@ -28,7 +28,7 @@ describe('model elements reducer', () => { it('should update store after successful getModelElementsForModel query', async () => { mockedAxiosClient - .onGet(apiPath.getModelElementsForModel(0)) + .onGet(apiPath.getModelElements(0)) .reply(HttpStatusCode.Ok, modelElementsFixture); const { type } = await store.dispatch(getModelElementsForModel(0)); @@ -41,7 +41,7 @@ describe('model elements reducer', () => { }); it('should update store after failed getModelElementsForModel query', async () => { - mockedAxiosClient.onGet(apiPath.getModelElementsForModel(0)).reply(HttpStatusCode.NotFound, []); + mockedAxiosClient.onGet(apiPath.getModelElements(0)).reply(HttpStatusCode.NotFound, []); const action = await store.dispatch(getModelElementsForModel(0)); const { data, loading, error } = store.getState().modelElements[0]; @@ -57,7 +57,7 @@ describe('model elements reducer', () => { it('should update store on loading getModelElementsForModel query', async () => { mockedAxiosClient - .onGet(apiPath.getModelElementsForModel(0)) + .onGet(apiPath.getModelElements(0)) .reply(HttpStatusCode.Ok, modelElementsFixture); const modelElementsPromise = store.dispatch(getModelElementsForModel(0)); diff --git a/src/redux/modelElements/modelElements.thunks.test.ts b/src/redux/modelElements/modelElements.thunks.test.ts index 0ba825c9f3d9a31f2d6f1d1e852d57fddc79464c..cb0c5c52b057ca7f95c6e09e1e3c7685778bfd1f 100644 --- a/src/redux/modelElements/modelElements.thunks.test.ts +++ b/src/redux/modelElements/modelElements.thunks.test.ts @@ -22,7 +22,7 @@ describe('model elements thunks', () => { describe('getModelElementsForModel', () => { it('should return data when data response from API is valid', async () => { mockedAxiosClient - .onGet(apiPath.getModelElementsForModel(0)) + .onGet(apiPath.getModelElements(0)) .reply(HttpStatusCode.Ok, modelElementsFixture); const { payload } = await store.dispatch(getModelElementsForModel(0)); @@ -31,7 +31,7 @@ describe('model elements thunks', () => { it('should return undefined when data response from API is not valid ', async () => { mockedAxiosClient - .onGet(apiPath.getModelElementsForModel(0)) + .onGet(apiPath.getModelElements(0)) .reply(HttpStatusCode.Ok, { randomProperty: 'randomValue' }); const { payload } = await store.dispatch(getModelElementsForModel(0)); diff --git a/src/redux/modelElements/modelElements.thunks.ts b/src/redux/modelElements/modelElements.thunks.ts index 210b65600cac6aeddb439298bb82534696302d55..fb1a3c2ee8ef716261d8cca78dc6e51c98e5ff1d 100644 --- a/src/redux/modelElements/modelElements.thunks.ts +++ b/src/redux/modelElements/modelElements.thunks.ts @@ -16,7 +16,7 @@ export const getModelElementsForModel = createAsyncThunk< >('vectorMap/getModelElementsForModel', async (modelId: number) => { try { const { data } = await axiosInstanceNewAPI.get<ModelElements>( - apiPath.getModelElementsForModel(modelId), + apiPath.getModelElements(modelId), ); const isDataValid = validateDataUsingZodSchema(data, pageableSchema(modelElementSchema)); return isDataValid ? data.content : undefined; diff --git a/src/redux/models/models.mock.ts b/src/redux/models/models.mock.ts index b7658d3867c9d80e221fa59ffd8507c51b0cf46d..dd426993f05308c93cf439f1b036f419100bf801 100644 --- a/src/redux/models/models.mock.ts +++ b/src/redux/models/models.mock.ts @@ -10,7 +10,7 @@ export const MODELS_INITIAL_STATE_MOCK: ModelsState = { export const MODELS_DATA_MOCK_WITH_MAIN_MAP: ModelsState = { data: [ { - idObject: 52, + id: 52, width: 26779.25, height: 13503, defaultCenterX: null, diff --git a/src/redux/models/models.reducers.test.ts b/src/redux/models/models.reducers.test.ts index c25cd72d4bff9e4510cbb0b6b596201c13831ec1..b4610360b40f5ae6cfdf7eba5b9bf8e8c03408f3 100644 --- a/src/redux/models/models.reducers.test.ts +++ b/src/redux/models/models.reducers.test.ts @@ -1,17 +1,17 @@ -import { modelsFixture } from '@/models/fixtures/modelsFixture'; +import { modelsFixture, modelsPageFixture } from '@/models/fixtures/modelsFixture'; import { apiPath } from '@/redux/apiPath'; import { ToolkitStoreWithSingleSlice, createStoreInstanceUsingSliceReducer, } from '@/utils/createStoreInstanceUsingSliceReducer'; -import { mockNetworkResponse } from '@/utils/mockNetworkResponse'; +import { mockNetworkNewAPIResponse } from '@/utils/mockNetworkResponse'; import { HttpStatusCode } from 'axios'; import { unwrapResult } from '@reduxjs/toolkit'; import modelsReducer from './models.slice'; import { getModels } from './models.thunks'; import { ModelsState } from './models.types'; -const mockedAxiosClient = mockNetworkResponse(); +const mockedAxiosNEWApiClient = mockNetworkNewAPIResponse(); const INITIAL_STATE: ModelsState = { data: [], @@ -30,8 +30,10 @@ describe('models reducer', () => { expect(modelsReducer(undefined, action)).toEqual(INITIAL_STATE); }); - it('should update store after succesfull getModels query', async () => { - mockedAxiosClient.onGet(apiPath.getModelsString()).reply(HttpStatusCode.Ok, modelsFixture); + it('should update store after successfull getModels query', async () => { + mockedAxiosNEWApiClient + .onGet(apiPath.getModelsString()) + .reply(HttpStatusCode.Ok, modelsPageFixture); const { type } = await store.dispatch(getModels()); const { data, loading, error } = store.getState().models; @@ -43,7 +45,7 @@ describe('models reducer', () => { }); it('should update store after failed getModels query', async () => { - mockedAxiosClient.onGet(apiPath.getModelsString()).reply(HttpStatusCode.NotFound, []); + mockedAxiosNEWApiClient.onGet(apiPath.getModelsString()).reply(HttpStatusCode.NotFound, []); const action = await store.dispatch(getModels()); const { data, loading, error } = store.getState().models; @@ -58,7 +60,9 @@ describe('models reducer', () => { }); it('should update store on loading getModels query', async () => { - mockedAxiosClient.onGet(apiPath.getModelsString()).reply(HttpStatusCode.Ok, modelsFixture); + mockedAxiosNEWApiClient + .onGet(apiPath.getModelsString()) + .reply(HttpStatusCode.Ok, modelsPageFixture); const modelsPromise = store.dispatch(getModels()); diff --git a/src/redux/models/models.reducers.ts b/src/redux/models/models.reducers.ts index ee7b9a63f5ac133a8b5fcfa6bf6f936698fb1305..054b4c0b1430bed549994d83addc7adb5552fb85 100644 --- a/src/redux/models/models.reducers.ts +++ b/src/redux/models/models.reducers.ts @@ -22,7 +22,7 @@ export const setModelVectorRenderingReducer = ( action: PayloadAction<{ vectorRendering: boolean; mapId: number }>, ): void => { const { payload } = action; - const modelIndex = state.data.findIndex(model => model.idObject === payload.mapId); + const modelIndex = state.data.findIndex(model => model.id === payload.mapId); if (modelIndex !== -1) { state.data[modelIndex].vectorRendering = payload.vectorRendering; } diff --git a/src/redux/models/models.selectors.ts b/src/redux/models/models.selectors.ts index 95a3c8841a0f2e824896c9cb7ea2ef5cc8010d99..606aa70ee36712b44b78d45580afa1d80a26c5d3 100644 --- a/src/redux/models/models.selectors.ts +++ b/src/redux/models/models.selectors.ts @@ -1,5 +1,7 @@ import { rootSelector } from '@/redux/root/root.selectors'; import { createSelector } from '@reduxjs/toolkit'; +import { projectDataSelector } from '@/redux/project/project.selectors'; +import { ZERO } from '@/constants/common'; import { MODEL_ID_DEFAULT } from '../map/map.constants'; import { mapDataSelector } from '../map/map.selectors'; @@ -10,27 +12,24 @@ export const modelsDataSelector = createSelector(modelsSelector, models => model export const currentModelSelector = createSelector( modelsDataSelector, mapDataSelector, - (models, mapData) => models.find(model => model.idObject === mapData.modelId), + (models, mapData) => models.find(model => model.id === mapData.modelId), ); export const modelsIdsSelector = createSelector(modelsDataSelector, models => - models.map(model => model.idObject), + models.map(model => model.id), ); export const modelsNameMapSelector = createSelector(modelsDataSelector, models => - models.reduce( - (acc, model) => ({ ...acc, [model.idObject]: model.name }), - {} as Record<number, string>, - ), + models.reduce((acc, model) => ({ ...acc, [model.id]: model.name }), {} as Record<number, string>), ); export const modelsIdsAndNamesSelector = createSelector(modelsDataSelector, models => - models.map(({ idObject, name }) => ({ id: idObject, name })), + models.map(({ id, name }) => ({ id, name })), ); export const currentModelIdSelector = createSelector( currentModelSelector, - model => model?.idObject || MODEL_ID_DEFAULT, + model => model?.id || MODEL_ID_DEFAULT, ); export const lastClickSelector = createSelector(mapDataSelector, mapData => mapData.lastClick); @@ -46,17 +45,23 @@ export const currentModelNameSelector = createSelector( export const modelByIdSelector = createSelector( [modelsSelector, (_state, modelId: number): number => modelId], - (models, modelId) => (models?.data || []).find(({ idObject }) => idObject === modelId), + (models, modelId) => (models?.data || []).find(({ id }) => id === modelId), ); -const MAIN_MAP = 0; -export const mainMapModelSelector = createSelector(modelsDataSelector, models => models[MAIN_MAP]); +export const mainMapModelSelector = createSelector( + projectDataSelector, + modelsDataSelector, + (project, models) => { + const topMapId = project?.topMap.id; + return models.filter(model => model.id === topMapId)[ZERO]; + }, +); export const loadingModelsSelector = createSelector(modelsSelector, state => state.loading); export const mainMapModelDescriptionSelector = createSelector( - modelsDataSelector, - models => models[MAIN_MAP].description, + mainMapModelSelector, + model => model?.description, ); export const vectorRenderingSelector = createSelector( diff --git a/src/redux/models/models.thunks.test.ts b/src/redux/models/models.thunks.test.ts index a8daf71d82f9a7ef7bd229df4afe8947e9c6c38a..4ad436aabc1602d6ecf971bb21aa5f8a9f1565a4 100644 --- a/src/redux/models/models.thunks.test.ts +++ b/src/redux/models/models.thunks.test.ts @@ -1,16 +1,16 @@ -import { modelsFixture } from '@/models/fixtures/modelsFixture'; +import { modelsFixture, modelsPageFixture } from '@/models/fixtures/modelsFixture'; import { apiPath } from '@/redux/apiPath'; import { ModelsState } from '@/redux/models/models.types'; import { ToolkitStoreWithSingleSlice, createStoreInstanceUsingSliceReducer, } from '@/utils/createStoreInstanceUsingSliceReducer'; -import { mockNetworkResponse } from '@/utils/mockNetworkResponse'; +import { mockNetworkNewAPIResponse } from '@/utils/mockNetworkResponse'; import { HttpStatusCode } from 'axios'; import modelsReducer from './models.slice'; import { getModels } from './models.thunks'; -const mockedAxiosClient = mockNetworkResponse(); +const mockedAxiosNEWApiClient = mockNetworkNewAPIResponse(); describe('models thunks', () => { let store = {} as ToolkitStoreWithSingleSlice<ModelsState>; @@ -19,13 +19,15 @@ describe('models thunks', () => { }); describe('getModels', () => { it('should return data when data response from API is valid', async () => { - mockedAxiosClient.onGet(apiPath.getModelsString()).reply(HttpStatusCode.Ok, modelsFixture); + mockedAxiosNEWApiClient + .onGet(apiPath.getModelsString()) + .reply(HttpStatusCode.Ok, modelsPageFixture); const { payload } = await store.dispatch(getModels()); expect(payload).toEqual(modelsFixture); }); it('should return undefined when data response from API is not valid ', async () => { - mockedAxiosClient + mockedAxiosNEWApiClient .onGet(apiPath.getModelsString()) .reply(HttpStatusCode.Ok, { randomProperty: 'randomValue' }); diff --git a/src/redux/models/models.thunks.ts b/src/redux/models/models.thunks.ts index d81096c9dd853bf571c31de25006583c1b60c36a..6447728ebd567cbaa0836a28724cbf10047a7372 100644 --- a/src/redux/models/models.thunks.ts +++ b/src/redux/models/models.thunks.ts @@ -1,23 +1,22 @@ -import { mapModelSchema } from '@/models/modelSchema'; import { apiPath } from '@/redux/apiPath'; -import { axiosInstance } from '@/services/api/utils/axiosInstance'; -import { MapModel } from '@/types/models'; +import { axiosInstanceNewAPI } from '@/services/api/utils/axiosInstance'; +import { MapModel, MapModels } from '@/types/models'; import { validateDataUsingZodSchema } from '@/utils/validateDataUsingZodSchema'; import { createAsyncThunk } from '@reduxjs/toolkit'; -import { z } from 'zod'; import { ThunkConfig } from '@/types/store'; import { getError } from '@/utils/error-report/getError'; +import { mapModelsSchema } from '@/models/modelSchema'; import { MODELS_FETCHING_ERROR_PREFIX } from './models.constants'; export const getModels = createAsyncThunk<MapModel[] | undefined, void, ThunkConfig>( 'project/getModels', async () => { try { - const response = await axiosInstance.get<MapModel[]>(apiPath.getModelsString()); + const response = await axiosInstanceNewAPI.get<MapModels>(apiPath.getModelsString()); - const isDataValid = validateDataUsingZodSchema(response.data, z.array(mapModelSchema)); + const isDataValid = validateDataUsingZodSchema(response.data, mapModelsSchema); - return isDataValid ? response.data : undefined; + return isDataValid ? response.data.content : undefined; } catch (error) { return Promise.reject(getError({ error, prefix: MODELS_FETCHING_ERROR_PREFIX })); } diff --git a/src/redux/overlays/overlays.thunks.ts b/src/redux/overlays/overlays.thunks.ts index 087d5117629969a32d58beb8aa3087270a812cd3..57698bf414b4cb367a1dd57eecedf8c7a9d0ccd4 100644 --- a/src/redux/overlays/overlays.thunks.ts +++ b/src/redux/overlays/overlays.thunks.ts @@ -55,13 +55,8 @@ export const getAllUserOverlaysByCreator = createAsyncThunk<MapOverlay[], void, try { const state = getState() as RootState; const creator = state.user.login; - // eslint-disable-next-line no-console - console.log('z1'); if (!creator) return []; - // eslint-disable-next-line no-console - console.log('z2'); - const response = await axiosInstanceNewAPI<PageOf<MapOverlay>>( apiPath.getAllUserOverlaysByCreatorQuery({ creator, @@ -72,9 +67,6 @@ export const getAllUserOverlaysByCreator = createAsyncThunk<MapOverlay[], void, }, ); - // eslint-disable-next-line no-console - console.log('z3'); - const isDataValid = validateDataUsingZodSchema(response.data, pageableSchema(mapOverlay)); const sortByOrder = (userOverlayA: MapOverlay, userOverlayB: MapOverlay): number => { @@ -82,15 +74,10 @@ export const getAllUserOverlaysByCreator = createAsyncThunk<MapOverlay[], void, return -1; }; - // eslint-disable-next-line no-console - console.log('z4', response.data.content); - const sortedUserOverlays = response.data.content .sort(sortByOrder) .filter(overlay => !overlay.publicOverlay); - // eslint-disable-next-line no-console - console.log('z5', isDataValid, sortedUserOverlays); return isDataValid ? sortedUserOverlays : []; } catch (error) { return Promise.reject(getError({ error, prefix: USER_OVERLAYS_FETCHING_ERROR_PREFIX })); @@ -214,22 +201,16 @@ export const addOverlay = createAsyncThunk<undefined, AddOverlayArgs, ThunkConfi // eslint-disable-next-line consistent-return ) => { try { - // eslint-disable-next-line no-console - console.log('y0'); const createdFile = await createFile({ filename, content, }); - // eslint-disable-next-line no-console - console.log('y1'); await uploadContent({ createdFile, overlayContent: content, }); - // eslint-disable-next-line no-console - console.log('y2'); await creteOverlay({ createdFile, description, @@ -238,15 +219,9 @@ export const addOverlay = createAsyncThunk<undefined, AddOverlayArgs, ThunkConfi projectId, }); - // eslint-disable-next-line no-console - console.log('y3'); await dispatch(getAllUserOverlaysByCreator()); - // eslint-disable-next-line no-console - console.log('y4'); showToast({ type: 'success', message: USER_OVERLAY_ADD_SUCCESS_MESSAGE }); - // eslint-disable-next-line no-console - console.log('y5'); } catch (error) { if (axios.isAxiosError(error) && error.code === 'ERR_BAD_REQUEST') { const data = error.response?.data; diff --git a/src/redux/project/project.mock.ts b/src/redux/project/project.mock.ts index a1edbd3b548a260205ab5c9760ffd050eb1a221b..b1caa44e3f4a75c7ca303b92979e49006f409092 100644 --- a/src/redux/project/project.mock.ts +++ b/src/redux/project/project.mock.ts @@ -1,5 +1,6 @@ import { DEFAULT_ERROR } from '@/constants/errors'; import { OverviewImageView } from '@/types/models'; +import { MAIN_MAP_ID } from '@/constants/mocks'; import { ProjectState } from './project.types'; export const PROJECT_STATE_INITIAL_MOCK: ProjectState = { @@ -38,7 +39,7 @@ export const PROJECT_OVERVIEW_IMAGE_MOCK: NonNullable<OverviewImageView> = { zoomLevel: 4, xCoord: 3473, yCoord: 5871, - linkedModel: 5053, + linkedModel: MAIN_MAP_ID, // type: 'OverviewModelLink', }, { @@ -87,7 +88,7 @@ export const PROJECT_OVERVIEW_IMAGE_MOCK: NonNullable<OverviewImageView> = { zoomLevel: 5, xCoord: 8081, yCoord: 1240, - linkedModel: 5053, + linkedModel: MAIN_MAP_ID, // type: 'OverviewModelLink', }, { @@ -136,7 +137,7 @@ export const PROJECT_OVERVIEW_IMAGE_MOCK: NonNullable<OverviewImageView> = { zoomLevel: 5, xCoord: 7488, yCoord: 11986, - linkedModel: 5053, + linkedModel: MAIN_MAP_ID, // type: 'OverviewModelLink', }, { diff --git a/src/services/pluginsManager/map/openMap.test.ts b/src/services/pluginsManager/map/openMap.test.ts index b3d01c8f647bbc5a8c1ef4a8b4d466d92470ee70..69aca9db5a1a8b97945bbd19f911512c38da782b 100644 --- a/src/services/pluginsManager/map/openMap.test.ts +++ b/src/services/pluginsManager/map/openMap.test.ts @@ -4,6 +4,7 @@ import { RootState, store } from '@/redux/store'; import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures'; import { MODELS_MOCK, MODELS_MOCK_SHORT } from '@/models/mocks/modelsMock'; import MapBackgroundsEnum from '@/redux/map/map.enums'; +import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; import { PluginsEventBus } from '../pluginsEventBus'; import { openMap } from './openMap'; @@ -22,7 +23,7 @@ describe('openMap', () => { () => ({ map: { - data: { ...initialMapDataFixture, modelId: 5052 }, + data: { ...initialMapDataFixture, modelId: HISTAMINE_MAP_ID }, loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, @@ -36,11 +37,11 @@ describe('openMap', () => { }) as RootState, ); - openMap({ id: 5053 }); + openMap({ id: MAIN_MAP_ID }); - expect(dispatchSpy).toHaveBeenCalledWith(setActiveMap({ modelId: 5053 })); - expect(pluginDispatchEvent).toHaveBeenCalledWith('onSubmapClose', 5052); - expect(pluginDispatchEvent).toHaveBeenCalledWith('onSubmapOpen', 5053); + expect(dispatchSpy).toHaveBeenCalledWith(setActiveMap({ modelId: MAIN_MAP_ID })); + expect(pluginDispatchEvent).toHaveBeenCalledWith('onSubmapClose', HISTAMINE_MAP_ID); + expect(pluginDispatchEvent).toHaveBeenCalledWith('onSubmapOpen', MAIN_MAP_ID); }); it('should open map and set active map when map with provided id is not already opened', () => { @@ -48,7 +49,7 @@ describe('openMap', () => { () => ({ map: { - data: { ...initialMapDataFixture, modelId: 5052 }, + data: { ...initialMapDataFixture, modelId: HISTAMINE_MAP_ID }, loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, @@ -67,7 +68,7 @@ describe('openMap', () => { expect(dispatchSpy).toHaveBeenCalledWith( openMapAndSetActive({ modelId: 5061, modelName: 'Wnt signaling' }), ); - expect(pluginDispatchEvent).toHaveBeenCalledWith('onSubmapClose', 5052); + expect(pluginDispatchEvent).toHaveBeenCalledWith('onSubmapClose', HISTAMINE_MAP_ID); expect(pluginDispatchEvent).toHaveBeenCalledWith('onSubmapOpen', 5061); }); @@ -76,7 +77,7 @@ describe('openMap', () => { () => ({ map: { - data: { ...initialMapDataFixture, modelId: 5052 }, + data: { ...initialMapDataFixture, modelId: HISTAMINE_MAP_ID }, loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, diff --git a/src/services/pluginsManager/map/openMap.ts b/src/services/pluginsManager/map/openMap.ts index ec6a9149d04a6503d03d5574f31e6727faf01514..eeb1eed7e60296c52ce725feced98862baacc55a 100644 --- a/src/services/pluginsManager/map/openMap.ts +++ b/src/services/pluginsManager/map/openMap.ts @@ -13,21 +13,21 @@ export const openMap = ({ id }: OpenMapArgs): void => { const { getState, dispatch } = store; const models = modelsDataSelector(getState()); const openedMaps = mapOpenedMapsSelector(getState()); - const mapToOpen = models.find(model => model.idObject === id); + const mapToOpen = models.find(model => model.id === id); const currentModelId = mapModelIdSelector(getState()); if (!mapToOpen) throw new Error(ERROR_MAP_NOT_FOUND); - const isMapAlreadyOpened = openedMaps.some(map => map.modelId === mapToOpen.idObject); + const isMapAlreadyOpened = openedMaps.some(map => map.modelId === mapToOpen.id); if (isMapAlreadyOpened) { - dispatch(setActiveMap({ modelId: mapToOpen.idObject })); + dispatch(setActiveMap({ modelId: mapToOpen.id })); } else { - dispatch(openMapAndSetActive({ modelId: mapToOpen.idObject, modelName: mapToOpen.name })); + dispatch(openMapAndSetActive({ modelId: mapToOpen.id, modelName: mapToOpen.name })); } - if (currentModelId !== mapToOpen.idObject) { + if (currentModelId !== mapToOpen.id) { PluginsEventBus.dispatchEvent('onSubmapClose', currentModelId); - PluginsEventBus.dispatchEvent('onSubmapOpen', mapToOpen.idObject); + PluginsEventBus.dispatchEvent('onSubmapOpen', mapToOpen.id); } }; diff --git a/src/services/pluginsManager/map/overlays/getVisibleDataOverlays.ts b/src/services/pluginsManager/map/overlays/getVisibleDataOverlays.ts index 14a69d51ac535c543ed55d85b2d06b7e7b41a7fc..910e2924aae35b5c7de6da919d749b2dec624d3f 100644 --- a/src/services/pluginsManager/map/overlays/getVisibleDataOverlays.ts +++ b/src/services/pluginsManager/map/overlays/getVisibleDataOverlays.ts @@ -19,7 +19,7 @@ export const getVisibleDataOverlays = (): DataOverlay[] => { const mapOverlayData = overlayData[dataOverlay.id]; if (mapOverlayData) { models.forEach(model => { - const entries = mapOverlayData[model.idObject]; + const entries = mapOverlayData[model.id]; if (entries) { entries.forEach(dataEntry => { if (dataEntry.type === 'submap-link') { diff --git a/src/services/pluginsManager/map/triggerSearch/getVisibleBioEntitiesPolygonCoordinates.test.ts b/src/services/pluginsManager/map/triggerSearch/getVisibleBioEntitiesPolygonCoordinates.test.ts index 47fc1165f558c948e10f02c45d7f274f045372fa..35661b14ce73d5d232d649d773c72fdfe7acc45a 100644 --- a/src/services/pluginsManager/map/triggerSearch/getVisibleBioEntitiesPolygonCoordinates.test.ts +++ b/src/services/pluginsManager/map/triggerSearch/getVisibleBioEntitiesPolygonCoordinates.test.ts @@ -5,6 +5,7 @@ import { bioEntityContentFixture } from '@/models/fixtures/bioEntityContentsFixt import { DRAWER_INITIAL_STATE } from '@/redux/drawer/drawer.constants'; import { MODELS_DATA_MOCK_WITH_MAIN_MAP } from '@/redux/models/models.mock'; +import { HISTAMINE_MAP_ID } from '@/constants/mocks'; import { getVisibleBioEntitiesPolygonCoordinates } from './getVisibleBioEntitiesPolygonCoordinates'; jest.mock('../../../../redux/store'); @@ -24,7 +25,7 @@ describe('getVisibleBioEntitiesPolygonCoordinates', () => { ...MAP_INITIAL_STATE, data: { ...MAP_INITIAL_STATE.data, - modelId: 5052, + modelId: HISTAMINE_MAP_ID, size: { width: 256, height: 256, diff --git a/src/services/pluginsManager/map/triggerSearch/searchByQuery.test.ts b/src/services/pluginsManager/map/triggerSearch/searchByQuery.test.ts index b4beac3eee835d5984b8849c6c9c5be171ed41c5..45c0e9dfdd8892ba3d44e2eb2391cdc1ff16fecd 100644 --- a/src/services/pluginsManager/map/triggerSearch/searchByQuery.test.ts +++ b/src/services/pluginsManager/map/triggerSearch/searchByQuery.test.ts @@ -10,6 +10,7 @@ import { RootState, store } from '@/redux/store'; import { mockNetworkNewAPIResponse } from '@/utils/mockNetworkResponse'; import { waitFor } from '@testing-library/react'; import { HttpStatusCode } from 'axios'; +import { HISTAMINE_MAP_ID } from '@/constants/mocks'; import { searchByQuery } from './searchByQuery'; import { searchFitBounds } from './searchFitBounds'; @@ -19,7 +20,7 @@ const MOCK_SEARCH_BY_QUERY_STORE = { ...MAP_INITIAL_STATE, data: { ...MAP_INITIAL_STATE.data, - modelId: 5052, + modelId: HISTAMINE_MAP_ID, size: { width: 256, height: 256, diff --git a/src/types/models.ts b/src/types/models.ts index a7f9735a40a82fc12d4c72e5c82a3771976efb7f..af20167b080040dc86ddd0eb954d518f3dfaa68c 100644 --- a/src/types/models.ts +++ b/src/types/models.ts @@ -31,7 +31,7 @@ import { markerTypeSchema, markerWithPositionSchema, } from '@/models/markerSchema'; -import { mapModelSchema } from '@/models/modelSchema'; +import { mapModelSchema, mapModelsSchema } from '@/models/modelSchema'; import { organism } from '@/models/organism'; import { overlayBioEntitySchema, @@ -91,6 +91,8 @@ export type OverviewImageLink = z.infer<typeof overviewImageLink>; export type OverviewImageLinkImage = z.infer<typeof overviewImageLinkImage>; export type OverviewImageLinkModel = z.infer<typeof overviewImageLinkModel>; export type OverviewImageLinkSearch = z.infer<typeof overviewImageLinkSearch>; + +export type MapModels = z.infer<typeof mapModelsSchema>; export type MapModel = z.infer<typeof mapModelSchema>; export type BioShape = z.infer<typeof bioShapeSchema>; export type LineType = z.infer<typeof lineTypeSchema>; diff --git a/src/utils/initialize/useInitializeStore.test.ts b/src/utils/initialize/useInitializeStore.test.ts index 8243df3004c2c266b33b382dfb60c2adccb3e540..34a1e072e0a64d13b8d47bf18892fbb5fbe4de35 100644 --- a/src/utils/initialize/useInitializeStore.test.ts +++ b/src/utils/initialize/useInitializeStore.test.ts @@ -1,6 +1,6 @@ import { PROJECT_ID } from '@/constants'; import { backgroundsFixture } from '@/models/fixtures/backgroundsFixture'; -import { modelsFixture } from '@/models/fixtures/modelsFixture'; +import { modelsFixture, modelsPageFixture } from '@/models/fixtures/modelsFixture'; import { overlaysPageFixture } from '@/models/fixtures/overlaysFixture'; import { projectFixture } from '@/models/fixtures/projectFixture'; import { apiPath } from '@/redux/apiPath'; @@ -21,7 +21,9 @@ const mockedAxiosNewClient = mockNetworkNewAPIResponse(); describe('useInitializeStore - hook', () => { describe('when fired', () => { beforeAll(() => { - mockedAxiosClient.onGet(apiPath.getModelsString()).reply(HttpStatusCode.Ok, modelsFixture); + mockedAxiosNewClient + .onGet(apiPath.getModelsString()) + .reply(HttpStatusCode.Ok, modelsPageFixture); mockedAxiosNewClient .onGet(apiPath.getAllOverlaysByProjectIdQuery(PROJECT_ID, { publicOverlay: true })) .reply(HttpStatusCode.Ok, overlaysPageFixture); diff --git a/src/utils/map/getUpdatedMapData.test.ts b/src/utils/map/getUpdatedMapData.test.ts index 4e4b28522c80a83c0fd23ac76091125f91af56b1..6f38197732587bef6a3ae9b245f127bc195e5480 100644 --- a/src/utils/map/getUpdatedMapData.test.ts +++ b/src/utils/map/getUpdatedMapData.test.ts @@ -15,7 +15,7 @@ describe('getUpdatedMapData - util', () => { it('should return correct value', () => { const result = { - modelId: model.idObject, + modelId: model.id, size: { width: model.width, height: model.height, @@ -51,7 +51,7 @@ describe('getUpdatedMapData - util', () => { it('should return correct value', () => { const result = { - modelId: model.idObject, + modelId: model.id, size: { width: model.width, height: model.height, @@ -87,7 +87,7 @@ describe('getUpdatedMapData - util', () => { it('should return correct value', () => { const result = { - modelId: model.idObject, + modelId: model.id, size: { width: model.width, height: model.height, diff --git a/src/utils/map/getUpdatedMapData.ts b/src/utils/map/getUpdatedMapData.ts index 6baeeae09b8f1693b0605e6aafd4a9ba7ca460ec..1e4fc498ac190f2d3161910b4dd25f36c2112dcf 100644 --- a/src/utils/map/getUpdatedMapData.ts +++ b/src/utils/map/getUpdatedMapData.ts @@ -27,7 +27,7 @@ export const getUpdatedMapData = ({ const mergedPosition = getPointMerged(position?.initial || {}, defaultPosition); return { - modelId: model.idObject, + modelId: model.id, backgroundId: background?.id || MAP_DATA_INITIAL_STATE.backgroundId, size: { width: model.width,