Skip to content
Snippets Groups Projects

Feat/open submap bioentity

Merged Mateusz Bolewski requested to merge feat/open-submap-bioentity into development
3 unresolved threads
Files
4
 
/* eslint-disable no-magic-numbers */
import { act, render, screen } from '@testing-library/react';
import { act, render, screen } from '@testing-library/react';
import { StoreType } from '@/redux/store';
import { StoreType } from '@/redux/store';
import { bioEntitiesContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
import { bioEntitiesContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
@@ -5,9 +6,17 @@ import {
@@ -5,9 +6,17 @@ import {
InitialStoreState,
InitialStoreState,
getReduxWrapperWithStore,
getReduxWrapperWithStore,
} from '@/utils/testing/getReduxWrapperWithStore';
} from '@/utils/testing/getReduxWrapperWithStore';
 
import { MODELS_MOCK_SHORT } from '@/models/mocks/modelsMock';
import { drawerSearchStepOneFixture } from '@/redux/drawer/drawerFixture';
import { drawerSearchStepOneFixture } from '@/redux/drawer/drawerFixture';
 
import {
 
initialMapDataFixture,
 
openedMapsInitialValueFixture,
 
openedMapsThreeSubmapsFixture,
 
} from '@/redux/map/map.fixtures';
import { BioEntitiesSubmapItem } from './BioEntitiesSubmapItem.component';
import { BioEntitiesSubmapItem } from './BioEntitiesSubmapItem.component';
 
const CORE_MAP_ID = 5053;
 
const SECOND_STEP = 2;
const SECOND_STEP = 2;
const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
@@ -17,7 +26,8 @@ const renderComponent = (initialStoreState: InitialStoreState = {}): { store: St
@@ -17,7 +26,8 @@ const renderComponent = (initialStoreState: InitialStoreState = {}): { store: St
render(
render(
<Wrapper>
<Wrapper>
<BioEntitiesSubmapItem
<BioEntitiesSubmapItem
mapName="main map"
mapName={MODELS_MOCK_SHORT[0].name}
 
mapId={MODELS_MOCK_SHORT[0].idObject}
numberOfEntities={21}
numberOfEntities={21}
bioEntities={bioEntitiesContentFixture}
bioEntities={bioEntitiesContentFixture}
/>
/>
@@ -33,7 +43,7 @@ describe('BioEntitiesSubmapItem - component', () => {
@@ -33,7 +43,7 @@ describe('BioEntitiesSubmapItem - component', () => {
it('should display map name, number of elements, icon', () => {
it('should display map name, number of elements, icon', () => {
renderComponent();
renderComponent();
expect(screen.getByText('main map (21)')).toBeInTheDocument();
expect(screen.getByText('Core PD map (21)')).toBeInTheDocument();
expect(screen.getByTestId('arrow-icon')).toBeInTheDocument();
expect(screen.getByTestId('arrow-icon')).toBeInTheDocument();
});
});
it('should navigate user to bio enitites results list after clicking button', async () => {
it('should navigate user to bio enitites results list after clicking button', async () => {
@@ -69,4 +79,103 @@ describe('BioEntitiesSubmapItem - component', () => {
@@ -69,4 +79,103 @@ describe('BioEntitiesSubmapItem - component', () => {
expect(currentStep).toBe(SECOND_STEP);
expect(currentStep).toBe(SECOND_STEP);
expect(listOfBioEnitites).toBe(bioEntitiesContentFixture);
expect(listOfBioEnitites).toBe(bioEntitiesContentFixture);
});
});
 
it("should open submap and set it to active if it's not already opened", async () => {
Please register or sign in to reply
 
const { store } = renderComponent({
 
bioEntity: {
 
data: [
 
{
 
searchQueryElement: '',
 
loading: 'succeeded',
 
error: { name: '', message: '' },
 
data: bioEntitiesContentFixture,
 
},
 
],
 
loading: 'succeeded',
 
error: { name: '', message: '' },
 
},
 
drawer: drawerSearchStepOneFixture,
 
models: { data: MODELS_MOCK_SHORT, loading: 'succeeded', error: { name: '', message: '' } },
 
map: {
 
data: initialMapDataFixture,
 
loading: 'succeeded',
 
error: { name: '', message: '' },
 
openedMaps: openedMapsInitialValueFixture,
 
},
 
});
 
 
const {
 
data: { modelId },
 
openedMaps,
 
} = store.getState().map;
 
 
expect(modelId).toBe(0);
 
expect(openedMaps).not.toContainEqual({
 
modelId: CORE_MAP_ID,
 
modelName: 'Core PD map',
 
lastPosition: { x: 0, y: 0, z: 0 },
 
});
 
 
const navigationButton = screen.getByTestId('bio-entites-submap-button');
 
await act(() => {
 
navigationButton.click();
 
});
 
 
const {
 
data: { modelId: newModelId },
 
openedMaps: newOpenedMaps,
 
} = store.getState().map;
 
 
expect(newOpenedMaps).toContainEqual({
 
modelId: CORE_MAP_ID,
 
modelName: 'Core PD map',
 
lastPosition: { x: 0, y: 0, z: 0 },
 
});
 
 
expect(newModelId).toBe(CORE_MAP_ID);
 
});
 
it("should set map active if it's already opened", async () => {
 
const { store } = renderComponent({
 
bioEntity: {
 
data: [
 
{
 
searchQueryElement: '',
 
loading: 'succeeded',
 
error: { name: '', message: '' },
 
data: bioEntitiesContentFixture,
 
},
 
],
 
loading: 'succeeded',
 
error: { name: '', message: '' },
 
},
 
drawer: drawerSearchStepOneFixture,
 
models: { data: MODELS_MOCK_SHORT, loading: 'succeeded', error: { name: '', message: '' } },
 
map: {
 
data: {
 
...initialMapDataFixture,
 
modelId: CORE_MAP_ID,
 
},
 
loading: 'succeeded',
 
error: { name: '', message: '' },
 
openedMaps: openedMapsThreeSubmapsFixture,
 
},
 
});
 
 
const navigationButton = screen.getByTestId('bio-entites-submap-button');
 
await act(() => {
 
navigationButton.click();
 
});
 
 
const {
 
map: {
 
data: { modelId },
 
openedMaps,
 
},
 
} = store.getState();
 
 
const histamineMap = openedMaps.filter(map => map.modelName === 'Histamine signaling');
 
 
// eslint-disable-next-line no-magic-numbers
 
expect(histamineMap.length).toBe(1);
 
expect(modelId).toBe(CORE_MAP_ID);
 
});
});
});
Loading