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