diff --git a/CHANGELOG b/CHANGELOG index eb0373fae239bcb69678fe9cded83dd2c938b10b..347b9405578eb7ea6e5cab9cd125b7da2eced8c2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ minerva-front (18.0.1) stable; urgency=medium * Bug fix: show cookie baner only when cookie baner link is provided (#304) * Bug fix: when link to submap is provided add submap name (#303) + * Bug fix: some old maps could not be opened (#311) -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 24 Oct 2024 13:00:00 +0200 diff --git a/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx b/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx index 4fae37530de53dd219cd0d5118bbe12aded2d3ae..2af7f3fb90190b2ffa0dc1f822138ceab27c2396 100644 --- a/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx +++ b/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx @@ -9,11 +9,9 @@ import { getReduxWrapperWithStore, } from '@/utils/testing/getReduxWrapperWithStore'; import { act, render, screen, within } from '@testing-library/react'; +import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; import { MapNavigation } from './MapNavigation.component'; -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/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx index a1bec280f9de88ba0b354c552d180ac34f3e16dd..64d82fabf6a64324b2f08d52f52c4166541434d6 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx @@ -11,6 +11,7 @@ import { } from '@/utils/testing/getReduxWrapperWithStore'; import { render, screen } from '@testing-library/react'; import { MockStoreEnhanced } from 'redux-mock-store'; +import { HISTAMINE_MAP_ID, MAIN_MAP_ID, PRKN_SUBSTRATES_MAP_ID } from '@/constants/mocks'; import { BioEntitiesAccordion } from './BioEntitiesAccordion.component'; const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { @@ -95,10 +96,22 @@ describe('BioEntitiesAccordion - component', () => { }, }); - expect(screen.getByText('Content (10)')).toBeInTheDocument(); - expect(screen.getByText('Core PD map (3)')).toBeInTheDocument(); - expect(screen.getByText('Histamine signaling (4)')).toBeInTheDocument(); - expect(screen.getByText('PRKN substrates (3)')).toBeInTheDocument(); + const countHistamine = bioEntitiesContentFixture.filter( + content => content.bioEntity.model === HISTAMINE_MAP_ID, + ).length; + const countCore = bioEntitiesContentFixture.filter( + content => content.bioEntity.model === MAIN_MAP_ID, + ).length; + const countPrkn = bioEntitiesContentFixture.filter( + content => content.bioEntity.model === PRKN_SUBSTRATES_MAP_ID, + ).length; + + const countAll = bioEntitiesContentFixture.length; + + expect(screen.getByText(`Content (${countAll})`)).toBeInTheDocument(); + expect(screen.getByText(`Core PD map (${countCore})`)).toBeInTheDocument(); + expect(screen.getByText(`Histamine signaling (${countHistamine})`)).toBeInTheDocument(); + expect(screen.getByText(`PRKN substrates (${countPrkn})`)).toBeInTheDocument(); }); it('should fire toggleIsContentTabOpened on accordion item button click', () => { 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 b1d74b817a28845a1f3b4f7f48374e864a5b6517..589688c92153478e9ec414ebd29a6fd11d24a95c 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 @@ -62,6 +62,11 @@ const renderComponent = ( }; describe('PinsListItem - component ', () => { + drugsFixture[0].targets[0].targetParticipants[0].link = 'https://example.com/plugin.js'; + drugsFixture[0].targets[0].targetParticipants[1].link = 'https://example.com/plugin.js'; + chemicalsFixture[0].targets[0].targetParticipants[0].link = 'https://example.com/plugin.js'; + chemicalsFixture[0].targets[0].targetParticipants[1].link = 'https://example.com/plugin.js'; + it('should display full name of pin', () => { renderComponent(DRUGS_PIN.name, DRUGS_PIN.pin, 'drugs', BIO_ENTITY, INITIAL_STORE_STATE); diff --git a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleAliasResults.test.ts b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleAliasResults.test.ts index e00535c5e895bb9b34d0563fb0132387abe31dcb..aae76f614efd91b111eb16846f5a3ef92ae9f222 100644 --- a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleAliasResults.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleAliasResults.test.ts @@ -209,8 +209,6 @@ describe('handleAliasResults - util', () => { 'entityNumber/addNumbersToEntityNumberData', 'project/getBioEntityById/fulfilled', 'entityNumber/addNumbersToEntityNumberData', - 'reactions/getByIds/pending', - 'reactions/getByIds/fulfilled', 'project/getMultiBioEntity/fulfilled', 'drawer/selectTab', 'drawer/openBioEntityDrawerById', diff --git a/src/constants/mocks.ts b/src/constants/mocks.ts index d7156f1ea3552ebde078a9d4dd4a84070f50f26e..11af1d0a150d3e7c2adcf79f5aff2f6359e3a9a6 100644 --- a/src/constants/mocks.ts +++ b/src/constants/mocks.ts @@ -1,2 +1,4 @@ -// eslint-disable-next-line no-magic-numbers -export const MODEL_IDS_MOCK = [5052, 5053, 5054]; +export const MAIN_MAP_ID = 5053; +export const HISTAMINE_MAP_ID = 5052; +export const PRKN_SUBSTRATES_MAP_ID = 5054; +export const MODEL_IDS_MOCK = [HISTAMINE_MAP_ID, MAIN_MAP_ID, PRKN_SUBSTRATES_MAP_ID]; diff --git a/src/models/bioEntitySchema.ts b/src/models/bioEntitySchema.ts index 187b1982bf1f7273d6694aca1a6a725d097c6f1a..1e01a1d5b020a9d1c21e93b2158ddd176fa2a6cd 100644 --- a/src/models/bioEntitySchema.ts +++ b/src/models/bioEntitySchema.ts @@ -35,7 +35,7 @@ export const bioEntitySchema = z.object({ .number() .optional() .transform(height => height ?? ZERO), - visibilityLevel: z.string(), + visibilityLevel: z.string().nullable(), transparencyLevel: z.string().nullable().optional(), synonyms: z.array(z.string()), formerSymbols: z.array(z.string()).nullable().optional(), @@ -47,13 +47,13 @@ export const bioEntitySchema = z.object({ activity: z.boolean().optional(), structuralState: z.optional(structuralStateSchema.nullable()), hypothetical: z.boolean().nullable().optional(), - boundaryCondition: z.boolean().optional(), - constant: z.boolean().optional(), + boundaryCondition: z.boolean().optional().nullable(), + constant: z.boolean().optional().nullable(), initialAmount: z.number().nullable().optional(), initialConcentration: z.number().nullable().optional(), charge: z.number().nullable().optional(), substanceUnits: z.string().nullable().optional(), - onlySubstanceUnits: z.boolean().optional(), + onlySubstanceUnits: z.boolean().optional().nullable(), modificationResidues: z.optional(z.array(modificationResiduesSchema)), complex: z.number().nullable().optional(), compartment: z.number().nullable().optional(), diff --git a/src/models/compartmentPathwaySchema.ts b/src/models/compartmentPathwaySchema.ts index 368ff17fc1f0fc77251f2bec1b917ec1f44c2858..1259fa8708e3d6514b69e113b52c97cd5c118a21 100644 --- a/src/models/compartmentPathwaySchema.ts +++ b/src/models/compartmentPathwaySchema.ts @@ -32,7 +32,7 @@ export const compartmentPathwayDetailsSchema = z.object({ formula: z.null(), fullName: z.string().nullable(), glyph: z.any(), - hierarchyVisibilityLevel: z.string(), + hierarchyVisibilityLevel: z.string().nullable(), homomultimer: z.null(), hypothetical: z.null(), id: z.number().gt(-1), diff --git a/src/models/mapBackground.ts b/src/models/mapBackground.ts index a8a9605280785e7071cd94256022177803ba9808..fe6c6e9e1319bad70bd7f627192caea855fd1b6c 100644 --- a/src/models/mapBackground.ts +++ b/src/models/mapBackground.ts @@ -8,7 +8,7 @@ export const mapBackground = z.object({ creator: z.object({ login: z.string() }), status: z.string(), progress: z.number(), - description: z.null(), + description: z.string().nullable(), order: z.number(), images: z.array( z.object({ diff --git a/src/models/overlayLeftBioEntitySchema.ts b/src/models/overlayLeftBioEntitySchema.ts index 5e751d72037cb7131dd7b6502a58a733d0d38ec6..64d3a1c9cebb399ddcd3e222a02ba103c2a9d79f 100644 --- a/src/models/overlayLeftBioEntitySchema.ts +++ b/src/models/overlayLeftBioEntitySchema.ts @@ -18,7 +18,7 @@ export const overlayLeftBioEntitySchema = z.object({ fontColor: colorSchema.optional(), fillColor: colorSchema.optional(), borderColor: colorSchema, - visibilityLevel: z.string(), + visibilityLevel: z.string().nullable(), transparencyLevel: z.string(), notes: z.string(), symbol: z.string().nullable(), @@ -40,10 +40,10 @@ export const overlayLeftBioEntitySchema = z.object({ initialAmount: z.unknown().nullable(), charge: z.unknown(), initialConcentration: z.number().nullable().optional(), - onlySubstanceUnits: z.unknown(), + onlySubstanceUnits: z.boolean().nullable().optional(), homodimer: z.number().optional(), hypothetical: z.unknown(), - boundaryCondition: z.boolean().optional(), + boundaryCondition: z.boolean().optional().nullable(), constant: z.boolean().nullable().optional(), modificationResidues: z.unknown(), stringType: z.string(), diff --git a/src/models/overlayLeftReactionSchema.ts b/src/models/overlayLeftReactionSchema.ts index c47febcff7136233ac38e7d4c41c6eb3d85c2144..28a0b9d7a812ad941c6bca8db5bc389aa2af8f62 100644 --- a/src/models/overlayLeftReactionSchema.ts +++ b/src/models/overlayLeftReactionSchema.ts @@ -17,7 +17,7 @@ export const overlayLeftReactionSchema = z.object({ upperBound: z.null(), subsystem: z.null(), geneProteinReaction: z.null(), - visibilityLevel: z.string(), + visibilityLevel: z.string().nullable(), z: z.number(), synonyms: z.array(z.unknown()), model: z.number(), diff --git a/src/models/reaction.ts b/src/models/reaction.ts index 51c7c51b014b35f76668730099639a929fb251cc..18a438f72386e9f790394dca2cf37114a9d24c29 100644 --- a/src/models/reaction.ts +++ b/src/models/reaction.ts @@ -6,7 +6,7 @@ import { referenceSchema } from './referenceSchema'; export const reactionSchema = z.object({ centerPoint: positionSchema, - hierarchyVisibilityLevel: z.string(), + hierarchyVisibilityLevel: z.string().nullable(), id: z.number(), kineticLaw: z.null(), lines: z.array(reactionLineSchema), diff --git a/src/utils/search/getElementsByCoordinates.ts b/src/utils/search/getElementsByCoordinates.ts index 70e392de47fcf2be6aabd9ee800069b60c682a58..fa54f1de0978145ce1d676a4663bca699216e570 100644 --- a/src/utils/search/getElementsByCoordinates.ts +++ b/src/utils/search/getElementsByCoordinates.ts @@ -25,7 +25,10 @@ export const getFirstVisibleParent = async ({ apiPath.getElementById(parentId, bioEntity.model), ); const parent = parentResponse.data; - if (parseInt(parent.visibilityLevel, 10) > Math.ceil(considerZoomLevel)) { + if ( + parent.visibilityLevel !== null && + parseInt(parent.visibilityLevel, 10) > Math.ceil(considerZoomLevel) + ) { return getFirstVisibleParent({ bioEntity: parent, considerZoomLevel, @@ -70,8 +73,9 @@ export const getElementsByPoint = async ({ ); const element = elementResponse.data; if ( + element.visibilityLevel != null && parseInt(element.visibilityLevel, 10) - (ONE - FRACTIONAL_ZOOM_AT_WHICH_IMAGE_LAYER_CHANGE) > - (considerZoomLevel || Number.MAX_SAFE_INTEGER) + (considerZoomLevel || Number.MAX_SAFE_INTEGER) ) { const visibleParent = await getFirstVisibleParent({ bioEntity: element,