From db888f72cfeed0a7d3aea85b81298882c130ab55 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <p.gawron@atcomp.pl> Date: Fri, 15 Nov 2024 10:27:07 +0100 Subject: [PATCH] getReactionByIdInNewApi apiPath replaced by getNewReaction apiPath --- public/config.js | 2 +- .../mouseClick/clickHandleReaction.test.ts | 2 +- .../handleReactionResults.test.ts | 42 ++++--------------- .../mapSingleClick/handleReactionResults.ts | 6 +-- src/redux/apiPath.ts | 2 - 5 files changed, 14 insertions(+), 40 deletions(-) diff --git a/public/config.js b/public/config.js index 51047de3..4d245aa0 100644 --- a/public/config.js +++ b/public/config.js @@ -6,6 +6,6 @@ window.config = { BASE_API_URL: `${root}/minerva/api`, BASE_NEW_API_URL: `${root}/minerva/new_api/`, BASE_MAP_IMAGES_URL: `${root}/`, - DEFAULT_PROJECT_ID: 'minervar_example', + DEFAULT_PROJECT_ID: 'sample', ADMIN_PANEL_URL: `${root}/minerva/admin.xhtml`, }; diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.test.ts b/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.test.ts index bc97ee98..47b21acd 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.test.ts +++ b/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.test.ts @@ -37,7 +37,7 @@ describe('clickHandleReaction', () => { modelId = newReactionFixture.model; mockedAxiosClient - .onGet(apiPath.getReactionByIdInNewApi(reactionId, modelId)) + .onGet(apiPath.getNewReaction(modelId, reactionId)) .reply(HttpStatusCode.Ok, bioEntityFixture); [ diff --git a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.test.ts b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.test.ts index 0d73fa70..f44aa7c8 100644 --- a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.test.ts @@ -82,15 +82,6 @@ describe('handleReactionResults - util', () => { ) .reply(HttpStatusCode.Ok, bioEntityFixture); - mockedAxiosNewClient - .onGet( - apiPath.getReactionByIdInNewApi( - ELEMENT_SEARCH_RESULT_MOCK_REACTION.id, - ELEMENT_SEARCH_RESULT_MOCK_REACTION.modelId, - ), - ) - .reply(HttpStatusCode.Ok, reaction); - mockedAxiosNewClient .onGet( apiPath.getNewReaction( @@ -170,12 +161,12 @@ describe('handleReactionResults - util', () => { mockedAxiosNewClient .onGet( - apiPath.getReactionByIdInNewApi( - ELEMENT_SEARCH_RESULT_MOCK_REACTION.id, + apiPath.getNewReaction( ELEMENT_SEARCH_RESULT_MOCK_REACTION.modelId, + ELEMENT_SEARCH_RESULT_MOCK_REACTION.id, ), ) - .reply(HttpStatusCode.Ok, bioEntityFixture); + .reply(HttpStatusCode.Ok, reaction); mockedAxiosOldClient .onGet(apiPath.getReactionsWithIds([ELEMENT_SEARCH_RESULT_MOCK_REACTION.id])) @@ -245,7 +236,7 @@ describe('handleReactionResults - util', () => { describe('when search config provided and matching reaction found', () => { const point = { x: 1, y: 1 }; const maxZoom = 10; - const zoom = 5; + const zoom = ZOOM_RESCALING_FACTOR * 5; it('should open reaction drawer and fetch bio entities', async () => { const { store } = getReduxStoreWithActionsListener(); @@ -258,15 +249,6 @@ describe('handleReactionResults - util', () => { ) .reply(HttpStatusCode.Ok, []); - mockedAxiosNewClient - .onGet( - apiPath.getReactionByIdInNewApi( - ELEMENT_SEARCH_RESULT_MOCK_REACTION.id, - ELEMENT_SEARCH_RESULT_MOCK_REACTION.modelId, - ), - ) - .reply(HttpStatusCode.Ok, reaction); - mockedAxiosNewClient .onGet( apiPath.getNewReaction( @@ -292,13 +274,16 @@ describe('handleReactionResults - util', () => { 'reactions/getByIds/fulfilled', 'drawer/openReactionDrawerById', 'drawer/selectTab', + 'project/getMultiBioEntity/pending', + 'entityNumber/addNumbersToEntityNumberData', + 'project/getMultiBioEntity/fulfilled', ]); }); }); describe('when matching reaction found', () => { const point = { x: reaction.line.segments[0].x1, y: reaction.line.segments[0].y1 }; const maxZoom = 10; - const zoom = 5; + const zoom = ZOOM_RESCALING_FACTOR * 5; it('should dispatch onSearch event with reaction data', async () => { const { store } = getReduxStoreWithActionsListener(); @@ -311,15 +296,6 @@ describe('handleReactionResults - util', () => { ) .reply(HttpStatusCode.Ok, []); - mockedAxiosNewClient - .onGet( - apiPath.getReactionByIdInNewApi( - ELEMENT_SEARCH_RESULT_MOCK_REACTION.id, - ELEMENT_SEARCH_RESULT_MOCK_REACTION.modelId, - ), - ) - .reply(HttpStatusCode.Ok, bioEntityFixture); - mockedAxiosNewClient .onGet( apiPath.getNewReaction( @@ -338,7 +314,7 @@ describe('handleReactionResults - util', () => { })(ELEMENT_SEARCH_RESULT_MOCK_REACTION); expect(PluginsEventBus.dispatchEvent).toHaveBeenCalledWith('onSearch', { - results: [[{ bioEntity: bioEntityFixture, perfect: true }]], + results: [[{ bioEntity: reaction, perfect: true }]], searchValues: [ELEMENT_SEARCH_RESULT_MOCK_REACTION], type: 'reaction', }); diff --git a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts index dd69ba18..e326806c 100644 --- a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts +++ b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts @@ -9,8 +9,8 @@ import { BioEntity, ElementSearchResult } from '@/types/models'; import { axiosInstanceNewAPI } from '@/services/api/utils/axiosInstance'; import { apiPath } from '@/redux/apiPath'; import { validateDataUsingZodSchema } from '@/utils/validateDataUsingZodSchema'; -import { bioEntitySchema } from '@/models/bioEntitySchema'; import { getMultiBioEntityByIds } from '@/redux/bioEntity/thunks/getMultiBioEntity'; +import { newReactionSchema } from '@/models/newReactionSchema'; import { handleReactionSearchClickFailure } from './handleReactionSearchClickFailure'; import { getBioEntitiesIdsFromReaction } from './getBioEntitiesIdsFromReaction'; import { findClosestReactionPoint } from './findClosestReactionPoint'; @@ -54,8 +54,8 @@ export const handleReactionResults = dispatch(selectTab('')); - const response = await axiosInstanceNewAPI.get<BioEntity>(apiPath.getReactionByIdInNewApi(reaction.id, reaction.model)); - const isDataValid = validateDataUsingZodSchema(response.data, bioEntitySchema); + const response = await axiosInstanceNewAPI.get<BioEntity>(apiPath.getNewReaction(reaction.model, reaction.id)); + const isDataValid = validateDataUsingZodSchema(response.data, newReactionSchema); if (isDataValid) { const reactionNewApi = response.data; diff --git a/src/redux/apiPath.ts b/src/redux/apiPath.ts index 1e58fd7d..5346ef4d 100644 --- a/src/redux/apiPath.ts +++ b/src/redux/apiPath.ts @@ -22,8 +22,6 @@ const getPublicationsURLSearchParams = ( export const apiPath = { getElementById: (elementId: number, modelId: number): string => `projects/${PROJECT_ID}/models/${modelId}/bioEntities/elements/${elementId}`, - getReactionByIdInNewApi: (reactionId: number, modelId: number): string => - `projects/${PROJECT_ID}/models/${modelId}/bioEntities/reactions/${reactionId}`, getBioEntityContentsStringWithQuery: ({ searchQuery, -- GitLab