diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx index a08c2d03588f126c9f2232f7851da1510b535333..e2567df73cefbf654370dc9e9eb9d93dfc11b13a 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx @@ -1,6 +1,6 @@ -// import { bioEntitiesContentFixture } from '@/models/fixtures/bioEntityContentsFixture'; import { MODELS_MOCK } from '@/models/mocks/modelsMock'; import { StoreType } from '@/redux/store'; +import { bioEntitiesContentFixture } from '@/models/fixtures/bioEntityContentsFixture'; import { Accordion } from '@/shared/Accordion'; import { InitialStoreState, @@ -26,14 +26,21 @@ const renderComponent = (initialStoreState: InitialStoreState = {}): { store: St ); }; -describe.skip('BioEntitiesAccordion - component', () => { +describe('BioEntitiesAccordion - component', () => { it('should display loading indicator when bioEntity search is pending', () => { renderComponent({ - // bioEntity: { - // data: undefined, - // loading: 'pending', - // error: { name: '', message: '' }, - // }, + bioEntity: { + data: [ + { + searchQueryElement: '', + loading: 'pending', + error: { name: '', message: '' }, + data: bioEntitiesContentFixture, + }, + ], + loading: 'pending', + error: { name: '', message: '' }, + }, models: { data: [], loading: 'pending', @@ -46,11 +53,18 @@ describe.skip('BioEntitiesAccordion - component', () => { it('should render list of maps with number of entities after succeeded bio entity search', () => { renderComponent({ - // bioEntity: { - // data: bioEntitiesContentFixture, - // loading: 'succeeded', - // error: { name: '', message: '' }, - // }, + bioEntity: { + data: [ + { + searchQueryElement: '', + loading: 'succeeded', + error: { name: '', message: '' }, + data: bioEntitiesContentFixture, + }, + ], + loading: 'succeeded', + error: { name: '', message: '' }, + }, models: { data: MODELS_MOCK, loading: 'succeeded', diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx index af6734a45dcefc287e1ebf18273a203a29fb5b14..5fca44d875fb5454cc2d2c524cbf688bb5722850 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx @@ -39,7 +39,14 @@ describe('BioEntitiesSubmapItem - component', () => { it('should navigate user to bio enitites results list after clicking button', async () => { const { store } = renderComponent({ bioEntity: { - data: bioEntitiesContentFixture, + data: [ + { + searchQueryElement: '', + loading: 'succeeded', + error: { name: '', message: '' }, + data: bioEntitiesContentFixture, + }, + ], loading: 'succeeded', error: { name: '', message: '' }, }, diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/ChemicalsAccordion/ChemicalsAccordion.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/ChemicalsAccordion/ChemicalsAccordion.component.test.tsx index aa6f96359ec742fc0c886248c1c0b1d2b79eb37e..5e85e6ae53922e84d030d6384dc5b5350bf43b86 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/ChemicalsAccordion/ChemicalsAccordion.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/ChemicalsAccordion/ChemicalsAccordion.component.test.tsx @@ -1,11 +1,16 @@ import { act, render, screen } from '@testing-library/react'; +import { MODELS_MOCK } from '@/models/mocks/modelsMock'; import { StoreType } from '@/redux/store'; import { InitialStoreState, getReduxWrapperWithStore, } from '@/utils/testing/getReduxWrapperWithStore'; import { Accordion } from '@/shared/Accordion'; -import { drawerSearchStepOneFixture } from '@/redux/drawer/drawerFixture'; +import { + drawerSearchStepOneFixture, + drawerSearchChemicalsStepTwoFixture, +} from '@/redux/drawer/drawerFixture'; +import { chemicalsFixture } from '@/models/fixtures/chemicalsFixture'; import { ChemicalsAccordion } from './ChemicalsAccordion.component'; const SECOND_STEP = 2; @@ -27,27 +32,56 @@ const renderComponent = (initialStoreState: InitialStoreState = {}): { store: St ); }; -describe.skip('DrugsAccordion - component', () => { +describe('DrugsAccordion - component', () => { it('should display drugs number after succesfull chemicals search', () => { renderComponent({ - // chemicals: { data: chemicalsFixture, loading: 'succeeded', error: { name: '', message: '' } }, + chemicals: { + data: [ + { + searchQueryElement: '', + loading: 'succeeded', + error: { name: '', message: '' }, + data: chemicalsFixture, + }, + ], + loading: 'succeeded', + error: { name: '', message: '' }, + }, + models: { + data: MODELS_MOCK, + loading: 'succeeded', + error: { name: '', message: '' }, + }, }); + expect(screen.getByText('Chemicals (4)')).toBeInTheDocument(); }); it('should display loading indicator while waiting for chemicals search response', () => { renderComponent({ - chemicals: { data: [], loading: 'pending', error: { name: '', message: '' } }, + chemicals: { + data: [ + { + searchQueryElement: '', + loading: 'pending', + error: { name: '', message: '' }, + data: chemicalsFixture, + }, + ], + loading: 'pending', + error: { name: '', message: '' }, + }, + models: { + data: [], + loading: 'pending', + error: { name: '', message: '' }, + }, }); + expect(screen.getByText('Chemicals (Loading...)')).toBeInTheDocument(); }); it('should navigate user to chemical results list after clicking button', async () => { const { store } = renderComponent({ - // chemicals: { - // data: chemicalsFixture, - // loading: 'succeeded', - // error: { name: '', message: '' }, - // }, - drawer: drawerSearchStepOneFixture, + drawer: drawerSearchChemicalsStepTwoFixture, }); const navigationButton = screen.getByTestId('accordion-item-button'); diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/DrugsAccordion/DrugsAccordion.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/DrugsAccordion/DrugsAccordion.component.test.tsx index f9300c239cd84087276b7b899bd7c40603a812dd..dfdbab89420af6132fbc965e055ad8ae0c617181 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/DrugsAccordion/DrugsAccordion.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/DrugsAccordion/DrugsAccordion.component.test.tsx @@ -5,7 +5,11 @@ import { getReduxWrapperWithStore, } from '@/utils/testing/getReduxWrapperWithStore'; import { act, render, screen } from '@testing-library/react'; -import { drawerSearchStepOneFixture } from '@/redux/drawer/drawerFixture'; +import { + drawerSearchStepOneFixture, + drawerSearchDrugsStepTwoFixture, +} from '@/redux/drawer/drawerFixture'; +import { drugsFixture } from '@/models/fixtures/drugFixtures'; import { DrugsAccordion } from './DrugsAccordion.component'; const SECOND_STEP = 2; @@ -27,27 +31,44 @@ const renderComponent = (initialStoreState: InitialStoreState = {}): { store: St ); }; -describe.skip('DrugsAccordion - component', () => { +describe('DrugsAccordion - component', () => { it('should display drugs number after succesfull drug search', () => { renderComponent({ - // drugs: { data: drugsFixture, loading: 'succeeded', error: { name: '', message: '' } }, + drugs: { + data: [ + { + searchQueryElement: '', + loading: 'succeeded', + error: { name: '', message: '' }, + data: drugsFixture, + }, + ], + loading: 'succeeded', + error: { name: '', message: '' }, + }, }); - // expect(screen.getByText('Drugs (4)')).toBeInTheDocument(); + expect(screen.getByText('Drugs (4)')).toBeInTheDocument(); }); it('should display loading indicator while waiting for drug search response', () => { renderComponent({ - drugs: { data: [], loading: 'pending', error: { name: '', message: '' } }, + drugs: { + data: [ + { + searchQueryElement: '', + loading: 'pending', + error: { name: '', message: '' }, + data: drugsFixture, + }, + ], + loading: 'pending', + error: { name: '', message: '' }, + }, }); expect(screen.getByText('Drugs (Loading...)')).toBeInTheDocument(); }); - it('should navigate user to chemical results list after clicking button', async () => { + it('should navigate user to drugs results list after clicking button', async () => { const { store } = renderComponent({ - // drugs: { - // data: drugsFixture, - // loading: 'succeeded', - // error: { name: '', message: '' }, - // }, - drawer: drawerSearchStepOneFixture, + drawer: drawerSearchDrugsStepTwoFixture, }); const navigationButton = screen.getByTestId('accordion-item-button'); diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/MirnaAccordion/MirnaAccordion.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/MirnaAccordion/MirnaAccordion.component.test.tsx index 79b186158eb07b3de7fda3ff7ad8bc81e0405550..5a535d5a6f75cb1920db5df6250b5d375b70b1f0 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/MirnaAccordion/MirnaAccordion.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/MirnaAccordion/MirnaAccordion.component.test.tsx @@ -5,7 +5,11 @@ import { getReduxWrapperWithStore, } from '@/utils/testing/getReduxWrapperWithStore'; import { Accordion } from '@/shared/Accordion'; -import { drawerSearchStepOneFixture } from '@/redux/drawer/drawerFixture'; +import { + drawerSearchStepOneFixture, + drawerSearchMirnaStepTwoFixture, +} from '@/redux/drawer/drawerFixture'; +import { mirnasFixture } from '@/models/fixtures/mirnasFixture'; import { MirnaAccordion } from './MirnaAccordion.component'; const SECOND_STEP = 2; @@ -27,14 +31,25 @@ const renderComponent = (initialStoreState: InitialStoreState = {}): { store: St ); }; -describe.skip('MirnaAccordion - component', () => { - it('should display mirna number after succesfull chemicals search', () => { +describe('MirnaAccordion - component', () => { + it('should display mirna number after succesfull mirna search', () => { renderComponent({ - // mirnas: { data: mirnasFixture, loading: 'succeeded', error: { name: '', message: '' } }, + mirnas: { + data: [ + { + searchQueryElement: '', + loading: 'succeeded', + error: { name: '', message: '' }, + data: mirnasFixture, + }, + ], + loading: 'succeeded', + error: { name: '', message: '' }, + }, }); expect(screen.getByText('MiRNA (4)')).toBeInTheDocument(); }); - it('should display loading indicator while waiting for chemicals search response', () => { + it('should display loading indicator while waiting for mirna search response', () => { renderComponent({ mirnas: { data: [], loading: 'pending', error: { name: '', message: '' } }, }); @@ -42,12 +57,19 @@ describe.skip('MirnaAccordion - component', () => { }); it('should navigate user to mirnas results list after clicking button', async () => { const { store } = renderComponent({ - // mirnas: { - // data: mirnasFixture, - // loading: 'succeeded', - // error: { name: '', message: '' }, - // }, - drawer: drawerSearchStepOneFixture, + mirnas: { + data: [ + { + searchQueryElement: '', + loading: 'succeeded', + error: { name: '', message: '' }, + data: mirnasFixture, + }, + ], + loading: 'succeeded', + error: { name: '', message: '' }, + }, + drawer: drawerSearchMirnaStepTwoFixture, }); const navigationButton = screen.getByTestId('accordion-item-button'); diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/AccordionsDetails/AccordionsDetails.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/AccordionsDetails/AccordionsDetails.component.test.tsx index db286ea51db4e64e2793283cb4c29ad8a9d77082..ff5de2f22965ec9b6ee3697fdca712939a9145e3 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/AccordionsDetails/AccordionsDetails.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/AccordionsDetails/AccordionsDetails.component.test.tsx @@ -41,7 +41,7 @@ const renderComponent = ( ); }; -describe.skip('AccordionsDetails - component', () => { +describe('AccordionsDetails - component', () => { it('should display name of drug', () => { renderComponent(DRUGS_PINS_LIST, 'drugs'); @@ -49,12 +49,12 @@ describe.skip('AccordionsDetails - component', () => { expect(screen.getByText(drugName, { exact: false })).toBeInTheDocument(); }); - it.skip('should display description of drug', () => { + it('should display description of drug', () => { renderComponent(DRUGS_PINS_LIST, 'drugs'); - const drugDescription = drugsFixture[0].description; + const drugDescription = drugsFixture[0].description ? drugsFixture[0].description : ''; - expect(screen.getByText(drugDescription || '', { exact: false })).toBeInTheDocument(); + expect(screen.getByTestId('details-description').textContent).toContain(drugDescription); }); it('should display synonyms of drug', () => { renderComponent(DRUGS_PINS_LIST, 'drugs'); diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/AccordionsDetails/AccordionsDetails.component.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/AccordionsDetails/AccordionsDetails.component.tsx index e8879fec6f33f38b53f500407c04304b9d25badf..c434cbfc67f8904a91770fb9280a69397c34d371 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/AccordionsDetails/AccordionsDetails.component.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/AccordionsDetails/AccordionsDetails.component.tsx @@ -32,7 +32,9 @@ export const AccordionsDetails = ({ pinsList, type }: AccordionsDetailsProps): J <AccordionItemHeading> <AccordionItemButton>Description</AccordionItemButton> </AccordionItemHeading> - <AccordionItemPanel>{getEntityDescriptions(pinsList)}</AccordionItemPanel> + <AccordionItemPanel> + <div data-testid="details-description">{getEntityDescriptions(pinsList)}</div> + </AccordionItemPanel> </AccordionItem> <AccordionItem> <AccordionItemHeading> 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 0f92af580240ea00b095e0ddbb127f5baee6aa6d..233da1643e8d44e3fa2231b54938353d5b80b235 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/ResultsList.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/ResultsList.component.test.tsx @@ -5,29 +5,38 @@ import { getReduxWrapperWithStore, } from '@/utils/testing/getReduxWrapperWithStore'; import { StoreType } from '@/redux/store'; -// import { drugsFixture } from '@/models/fixtures/drugFixtures'; +import { drugsFixture } from '@/models/fixtures/drugFixtures'; import { ResultsList } from './ResultsList.component'; const INITIAL_STATE: InitialStoreState = { - // search: { - // searchValue: 'aspirin', - // loading: 'idle', - // }, - // drawer: { - // isOpen: true, - // drawerName: 'search', - // searchDrawerState: { - // currentStep: 2, - // stepType: 'drugs', - // selectedValue: undefined, - // listOfBioEnitites: [], - // }, - // }, - // drugs: { - // data: drugsFixture, - // loading: 'succeeded', - // error: { name: '', message: '' }, - // }, + search: { + searchValue: ['aspirin'], + loading: 'idle', + perfectMatch: false, + }, + drawer: { + isOpen: true, + drawerName: 'search', + searchDrawerState: { + currentStep: 2, + stepType: 'drugs', + selectedValue: undefined, + listOfBioEnitites: [], + selectedSearchElement: 'aspirin', + }, + }, + drugs: { + data: [ + { + searchQueryElement: 'aspirin', + loading: 'succeeded', + error: { name: '', message: '' }, + data: drugsFixture, + }, + ], + loading: 'succeeded', + error: { name: '', message: '' }, + }, }; const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { @@ -45,7 +54,7 @@ const renderComponent = (initialStoreState: InitialStoreState = {}): { store: St ); }; -describe.skip('ResultsList - component ', () => { +describe('ResultsList - component ', () => { it('should render results and navigation panel', () => { renderComponent(INITIAL_STATE); diff --git a/src/redux/drawer/drawerFixture.ts b/src/redux/drawer/drawerFixture.ts index 51874b0e54cd4c02f18e781b6477c729b4261072..c6c1c62d511a90ce59ca3d41c4a20f57ff58bf7b 100644 --- a/src/redux/drawer/drawerFixture.ts +++ b/src/redux/drawer/drawerFixture.ts @@ -47,3 +47,27 @@ export const drawerSearchDrugsStepTwoFixture: DrawerState = { selectedSearchElement: '', }, }; + +export const drawerSearchChemicalsStepTwoFixture: DrawerState = { + isOpen: true, + drawerName: 'search', + searchDrawerState: { + currentStep: 2, + stepType: 'chemicals', + selectedValue: undefined, + listOfBioEnitites: [], + selectedSearchElement: '', + }, +}; + +export const drawerSearchMirnaStepTwoFixture: DrawerState = { + isOpen: true, + drawerName: 'search', + searchDrawerState: { + currentStep: 2, + stepType: 'mirna', + selectedValue: undefined, + listOfBioEnitites: [], + selectedSearchElement: '', + }, +};