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/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/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/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/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/ExportDrawer/ExportCompound/ExportCompound.component.tsx b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx index d380b1c020c48920c20388c9eef347c3c52d9993..906dd9ee6fe55e9aaea12c5907df5ef2e9204c63 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx +++ b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx @@ -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/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 d6561b9501549ef128a86265a0ba1d459d82d8a5..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 } => { @@ -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/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 23e1eef1e131fe21703acb1ab0d490a38de67e1b..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; 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 704176d2269eab35c33b05befd65f638c2981e73..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; @@ -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/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/MapAdditionalActions/utils/useVisibleBioEntitiesPolygonCoordinates.test.ts b/src/components/Map/MapAdditionalActions/utils/useVisibleBioEntitiesPolygonCoordinates.test.ts index 331d5e98a034262740b169524c84367b4e297618..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], - id: 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/models/mocks/modelsMock.ts b/src/models/mocks/modelsMock.ts index 7166e45f8fd5de19eeecd8634f8671592ecf87d7..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[] = [ { - id: 5053, + id: MAIN_MAP_ID, width: 26779.25, height: 13503.0, defaultCenterX: null, @@ -19,7 +20,7 @@ export const MODELS_MOCK: MapModel[] = [ maxZoom: 9, }, { - id: 5052, + id: HISTAMINE_MAP_ID, width: 3511.09375, height: 1312.125, defaultCenterX: null, @@ -406,7 +407,7 @@ export const MODELS_MOCK: MapModel[] = [ export const MODELS_MOCK_SHORT: MapModel[] = [ { - id: 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, }, { - id: 5052, + id: HISTAMINE_MAP_ID, width: 3511.09375, height: 1312.125, defaultCenterX: null, @@ -459,7 +460,7 @@ export const MODELS_MOCK_SHORT: MapModel[] = [ ]; export const CORE_PD_MODEL_MOCK: MapModel = { - id: 5053, + id: MAIN_MAP_ID, width: 26779.25, height: 13503.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/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/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/compartmentPathways/compartmentPathways.mock.ts b/src/redux/compartmentPathways/compartmentPathways.mock.ts index a8c7fdb90921f194e3133a1fdf69dc9ecbfaee59..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[] = [ { - id: 5053, + id: MAIN_MAP_ID, 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 517b8fec865fe6263c6ccbd8bbff3ea893d178d0..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)) 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 75fcb092a9b34265ca46539c89661d0ef2b09cef..363b1d9c02c8479a01abf2a8f91078125c52b621 100644 --- a/src/redux/map/map.thunks.ts +++ b/src/redux/map/map.thunks.ts @@ -147,16 +147,14 @@ 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]?.id || 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?.id !== mainMapId; + const isMainMapSetAsCurrentModel = currentModel?.id !== mainMap.id; if (isMainMapSetAsCurrentModel) { openedMaps.push({ diff --git a/src/redux/models/models.selectors.ts b/src/redux/models/models.selectors.ts index 9676601d0b68e3e0b7f19bc5865c5874d71d3b8f..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'; @@ -46,14 +48,20 @@ export const modelByIdSelector = createSelector( (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/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/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,