test(search): added missing tests for search flow
Added tests files for search flow:
- Bio Entities Accrodions
- Pins List
- Pin Details
- Bio Entities Pins List
- Bio Entities Pins Details
Merge request reports
Activity
assigned to @MateuszBolewski
added 10 commits
-
907d7442...8e885530 - 9 commits from branch
development
- e410058e - Merge branch 'development' of ssh://gitlab.lcsb.uni.lu:8022/minerva/frontend...
-
907d7442...8e885530 - 9 commits from branch
added 1 commit
- c7cb3497 - test(search): added and fixed tests after merging multisearch
25 store, 26 } 27 ); 28 }; 29 30 describe('BioEntitiesPinsList - component ', () => { 31 it('should display list of bio entites elements', () => { 32 renderComponent(bioEntitiesContentFixture); 33 34 const bioEntityName = bioEntitiesContentFixture[1].bioEntity.fullName 35 ? bioEntitiesContentFixture[1].bioEntity.fullName 36 : ''; 37 38 // First element in fixture has empty name 39 expect(screen.getAllByTestId('bio-entity-name')[0].textContent).toHaveLength(0); 40 expect(screen.getByText(bioEntityName, { exact: false })).toBeInTheDocument(); changed this line in version 4 of the diff
25 25 onClick={onSubmapClick} 26 26 type="button" 27 27 className="flex flex-row flex-nowrap items-center justify-between pl-6 [&:not(:last-of-type)]:pb-4" 28 data-testid="bio-entites-submap-button" 28 29 > 29 30 <p className="text-sm font-normal"> 30 31 {mapName} ({numberOfEntities}) 31 32 </p> 32 <Icon name="arrow" className="h-6 w-6 fill-font-500" /> 33 <div data-testid="arrow-icon"> changed this line in version 4 of the diff
6 } from '@/utils/testing/getReduxWrapperWithStore'; 7 import { drugsFixture } from '@/models/fixtures/drugFixtures'; 8 import { StoreType } from '@/redux/store'; 9 import { PinDetailsItem } from '@/types/models'; 10 import { PinType } from '../PinsList.types'; 11 import { PinsListItem } from './PinsListItem.component'; 12 13 const DRUGS_PIN = { 14 name: drugsFixture[0].targets[0].name, 15 pin: drugsFixture[0].targets[0], 16 }; 17 18 const renderComponent = ( 19 name: string, 20 pin: PinDetailsItem, 21 type: PinType, 69 expect(screen.getByTestId('accordions-details')).toBeInTheDocument(); 70 }); 71 it('should display list of mirnas targets', () => { 72 renderComponent(MIRNA_PINS_LIST, 'mirna'); 73 74 expect(screen.getByTestId('pins-list')).toBeInTheDocument(); 75 }); 76 it('should not display list of bio enities when bioEntity is searched', () => { 77 renderComponent([], 'bioEntity'); 78 79 expect(screen.queryByTestId('pins-list')).toBeNull(); 80 }); 81 it('should not display list of pins when none is searched', () => { 82 renderComponent([], 'none'); 83 84 expect(screen.queryByTestId('pins-list')).toBeNull(); line 54,64,69,74,79,84 -> you test if sth is rendered for given type but you don't check what (and thats ok here). It should be tested in PinsListItem like I mentioned in another comment. It's a small hole -> you can have situation when you render wrong data (cuz there is no check for them) and tests pass
mentioned in merge request !64 (merged)
21 21 </p> 22 22 </div> 23 23 <p className="font-bold leading-6"> 24 Full name: <span className="w-full font-normal">{pin.fullName}</span> 24 Full name:{' '} 25 <span className="w-full font-normal" data-testid="bio-entity-name"> 26 {pin.fullName ? pin.fullName : ``} changed this line in version 4 of the diff
24 <BioEntitiesPinsListItem name={name} pin={pin} /> 25 </Wrapper>, 26 ), 27 { 28 store, 29 } 30 ); 31 }; 32 33 describe('BioEntitiesPinsList - component ', () => { 34 it('should display name of bio entity element', () => { 35 renderComponent(BIO_ENTITY.name, BIO_ENTITY); 36 37 const bioEntityName = bioEntitiesContentFixture[2].bioEntity.fullName 38 ? bioEntitiesContentFixture[2].bioEntity.fullName 39 : ''; changed this line in version 4 of the diff
33 describe('BioEntitiesPinsList - component ', () => { 34 it('should display name of bio entity element', () => { 35 renderComponent(BIO_ENTITY.name, BIO_ENTITY); 36 37 const bioEntityName = bioEntitiesContentFixture[2].bioEntity.fullName 38 ? bioEntitiesContentFixture[2].bioEntity.fullName 39 : ''; 40 41 expect(screen.getByText(bioEntityName, { exact: false })).toBeInTheDocument(); 42 }); 43 it('should display symbol of bio entity element', () => { 44 renderComponent(BIO_ENTITY.name, BIO_ENTITY); 45 46 const bioEntitySymbol = bioEntitiesContentFixture[2].bioEntity.symbol 47 ? bioEntitiesContentFixture[2].bioEntity.symbol 48 : ''; changed this line in version 4 of the diff
24 { 25 store, 26 } 27 ); 28 }; 29 30 describe('BioEntitiesPinsList - component ', () => { 31 it('should display list of bio entites elements', () => { 32 renderComponent(bioEntitiesContentFixture); 33 34 const bioEntityName = bioEntitiesContentFixture[1].bioEntity.fullName 35 ? bioEntitiesContentFixture[1].bioEntity.fullName 36 : ''; 37 38 // First element in fixture has empty name 39 expect(screen.getAllByTestId('bio-entity-name')[0].textContent).toHaveLength(0); changed this line in version 4 of the diff
RFC - PinsList test fix. Please check Tadeusz's comment
RFC - "First element in fixture has empty name"
Edited by Adrian Orłówenabled an automatic merge when the pipeline for 5d2768ec succeeds
mentioned in commit 21d10c49