Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • minerva/frontend
1 result
Show changes
Commits on Source (10)
Showing
with 312 additions and 278 deletions
......@@ -8,6 +8,8 @@ import { act, render, screen } from '@testing-library/react';
import { CONTEXT_MENU_INITIAL_STATE } from '@/redux/contextMenu/contextMenu.constants';
import { bioEntityContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
import { PluginsContextMenu } from '@/services/pluginsManager/pluginContextMenu/pluginsContextMenu';
import { modelElementFixture } from '@/models/fixtures/modelElementFixture';
import { DEFAULT_ERROR } from '@/constants/errors';
import { ContextMenu } from './ContextMenu.component';
const renderComponent = (initialStore?: InitialStoreState): { store: StoreType } => {
......@@ -97,31 +99,40 @@ describe('ContextMenu - Component', () => {
it('should display uniprot id as option if it is provided', () => {
renderComponent({
bioEntity: {
data: [
{
searchQueryElement: bioEntityContentFixture.bioEntity.id.toString(),
modelElements: {
data: {
0: {
data: [modelElementFixture],
loading: 'succeeded',
error: { name: '', message: '' },
data: [
{
...bioEntityContentFixture,
bioEntity: {
...bioEntityContentFixture.bioEntity,
fullName: 'BioEntity Full Name',
references: [
{
...bioEntityContentFixture.bioEntity.references[0],
type: 'UNIPROT',
},
],
},
},
],
error: { message: '', name: '' },
},
],
loading: 'succeeded',
error: { message: '', name: '' },
},
search: {
data: [
{
searchQueryElement: modelElementFixture.id.toString(),
loading: 'succeeded',
error: DEFAULT_ERROR,
data: [
{
modelElement: {
...modelElementFixture,
fullName: 'BioEntity Full Name',
references: [
{
...bioEntityContentFixture.bioEntity.references[0],
type: 'UNIPROT',
},
],
},
perfect: true,
},
],
},
],
loading: 'pending',
error: DEFAULT_ERROR,
},
},
contextMenu: {
...CONTEXT_MENU_INITIAL_STATE,
......@@ -144,31 +155,40 @@ describe('ContextMenu - Component', () => {
it('should open molart modal when clicking on uniprot', async () => {
const { store } = renderComponent({
bioEntity: {
data: [
{
searchQueryElement: bioEntityContentFixture.bioEntity.id.toString(),
modelElements: {
data: {
0: {
data: [modelElementFixture],
loading: 'succeeded',
error: { name: '', message: '' },
data: [
{
...bioEntityContentFixture,
bioEntity: {
...bioEntityContentFixture.bioEntity,
fullName: 'BioEntity Full Name',
references: [
{
...bioEntityContentFixture.bioEntity.references[0],
type: 'UNIPROT',
},
],
},
},
],
error: { message: '', name: '' },
},
],
loading: 'succeeded',
error: { message: '', name: '' },
},
search: {
data: [
{
searchQueryElement: modelElementFixture.id.toString(),
loading: 'succeeded',
error: DEFAULT_ERROR,
data: [
{
modelElement: {
...modelElementFixture,
fullName: 'BioEntity Full Name',
references: [
{
...bioEntityContentFixture.bioEntity.references[0],
type: 'UNIPROT',
},
],
},
perfect: true,
},
],
},
],
loading: 'pending',
error: DEFAULT_ERROR,
},
},
contextMenu: {
...CONTEXT_MENU_INITIAL_STATE,
......
import { searchedBioEntityElementUniProtIdSelector } from '@/redux/bioEntity/bioEntity.selectors';
import { contextMenuSelector } from '@/redux/contextMenu/contextMenu.selector';
import { closeContextMenu } from '@/redux/contextMenu/contextMenu.slice';
import { useAppDispatch } from '@/redux/hooks/useAppDispatch';
......@@ -9,12 +8,13 @@ import { twMerge } from 'tailwind-merge';
import { FIRST_ARRAY_ELEMENT, SECOND_ARRAY_ELEMENT, ZERO } from '@/constants/common';
import { PluginsContextMenu } from '@/services/pluginsManager/pluginContextMenu/pluginsContextMenu';
import { BioEntity, NewReaction } from '@/types/models';
import { ModelElement, NewReaction } from '@/types/models';
import { ClickCoordinates } from '@/services/pluginsManager/pluginContextMenu/pluginsContextMenu.types';
import { currentModelSelector } from '@/redux/models/models.selectors';
import { mapDataLastPositionSelector } from '@/redux/map/map.selectors';
import { DEFAULT_ZOOM } from '@/constants/map';
import { OutsideClickWrapper } from '@/shared/OutsideClickWrapper';
import { searchedModelElementUniProtIdSelector } from '@/redux/modelElements/modelElements.selector';
export const ContextMenu = (): React.ReactNode => {
const pluginContextMenu = PluginsContextMenu.menuItems;
......@@ -22,7 +22,7 @@ export const ContextMenu = (): React.ReactNode => {
const lastPosition = useAppSelector(mapDataLastPositionSelector);
const dispatch = useAppDispatch();
const { isOpen, coordinates } = useAppSelector(contextMenuSelector);
const unitProtId = useAppSelector(searchedBioEntityElementUniProtIdSelector);
const unitProtId = useAppSelector(searchedModelElementUniProtIdSelector);
const isUnitProtIdAvailable = (): boolean => unitProtId !== undefined;
......@@ -49,7 +49,10 @@ export const ContextMenu = (): React.ReactNode => {
const modelId = model ? model.id : ZERO;
const handleCallback = (
callback: (coordinates: ClickCoordinates, element: BioEntity | NewReaction | undefined) => void,
callback: (
coordinates: ClickCoordinates,
element: ModelElement | NewReaction | undefined,
) => void,
) => {
return () => {
closeContextMenuFunction();
......
......@@ -18,6 +18,8 @@ jest.mock('./utils/useOverviewImageSize', () => ({
})),
}));
const PROJECT_DIRECTORY = 'directory';
const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState);
......@@ -42,6 +44,7 @@ describe('OverviewImagesModal - component', () => {
...projectFixture,
overviewImageViews: [],
topOverviewImage: PROJECT_OVERVIEW_IMAGE_MOCK,
directory: PROJECT_DIRECTORY,
},
loading: 'succeeded',
error: { message: '', name: '' },
......@@ -70,6 +73,7 @@ describe('OverviewImagesModal - component', () => {
...projectFixture,
overviewImageViews: [PROJECT_OVERVIEW_IMAGE_MOCK],
topOverviewImage: PROJECT_OVERVIEW_IMAGE_MOCK,
directory: PROJECT_DIRECTORY,
},
loading: 'succeeded',
error: { message: '', name: '' },
......@@ -91,7 +95,7 @@ describe('OverviewImagesModal - component', () => {
it('should render image with valid src', () => {
const imageElement = screen.getByAltText('overview');
const result = `${BASE_MAP_IMAGES_URL}/map_images/${PROJECT_OVERVIEW_IMAGE_MOCK.filename}`;
const result = `${BASE_MAP_IMAGES_URL}/map_images/${PROJECT_DIRECTORY}/${PROJECT_OVERVIEW_IMAGE_MOCK.filename}`;
expect(imageElement.getAttribute('src')).toBe(result);
});
......
......@@ -7,6 +7,8 @@ import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithSto
import { renderHook } from '@testing-library/react';
import { useOverviewImage } from './useOverviewImage';
const PROJECT_DIRECTORY = 'directory';
describe('useOverviewImage - hook', () => {
describe('when image data is invalid', () => {
const { Wrapper } = getReduxWrapperWithStore({
......@@ -15,6 +17,7 @@ describe('useOverviewImage - hook', () => {
...projectFixture,
overviewImageViews: [],
topOverviewImage: PROJECT_OVERVIEW_IMAGE_MOCK,
directory: PROJECT_DIRECTORY,
},
loading: 'succeeded',
error: { message: '', name: '' },
......@@ -48,6 +51,7 @@ describe('useOverviewImage - hook', () => {
...projectFixture,
overviewImageViews: [PROJECT_OVERVIEW_IMAGE_MOCK],
topOverviewImage: PROJECT_OVERVIEW_IMAGE_MOCK,
directory: PROJECT_DIRECTORY,
},
loading: 'succeeded',
error: { message: '', name: '' },
......@@ -66,7 +70,7 @@ describe('useOverviewImage - hook', () => {
});
it('should return default size of image and valid imageUrl', () => {
const imageUrl = `${BASE_MAP_IMAGES_URL}/map_images/${PROJECT_OVERVIEW_IMAGE_MOCK.filename}`;
const imageUrl = `${BASE_MAP_IMAGES_URL}/map_images/${PROJECT_DIRECTORY}/${PROJECT_OVERVIEW_IMAGE_MOCK.filename}`;
expect(result.current).toMatchObject({
imageUrl,
......@@ -88,6 +92,7 @@ describe('useOverviewImage - hook', () => {
},
],
topOverviewImage: PROJECT_OVERVIEW_IMAGE_MOCK,
directory: PROJECT_DIRECTORY,
},
loading: 'succeeded',
error: { message: '', name: '' },
......@@ -109,7 +114,7 @@ describe('useOverviewImage - hook', () => {
);
it('should return size of image and valid imageUrl', () => {
const imageUrl = `${BASE_MAP_IMAGES_URL}/map_images/${PROJECT_OVERVIEW_IMAGE_MOCK.filename}`;
const imageUrl = `${BASE_MAP_IMAGES_URL}/map_images/${PROJECT_DIRECTORY}/${PROJECT_OVERVIEW_IMAGE_MOCK.filename}`;
expect(result.current).toMatchObject({
imageUrl,
......
......@@ -6,6 +6,8 @@ import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithSto
import { renderHook } from '@testing-library/react';
import { useOverviewImageUrl } from './useOverviewImageUrl';
const PROJECT_DIRECTORY = 'directory';
describe('useOverviewImageUrl - hook', () => {
describe('when currentImage data is valid', () => {
const { Wrapper } = getReduxWrapperWithStore({
......@@ -14,6 +16,7 @@ describe('useOverviewImageUrl - hook', () => {
...projectFixture,
overviewImageViews: [],
topOverviewImage: PROJECT_OVERVIEW_IMAGE_MOCK,
directory: PROJECT_DIRECTORY,
},
loading: 'succeeded',
error: { message: '', name: '' },
......@@ -41,6 +44,7 @@ describe('useOverviewImageUrl - hook', () => {
...projectFixture,
overviewImageViews: [PROJECT_OVERVIEW_IMAGE_MOCK],
topOverviewImage: PROJECT_OVERVIEW_IMAGE_MOCK,
directory: PROJECT_DIRECTORY,
},
loading: 'succeeded',
error: { message: '', name: '' },
......@@ -58,7 +62,7 @@ describe('useOverviewImageUrl - hook', () => {
const { result } = renderHook(() => useOverviewImageUrl(), { wrapper: Wrapper });
expect(result.current).toBe(
`${BASE_MAP_IMAGES_URL}/map_images/${PROJECT_OVERVIEW_IMAGE_MOCK.filename}`,
`${BASE_MAP_IMAGES_URL}/map_images/${PROJECT_DIRECTORY}/${PROJECT_OVERVIEW_IMAGE_MOCK.filename}`,
);
});
});
......
import { BASE_MAP_IMAGES_URL } from '@/constants';
import { currentOverviewImageSelector } from '@/redux/project/project.selectors';
import {
currentOverviewImageSelector,
projectDirectorySelector,
} from '@/redux/project/project.selectors';
import { useSelector } from 'react-redux';
export const useOverviewImageUrl = (): string => {
const currentImage = useSelector(currentOverviewImageSelector);
if (!currentImage) {
const directory = useSelector(projectDirectorySelector);
if (!currentImage || !directory) {
return '';
}
return `${BASE_MAP_IMAGES_URL}/map_images/${currentImage.filename}`;
return `${BASE_MAP_IMAGES_URL}/map_images/${directory}/${currentImage.filename}`;
};
......@@ -5,7 +5,7 @@ import { apiPath } from '@/redux/apiPath';
import { DEFAULT_POSITION } from '@/redux/map/map.constants';
import { INITIAL_STORE_STATE_MOCK } from '@/redux/root/root.fixtures';
import { AppDispatch, RootState } from '@/redux/store';
import { BioEntity, MapModel } from '@/types/models';
import { MapModel, PublicationElement } from '@/types/models';
import { mockNetworkNewAPIResponse } from '@/utils/mockNetworkResponse';
import {
InitialStoreState,
......@@ -14,12 +14,12 @@ import {
import { render, screen, waitFor } from '@testing-library/react';
import { HttpStatusCode } from 'axios';
import { MockStoreEnhanced } from 'redux-mock-store';
import { isReactionBioEntity } from '@/redux/reactions/isReactionBioentity';
import { isReactionElement } from '@/redux/reactions/isReactionElement';
import { ElementLink } from './ElementLink.component';
const mockedAxiosNewClient = mockNetworkNewAPIResponse();
const TARGET_ELEMENT: BioEntity = {
const TARGET_ELEMENT: PublicationElement = {
...bioEntityResponseFixture.content[FIRST_ARRAY_ELEMENT].bioEntity,
id: 123,
model: 52,
......@@ -36,20 +36,20 @@ const OTHER_MODEL: MapModel = {
};
interface Props {
target: BioEntity;
target: PublicationElement;
}
const getElementText = (bioEntity: BioEntity): string => {
const isReaction = isReactionBioEntity(bioEntity);
const getElementText = (element: PublicationElement): string => {
const isReaction = isReactionElement(element);
const prefix = isReaction ? 'Reaction: ' : 'Element: ';
return prefix + bioEntity.elementId;
return prefix + element.elementId;
};
const getSearchQuery = (bioEntity: BioEntity): string => {
const isReaction = isReactionBioEntity(bioEntity);
const getSearchQuery = (element: PublicationElement): string => {
const isReaction = isReactionElement(element);
return (isReaction ? 'reaction:' : 'element:') + bioEntity.id;
return (isReaction ? 'reaction:' : 'element:') + element.id;
};
const renderComponent = (
......@@ -86,10 +86,10 @@ describe('ElementLink - component', () => {
});
it('should should show element id', async () => {
const bioEntity = TARGET_ELEMENT;
const element = TARGET_ELEMENT;
await waitFor(() => {
expect(screen.getByText(getElementText(bioEntity))).toBeInTheDocument();
expect(screen.getByText(getElementText(element))).toBeInTheDocument();
});
});
});
......@@ -116,10 +116,10 @@ describe('ElementLink - component', () => {
},
);
const bioEntity = TARGET_ELEMENT;
const element = TARGET_ELEMENT;
await waitFor(() => {
const link = screen.getByText(getElementText(bioEntity));
const link = screen.getByText(getElementText(element));
link.click();
const actions = store.getActions();
......@@ -148,7 +148,7 @@ describe('ElementLink - component', () => {
expect(actions).toEqual(
expect.arrayContaining([
expect.objectContaining({
payload: getSearchQuery(bioEntity),
payload: getSearchQuery(element),
type: 'drawer/openSearchDrawerWithSelectedTab',
}),
]),
......@@ -206,10 +206,10 @@ describe('ElementLink - component', () => {
},
);
const bioEntity = TARGET_ELEMENT;
const element = TARGET_ELEMENT;
await waitFor(() => {
const link = screen.getByText(getElementText(bioEntity));
const link = screen.getByText(getElementText(element));
link.click();
const actions = store.getActions();
......@@ -238,7 +238,7 @@ describe('ElementLink - component', () => {
expect(actions).toEqual(
expect.arrayContaining([
expect.objectContaining({
payload: getSearchQuery(bioEntity),
payload: getSearchQuery(element),
type: 'drawer/openSearchDrawerWithSelectedTab',
}),
]),
......
......@@ -13,11 +13,11 @@ import { closeModal } from '@/redux/modal/modal.slice';
import { modelsNameMapSelector } from '@/redux/models/models.selectors';
import { getSearchData } from '@/redux/search/search.thunks';
import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus';
import { BioEntity } from '@/types/models';
import { isReactionBioEntity } from '@/redux/reactions/isReactionBioentity';
import { PublicationElement } from '@/types/models';
import { isReactionElement } from '@/redux/reactions/isReactionElement';
interface Props {
target: BioEntity;
target: PublicationElement;
}
export const ElementLink = ({ target }: Props): JSX.Element => {
......@@ -26,7 +26,7 @@ export const ElementLink = ({ target }: Props): JSX.Element => {
const currentModelId = useAppSelector(mapModelIdSelector);
const mapsNames = useAppSelector(modelsNameMapSelector);
const isReaction = isReactionBioEntity(target);
const isReaction = isReactionElement(target);
const isMapAlreadyOpened = (modelId: number): boolean =>
openedMaps.some(map => map.modelId === modelId);
......
import { INITIAL_STORE_STATE_MOCK } from '@/redux/root/root.fixtures';
import { AppDispatch, RootState } from '@/redux/store';
import { BioEntity } from '@/types/models';
import { PublicationElement } from '@/types/models';
import {
InitialStoreState,
getReduxStoreWithActionsListener,
} from '@/utils/testing/getReduxStoreActionsListener';
import { render, screen, waitFor } from '@testing-library/react';
import { MockStoreEnhanced } from 'redux-mock-store';
import { bioEntityFixture } from '@/models/fixtures/bioEntityFixture';
import { isReactionBioEntity } from '@/redux/reactions/isReactionBioentity';
import { isReactionElement } from '@/redux/reactions/isReactionElement';
import { publicationElementFixture } from '@/models/fixtures/publicationElementFixture';
import { ElementsOnMapCell } from './ElementsOnMapCell.component';
interface Props {
targets: BioEntity[];
targets: PublicationElement[];
}
const renderComponent = (
......@@ -33,8 +33,8 @@ const renderComponent = (
);
};
const elementFixture = { ...bioEntityFixture, idReaction: undefined };
const reactionFixture = { ...bioEntityFixture, idReaction: '123' };
const elementFixture = { ...publicationElementFixture, idReaction: undefined };
const reactionFixture = { ...publicationElementFixture, idReaction: '123' };
const mockTargets = [{ ...elementFixture }, { ...reactionFixture }];
......@@ -49,7 +49,7 @@ describe('ElementsOnMapCell - component', () => {
await waitFor(() => {
// type as elementId
const isReaction = isReactionBioEntity(bioEntity);
const isReaction = isReactionElement(bioEntity);
const prefix = isReaction ? 'Reaction: ' : 'Element: ';
expect(screen.getByText(prefix + bioEntity.elementId)).toBeInTheDocument();
});
......
import { ONE } from '@/constants/common';
import { BioEntity } from '@/types/models';
import { PublicationElement } from '@/types/models';
import { ElementLink } from './ElementLink';
interface Props {
targets: BioEntity[];
targets: PublicationElement[];
}
export const ElementsOnMapCell = ({ targets }: Props): JSX.Element => {
......
......@@ -23,7 +23,7 @@ import {
} from '@tanstack/react-table';
import { useRef, useState } from 'react';
import { z } from 'zod';
import { bioEntitySchema } from '@/models/bioEntitySchema';
import { publicationElementSchema } from '@/models/publicationElementSchema';
import { ElementsOnMapCell } from './ElementsOnMapCell';
import { FilterBySubmapHeader } from './FilterBySubmapHeader/FilterBySubmapHeader.component';
import { DEFAULT_PAGE_SIZE } from './PublicationsTable.constants';
......@@ -74,9 +74,7 @@ const columns = [
cell: ({ getValue }): JSX.Element => {
try {
const valueObject: unknown = JSON.parse(getValue());
// eslint-disable-next-line no-console
console.log(valueObject);
const targets = z.array(bioEntitySchema).parse(valueObject);
const targets = z.array(publicationElementSchema).parse(valueObject);
return <ElementsOnMapCell targets={targets} />;
} catch (error) {
......
......@@ -49,7 +49,7 @@ describe('ClearAnchorsButton - component', () => {
{ payload: undefined, type: 'contextMenu/closeContextMenu' },
{ payload: undefined, type: 'reactions/resetReactionsData' },
{ payload: undefined, type: 'search/clearSearchData' },
{ payload: undefined, type: 'bioEntityContents/clearBioEntities' },
{ payload: undefined, type: 'modelElements/clearSearchModelElements' },
{ payload: undefined, type: 'drugs/clearDrugsData' },
{ payload: undefined, type: 'chemicals/clearChemicalsData' },
]);
......@@ -75,7 +75,7 @@ describe('ClearAnchorsButton - component', () => {
{ payload: undefined, type: 'contextMenu/closeContextMenu' },
{ payload: undefined, type: 'reactions/resetReactionsData' },
{ payload: undefined, type: 'search/clearSearchData' },
{ payload: undefined, type: 'bioEntityContents/clearBioEntities' },
{ payload: undefined, type: 'modelElements/clearSearchModelElements' },
{ payload: undefined, type: 'drugs/clearDrugsData' },
{ payload: undefined, type: 'chemicals/clearChemicalsData' },
]);
......
import { clearBioEntities } from '@/redux/bioEntity/bioEntity.slice';
import { clearChemicalsData } from '@/redux/chemicals/chemicals.slice';
import { closeContextMenu } from '@/redux/contextMenu/contextMenu.slice';
import { resultDrawerOpen } from '@/redux/drawer/drawer.selectors';
......@@ -11,6 +10,7 @@ import { Button } from '@/shared/Button';
import { Icon } from '@/shared/Icon';
import React from 'react';
import { useSelector } from 'react-redux';
import { clearSearchModelElements } from '@/redux/modelElements/modelElements.slice';
export const ClearAnchorsButton = (): React.ReactNode => {
const dispatch = useAppDispatch();
......@@ -31,7 +31,7 @@ export const ClearAnchorsButton = (): React.ReactNode => {
dispatch(clearSearchData());
// Reset old pins data
dispatch(clearBioEntities());
dispatch(clearSearchModelElements());
dispatch(clearDrugsData());
dispatch(clearChemicalsData());
};
......
import { SIZE_OF_ARRAY_WITH_ONE_ELEMENT, ZERO } from '@/constants/common';
import { bioEntityContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
import { MODELS_MOCK_SHORT } from '@/models/mocks/modelsMock';
import {
BIOENTITY_INITIAL_STATE_MOCK,
BIO_ENTITY_LINKING_TO_SUBMAP_DATA_MOCK,
BIO_ENTITY_LINKING_TO_SUBMAP,
} from '@/redux/bioEntity/bioEntity.mock';
import { BIOENTITY_INITIAL_STATE_MOCK } from '@/redux/bioEntity/bioEntity.mock';
import { DRAWER_INITIAL_STATE } from '@/redux/drawer/drawer.constants';
import {
initialMapDataFixture,
......@@ -21,6 +16,12 @@ import {
import { act, render, screen } from '@testing-library/react';
import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks';
import { ModelElementsState } from '@/redux/modelElements/modelElements.types';
import {
MODEL_ELEMENT_LINKING_TO_SUBMAP,
MODEL_ELEMENTS_SEARCH_LINKING_TO_SUBMAP_DATA_MOCK,
} from '@/redux/modelElements/modelElements.mock';
import { DEFAULT_ERROR } from '@/constants/errors';
import { modelElementFixture } from '@/models/fixtures/modelElementFixture';
import { AssociatedSubmap } from './AssociatedSubmap.component';
const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
......@@ -43,21 +44,27 @@ describe('AssociatedSubmap - component', () => {
renderComponent({
bioEntity: {
...BIOENTITY_INITIAL_STATE_MOCK,
data: BIO_ENTITY_LINKING_TO_SUBMAP_DATA_MOCK,
},
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
bioentityId: bioEntityContentFixture.bioEntity.id,
bioentityId: modelElementFixture.id,
drugs: {},
chemicals: {},
},
},
modelElements: {
[MAIN_MAP_ID]: {
data: [BIO_ENTITY_LINKING_TO_SUBMAP],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
[MAIN_MAP_ID]: {
data: [MODEL_ELEMENT_LINKING_TO_SUBMAP],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
search: {
data: MODEL_ELEMENTS_SEARCH_LINKING_TO_SUBMAP_DATA_MOCK,
loading: 'idle',
error: DEFAULT_ERROR,
},
} as ModelElementsState,
models: {
......@@ -81,21 +88,27 @@ describe('AssociatedSubmap - component', () => {
},
bioEntity: {
...BIOENTITY_INITIAL_STATE_MOCK,
data: BIO_ENTITY_LINKING_TO_SUBMAP_DATA_MOCK,
},
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
bioentityId: bioEntityContentFixture.bioEntity.id,
bioentityId: modelElementFixture.id,
drugs: {},
chemicals: {},
},
},
modelElements: {
[MAIN_MAP_ID]: {
data: [BIO_ENTITY_LINKING_TO_SUBMAP],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
[MAIN_MAP_ID]: {
data: [MODEL_ELEMENT_LINKING_TO_SUBMAP],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
search: {
data: MODEL_ELEMENTS_SEARCH_LINKING_TO_SUBMAP_DATA_MOCK,
loading: 'idle',
error: DEFAULT_ERROR,
},
} as ModelElementsState,
models: {
......@@ -118,19 +131,25 @@ describe('AssociatedSubmap - component', () => {
},
bioEntity: {
...BIOENTITY_INITIAL_STATE_MOCK,
data: BIO_ENTITY_LINKING_TO_SUBMAP_DATA_MOCK,
},
modelElements: {
0: {
data: [BIO_ENTITY_LINKING_TO_SUBMAP],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
0: {
data: [MODEL_ELEMENT_LINKING_TO_SUBMAP],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
search: {
data: MODEL_ELEMENTS_SEARCH_LINKING_TO_SUBMAP_DATA_MOCK,
loading: 'idle',
error: DEFAULT_ERROR,
},
} as ModelElementsState,
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
bioentityId: bioEntityContentFixture.bioEntity.id,
bioentityId: modelElementFixture.id,
drugs: {},
chemicals: {},
},
......@@ -151,7 +170,6 @@ describe('AssociatedSubmap - component', () => {
modelName: 'Histamine signaling',
lastPosition: { x: 0, y: 0, z: 0 },
});
const openSubmapButton = screen.getByRole('button', { name: 'Open submap' });
await act(() => {
openSubmapButton.click();
......@@ -184,19 +202,25 @@ describe('AssociatedSubmap - component', () => {
},
bioEntity: {
...BIOENTITY_INITIAL_STATE_MOCK,
data: BIO_ENTITY_LINKING_TO_SUBMAP_DATA_MOCK,
},
modelElements: {
[MAIN_MAP_ID]: {
data: [BIO_ENTITY_LINKING_TO_SUBMAP],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
[MAIN_MAP_ID]: {
data: [MODEL_ELEMENT_LINKING_TO_SUBMAP],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
search: {
data: MODEL_ELEMENTS_SEARCH_LINKING_TO_SUBMAP_DATA_MOCK,
loading: 'idle',
error: DEFAULT_ERROR,
},
} as ModelElementsState,
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
bioentityId: bioEntityContentFixture.bioEntity.id,
bioentityId: modelElementFixture.id,
drugs: {},
chemicals: {},
},
......
import { useOpenSubmap } from '@/hooks/useOpenSubmaps';
import { currentDrawerBioEntityRelatedSubmapSelector } from '@/redux/bioEntity/bioEntity.selectors';
import { useAppSelector } from '@/redux/hooks/useAppSelector';
import { Button } from '@/shared/Button';
import { currentDrawerModelElementRelatedSubmapSelector } from '@/redux/modelElements/modelElements.selector';
export const AssociatedSubmap = (): React.ReactNode => {
const relatedSubmap = useAppSelector(currentDrawerBioEntityRelatedSubmapSelector);
const relatedSubmap = useAppSelector(currentDrawerModelElementRelatedSubmapSelector);
const { openSubmap } = useOpenSubmap({
modelId: relatedSubmap?.id,
modelName: relatedSubmap?.name,
......
/* eslint-disable no-magic-numbers */
import { MODELS_MOCK_SHORT } from '@/models/mocks/modelsMock';
import { BIO_ENTITY_LINKING_TO_SUBMAP } from '@/redux/bioEntity/bioEntity.mock';
import { DRAWER_INITIAL_STATE } from '@/redux/drawer/drawer.constants';
import { MODELS_INITIAL_STATE_MOCK } from '@/redux/models/models.mock';
import { INITIAL_STORE_STATE_MOCK } from '@/redux/root/root.fixtures';
......@@ -10,8 +9,11 @@ import { InitialStoreState } from '@/utils/testing/getReduxWrapperWithStore';
import { act, render, screen } from '@testing-library/react';
import { MockStoreEnhanced } from 'redux-mock-store';
import { getTypeBySBOTerm } from '@/utils/bioEntity/getTypeBySBOTerm';
import { ModelElementsState } from '@/redux/modelElements/modelElements.types';
import { modelElementFixture } from '@/models/fixtures/modelElementFixture';
import {
MODEL_ELEMENT_LINKING_TO_SUBMAP,
MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
} from '@/redux/modelElements/modelElements.mock';
import { BioEntityDrawer } from './BioEntityDrawer.component';
const renderComponent = (
......@@ -43,10 +45,15 @@ describe('BioEntityDrawer - component', () => {
describe("when there's NO matching bioEntity", () => {
beforeEach(() =>
renderComponent({
bioEntity: {
data: [],
loading: 'succeeded',
error: { message: '', name: '' },
modelElements: {
data: {
0: {
data: [],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
},
drawer: DRAWER_INITIAL_STATE,
}),
......@@ -67,12 +74,15 @@ describe('BioEntityDrawer - component', () => {
it('should show drawer header', () => {
renderComponent({
modelElements: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName }],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName }],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
} as ModelElementsState,
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
},
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
......@@ -91,12 +101,15 @@ describe('BioEntityDrawer - component', () => {
it('should show drawer bioEntity full name', () => {
renderComponent({
modelElements: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: bioEntityFullName }],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: bioEntityFullName }],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
} as ModelElementsState,
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
},
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
......@@ -114,12 +127,15 @@ describe('BioEntityDrawer - component', () => {
it("should not show drawer bioEntity full name if it doesn't exists", () => {
renderComponent({
modelElements: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
} as ModelElementsState,
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
},
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
......@@ -136,12 +152,15 @@ describe('BioEntityDrawer - component', () => {
it('should show list of annotations ', () => {
renderComponent({
modelElements: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
} as ModelElementsState,
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
},
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
......@@ -164,16 +183,19 @@ describe('BioEntityDrawer - component', () => {
it('should display associated submaps if bio entity links to submap', () => {
renderComponent({
modelElements: {
0: {
data: [{ ...BIO_ENTITY_LINKING_TO_SUBMAP, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
0: {
data: [{ ...MODEL_ELEMENT_LINKING_TO_SUBMAP, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
} as ModelElementsState,
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
},
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
bioentityId: BIO_ENTITY_LINKING_TO_SUBMAP.id,
bioentityId: MODEL_ELEMENT_LINKING_TO_SUBMAP.id,
drugs: {},
chemicals: {},
},
......@@ -190,12 +212,15 @@ describe('BioEntityDrawer - component', () => {
it('should display chemicals list header', () => {
renderComponent({
modelElements: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
} as ModelElementsState,
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
},
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
......@@ -212,12 +237,15 @@ describe('BioEntityDrawer - component', () => {
it('should display drugs list header', () => {
renderComponent({
modelElements: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
} as ModelElementsState,
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
},
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
......@@ -234,12 +262,15 @@ describe('BioEntityDrawer - component', () => {
it('should fetch chemicals on chemicals for target click', () => {
const { store } = renderComponent({
modelElements: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
} as ModelElementsState,
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
},
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
......@@ -263,12 +294,15 @@ describe('BioEntityDrawer - component', () => {
it('should fetch drugs on drugs for target click', () => {
const { store } = renderComponent({
modelElements: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
0: {
data: [{ ...modelElementFixture, name: bioEntityName, fullName: null }],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
} as ModelElementsState,
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
},
drawer: {
...DRAWER_INITIAL_STATE,
bioEntityDrawerState: {
......
import { ZERO } from '@/constants/common';
import {
currentDrawerBioEntityRelatedSubmapSelector,
currentDrawerElementCommentsSelector,
} from '@/redux/bioEntity/bioEntity.selectors';
import {
getChemicalsForBioEntityDrawerTarget,
getDrugsForBioEntityDrawerTarget,
......@@ -18,6 +14,8 @@ import React from 'react';
import { AnnotationItemList } from '@/components/Map/Drawer/BioEntityDrawer/AnnotationItem/AnnotationItemList.component';
import {
compartmentNameByIdSelector,
currentDrawerElementCommentsSelector,
currentDrawerModelElementRelatedSubmapSelector,
currentDrawerModelElementSelector,
} from '@/redux/modelElements/modelElements.selector';
import { CollapsibleSection } from '../ExportDrawer/CollapsibleSection';
......@@ -32,7 +30,7 @@ export const BioEntityDrawer = (): React.ReactNode => {
const dispatch = useAppDispatch();
const modelElement = useAppSelector(currentDrawerModelElementSelector);
const commentsData = useAppSelector(currentDrawerElementCommentsSelector);
const relatedSubmap = useAppSelector(currentDrawerBioEntityRelatedSubmapSelector);
const relatedSubmap = useAppSelector(currentDrawerModelElementRelatedSubmapSelector);
const currentTargetId = modelElement?.id ? `${TARGET_PREFIX}:${modelElement.id}` : '';
const fetchChemicalsForTarget = (): void => {
dispatch(getChemicalsForBioEntityDrawerTarget(currentTargetId));
......
/* eslint-disable no-magic-numbers */
import { ZERO } from '@/constants/common';
import { bioEntitiesContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
import { overlayFixture } from '@/models/fixtures/overlaysFixture';
import { GENE_VARIANTS_MOCK } from '@/models/mocks/geneVariantsMock';
import { CORE_PD_MODEL_MOCK } from '@/models/mocks/modelsMock';
......@@ -61,26 +60,6 @@ describe('OverlayData - component', () => {
...INITIAL_STORE_STATE_MOCK.overlays,
data: [{ ...overlayFixture, name: 'axis name' }],
},
bioEntity: {
data: [
{
searchQueryElement: '',
loading: 'pending',
error: { name: '', message: '' },
data: [
{
...bioEntitiesContentFixture[0],
bioEntity: {
...bioEntitiesContentFixture[0].bioEntity,
id: BIO_ENTITY.id,
},
},
],
},
],
loading: 'pending',
error: { name: '', message: '' },
},
overlayBioEntity: {
...OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK,
overlaysId: [OVERLAY_ID],
......@@ -133,26 +112,6 @@ describe('OverlayData - component', () => {
...INITIAL_STORE_STATE_MOCK.overlays,
data: [{ ...overlayFixture, name: 'overlay name' }],
},
bioEntity: {
data: [
{
searchQueryElement: '',
loading: 'pending',
error: { name: '', message: '' },
data: [
{
...bioEntitiesContentFixture[0],
bioEntity: {
...bioEntitiesContentFixture[0].bioEntity,
id: BIO_ENTITY.id,
},
},
],
},
],
loading: 'pending',
error: { name: '', message: '' },
},
overlayBioEntity: {
...OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK,
overlaysId: [OVERLAY_ID],
......@@ -209,26 +168,6 @@ describe('OverlayData - component', () => {
...INITIAL_STORE_STATE_MOCK.overlays,
data: [{ ...overlayFixture, name: 'overlay name' }],
},
bioEntity: {
data: [
{
searchQueryElement: '',
loading: 'pending',
error: { name: '', message: '' },
data: [
{
...bioEntitiesContentFixture[0],
bioEntity: {
...bioEntitiesContentFixture[0].bioEntity,
id: BIO_ENTITY.id,
},
},
],
},
],
loading: 'pending',
error: { name: '', message: '' },
},
overlayBioEntity: {
...OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK,
overlaysId: [OVERLAY_ID],
......
import { FIRST_ARRAY_ELEMENT } from '@/constants/common';
import {
openBioEntityDrawerById,
openReactionDrawerById,
......@@ -12,10 +11,11 @@ import {
getReduxWrapperWithStore,
} from '@/utils/testing/getReduxWrapperWithStore';
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import type {} from 'redux-thunk/extend-redux';
import { bioEntitiesContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
import { newReactionFixture } from '@/models/fixtures/newReactionFixture';
import { modelElementFixture } from '@/models/fixtures/modelElementFixture';
import { MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK } from '@/redux/modelElements/modelElements.mock';
import { Drawer } from './Drawer.component';
import type {} from 'redux-thunk/extend-redux';
const renderComponent = (initialStore?: InitialStoreState): { store: StoreType } => {
const { Wrapper, store } = getReduxWrapperWithStore(initialStore);
......@@ -121,20 +121,18 @@ describe('Drawer - component', () => {
describe('bioEntity drawer', () => {
it.skip('should open drawer and display bioEntity', async () => {
const { id } = bioEntitiesContentFixture[FIRST_ARRAY_ELEMENT].bioEntity;
const { id } = modelElementFixture;
const { store } = renderComponent({
bioEntity: {
data: [
{
searchQueryElement: '',
modelElements: {
data: {
0: {
data: [modelElementFixture],
loading: 'succeeded',
error: { name: '', message: '' },
data: bioEntitiesContentFixture,
error: { message: '', name: '' },
},
],
loading: 'succeeded',
error: { message: '', name: '' },
},
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
},
});
......
......@@ -16,6 +16,7 @@ import { MockStoreEnhanced } from 'redux-mock-store';
import { modelElementFixture } from '@/models/fixtures/modelElementFixture';
import { ModelElementsState } from '@/redux/modelElements/modelElements.types';
import { COMPARTMENT_SBO_TERM } from '@/components/Map/MapViewer/MapViewer.constants';
import { MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK } from '@/redux/modelElements/modelElements.mock';
import { ELEMENTS_COLUMNS } from '../ExportCompound/ExportCompound.constant';
import { Elements } from './Elements.component';
......@@ -133,24 +134,27 @@ describe('Elements - component', () => {
},
},
modelElements: {
0: {
data: [
{
...modelElementFixture,
id: FIRST_COMPARMENT_PATHWAY_ID,
name: FIRST_COMPARMENT_PATHWAY_NAME,
sboTerm: COMPARTMENT_SBO_TERM,
},
{
...modelElementFixture,
id: SECOND_COMPARMENT_PATHWAY_ID,
name: SECOND_COMPARMENT_PATHWAY_NAME,
sboTerm: COMPARTMENT_SBO_TERM,
},
],
loading: 'succeeded',
error: { message: '', name: '' },
data: {
0: {
data: [
{
...modelElementFixture,
id: FIRST_COMPARMENT_PATHWAY_ID,
name: FIRST_COMPARMENT_PATHWAY_NAME,
sboTerm: COMPARTMENT_SBO_TERM,
},
{
...modelElementFixture,
id: SECOND_COMPARMENT_PATHWAY_ID,
name: SECOND_COMPARMENT_PATHWAY_NAME,
sboTerm: COMPARTMENT_SBO_TERM,
},
],
loading: 'succeeded',
error: { message: '', name: '' },
},
},
search: MODEL_ELEMENTS_SEARCH_INITIAL_STATE_MOCK,
} as ModelElementsState,
});
......