diff --git a/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx b/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx index 0b3e93aa33fc86e02ada210a11c31bccc52c9010..d3880a0982b7ed610b201de0f4b8d17f853bc4b6 100644 --- a/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx +++ b/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx @@ -1,23 +1,23 @@ -import { StoreType } from '@/redux/store'; -import { - InitialStoreState, - getReduxWrapperWithStore, -} from '@/utils/testing/getReduxWrapperWithStore'; -import { act, render, screen } from '@testing-library/react'; +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, } from '@/redux/bioEntity/bioEntity.mock'; -import { bioEntityContentFixture } from '@/models/fixtures/bioEntityContentsFixture'; import { DRAWER_INITIAL_STATE } from '@/redux/drawer/drawer.constants'; -import { MODELS_INITIAL_STATE_MOCK } from '@/redux/models/models.mock'; -import { MODELS_MOCK_SHORT } from '@/models/mocks/modelsMock'; import { initialMapDataFixture, openedMapsInitialValueFixture, openedMapsThreeSubmapsFixture, } from '@/redux/map/map.fixtures'; -import { SIZE_OF_ARRAY_WITH_ONE_ELEMENT, ZERO } from '@/constants/common'; +import { MODELS_INITIAL_STATE_MOCK } from '@/redux/models/models.mock'; +import { StoreType } from '@/redux/store'; +import { + InitialStoreState, + getReduxWrapperWithStore, +} from '@/utils/testing/getReduxWrapperWithStore'; +import { act, render, screen } from '@testing-library/react'; import { AssociatedSubmap } from './AssociatedSubmap.component'; const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { @@ -49,6 +49,8 @@ describe('AssociatedSubmap - component', () => { ...DRAWER_INITIAL_STATE, bioEntityDrawerState: { bioentityId: bioEntityContentFixture.bioEntity.id, + drugs: {}, + chemicals: {}, }, }, models: { @@ -68,6 +70,8 @@ describe('AssociatedSubmap - component', () => { ...DRAWER_INITIAL_STATE, bioEntityDrawerState: { bioentityId: bioEntityContentFixture.bioEntity.id, + drugs: {}, + chemicals: {}, }, }, models: { @@ -96,6 +100,8 @@ describe('AssociatedSubmap - component', () => { ...DRAWER_INITIAL_STATE, bioEntityDrawerState: { bioentityId: bioEntityContentFixture.bioEntity.id, + drugs: {}, + chemicals: {}, }, }, models: { @@ -153,6 +159,8 @@ describe('AssociatedSubmap - component', () => { ...DRAWER_INITIAL_STATE, bioEntityDrawerState: { bioentityId: bioEntityContentFixture.bioEntity.id, + drugs: {}, + chemicals: {}, }, }, models: { diff --git a/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx b/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx index 1c37d3bd8052b197d937f19dc370ac4bba753786..2ee7eb5b5a6eb3e445c572fe5fa593062bd482a2 100644 --- a/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx +++ b/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx @@ -10,6 +10,7 @@ import { import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { DrawerHeading } from '@/shared/DrawerHeading'; +import { ElementSearchResultType } from '@/types/models'; import { CollapsibleSection } from '../ExportDrawer/CollapsibleSection'; import { AnnotationItem } from './AnnotationItem'; import { AssociatedSubmap } from './AssociatedSubmap'; diff --git a/src/components/Map/Drawer/BioEntityDrawer/ChemicalsList/ChemicalsList.component.tsx b/src/components/Map/Drawer/BioEntityDrawer/ChemicalsList/ChemicalsList.component.tsx index ffbacbd9ead73d2d82043c0f2fe2c42ebdfa81c0..c7cb5b9f3b6a184a8e64043a8ac12e64dcf1bdc8 100644 --- a/src/components/Map/Drawer/BioEntityDrawer/ChemicalsList/ChemicalsList.component.tsx +++ b/src/components/Map/Drawer/BioEntityDrawer/ChemicalsList/ChemicalsList.component.tsx @@ -1,21 +1,22 @@ +import { ZERO } from '@/constants/common'; import { currentSearchedBioEntityChemicalsSelector } from '@/redux/drawer/drawer.selectors'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { LoadingIndicator } from '@/shared/LoadingIndicator'; -import { ZERO } from '@/constants/common'; import { BioEntitiesPinsListItem } from '../../SearchDrawerWrapper/BioEntitiesResultsList/BioEntitiesPinsList/BioEntitiesPinsListItem'; export const ChemicalsList = (): JSX.Element => { const chemicals = useAppSelector(currentSearchedBioEntityChemicalsSelector); const chemicalsData = chemicals.data || []; + const isPending = chemicals.loading === 'pending'; - if (chemicals.loading === 'pending') { + if (isPending) { return <LoadingIndicator />; } return ( <div> - {chemicalsData.map(drug => ( - <BioEntitiesPinsListItem key={`${drug.id}`} pin={drug} name={drug.name} /> + {chemicalsData.map(chemical => ( + <BioEntitiesPinsListItem key={`${chemical.id}`} pin={chemical} name={chemical.name} /> ))} {chemicalsData.length === ZERO && 'List is empty'} </div> diff --git a/src/components/Map/Drawer/BioEntityDrawer/DrugsList/DrugsList.component.tsx b/src/components/Map/Drawer/BioEntityDrawer/DrugsList/DrugsList.component.tsx index 998a0a77fc5adcd0f9d7fb253d72477a72d39a43..da8cf74fd112b3143271ee9c3cba4cd7837cfb83 100644 --- a/src/components/Map/Drawer/BioEntityDrawer/DrugsList/DrugsList.component.tsx +++ b/src/components/Map/Drawer/BioEntityDrawer/DrugsList/DrugsList.component.tsx @@ -7,8 +7,9 @@ import { BioEntitiesPinsListItem } from '../../SearchDrawerWrapper/BioEntitiesRe export const DrugsList = (): JSX.Element => { const drugs = useAppSelector(currentSearchedBioEntityDrugsSelector); const drugsData = drugs.data || []; + const isPending = drugs.loading === 'pending'; - if (drugs.loading === 'pending') { + if (isPending) { return <LoadingIndicator />; } diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/ResultsList.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/ResultsList.component.test.tsx index 94bc618d7d632fd681c45a9f96b2523fd6b8dffc..24af3ef7543bba17574ae3df30766b182d405346 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/ResultsList.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/ResultsList.component.test.tsx @@ -1,11 +1,11 @@ /* eslint-disable no-magic-numbers */ -import { act, render, screen } from '@testing-library/react'; +import { drugsFixture } from '@/models/fixtures/drugFixtures'; +import { StoreType } from '@/redux/store'; import { InitialStoreState, getReduxWrapperWithStore, } from '@/utils/testing/getReduxWrapperWithStore'; -import { StoreType } from '@/redux/store'; -import { drugsFixture } from '@/models/fixtures/drugFixtures'; +import { act, render, screen } from '@testing-library/react'; import { ResultsList } from './ResultsList.component'; const INITIAL_STATE: InitialStoreState = { @@ -25,7 +25,10 @@ const INITIAL_STATE: InitialStoreState = { selectedSearchElement: 'aspirin', }, reactionDrawerState: {}, - bioEntityDrawerState: {}, + bioEntityDrawerState: { + drugs: {}, + chemicals: {}, + }, overlayDrawerState: { currentStep: 0, }, diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/SearchDrawerWrapper.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/SearchDrawerWrapper.component.test.tsx index c36eb3a97ab71c8c936439e223f01849b459a275..3ad3dbabe05b7683c49f4916d616c884b0e4aa47 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/SearchDrawerWrapper.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/SearchDrawerWrapper.component.test.tsx @@ -44,7 +44,10 @@ describe('SearchDrawerWrapper - component', () => { selectedSearchElement: '', }, reactionDrawerState: {}, - bioEntityDrawerState: {}, + bioEntityDrawerState: { + drugs: {}, + chemicals: {}, + }, overlayDrawerState: { currentStep: 0, }, @@ -67,7 +70,10 @@ describe('SearchDrawerWrapper - component', () => { selectedSearchElement: '', }, reactionDrawerState: {}, - bioEntityDrawerState: {}, + bioEntityDrawerState: { + drugs: {}, + chemicals: {}, + }, overlayDrawerState: { currentStep: 0, }, diff --git a/src/redux/drawer/drawerFixture.ts b/src/redux/drawer/drawerFixture.ts index 29b32d3aeb1d5f53ff6ee34abd86d325d6a71e8b..fc7138abf5033cc3c2b233d85092dd17f1788d88 100644 --- a/src/redux/drawer/drawerFixture.ts +++ b/src/redux/drawer/drawerFixture.ts @@ -11,7 +11,10 @@ export const initialStateFixture: DrawerState = { selectedSearchElement: '', }, reactionDrawerState: {}, - bioEntityDrawerState: {}, + bioEntityDrawerState: { + drugs: {}, + chemicals: {}, + }, overlayDrawerState: { currentStep: 0, }, @@ -28,7 +31,10 @@ export const openedDrawerSubmapsFixture: DrawerState = { selectedSearchElement: '', }, reactionDrawerState: {}, - bioEntityDrawerState: {}, + bioEntityDrawerState: { + drugs: {}, + chemicals: {}, + }, overlayDrawerState: { currentStep: 0, }, @@ -45,7 +51,10 @@ export const drawerSearchStepOneFixture: DrawerState = { selectedSearchElement: '', }, reactionDrawerState: {}, - bioEntityDrawerState: {}, + bioEntityDrawerState: { + drugs: {}, + chemicals: {}, + }, overlayDrawerState: { currentStep: 0, }, @@ -62,7 +71,10 @@ export const drawerSearchDrugsStepTwoFixture: DrawerState = { selectedSearchElement: '', }, reactionDrawerState: {}, - bioEntityDrawerState: {}, + bioEntityDrawerState: { + drugs: {}, + chemicals: {}, + }, overlayDrawerState: { currentStep: 0, }, @@ -79,7 +91,10 @@ export const drawerSearchChemicalsStepTwoFixture: DrawerState = { selectedSearchElement: '', }, reactionDrawerState: {}, - bioEntityDrawerState: {}, + bioEntityDrawerState: { + drugs: {}, + chemicals: {}, + }, overlayDrawerState: { currentStep: 0, }, @@ -96,7 +111,10 @@ export const drawerOverlaysStepOneFixture: DrawerState = { selectedSearchElement: '', }, reactionDrawerState: {}, - bioEntityDrawerState: {}, + bioEntityDrawerState: { + drugs: {}, + chemicals: {}, + }, overlayDrawerState: { currentStep: 2, }, @@ -113,7 +131,10 @@ export const openedExportDrawerFixture: DrawerState = { selectedSearchElement: '', }, reactionDrawerState: {}, - bioEntityDrawerState: {}, + bioEntityDrawerState: { + drugs: {}, + chemicals: {}, + }, overlayDrawerState: { currentStep: 0, },