Skip to content
Snippets Groups Projects

test(search): added missing tests for search flow

Merged Mateusz Bolewski requested to merge fix/search-bioentites-tests into development
8 unresolved threads

Added tests files for search flow:

  • Bio Entities Accrodions
  • Pins List
  • Pin Details
  • Bio Entities Pins List
  • Bio Entities Pins Details

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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();
  • 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">
  • 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

    • Please register or sign in to reply
  • LGTM. One test scenario is missing, check comments

  • Tadeusz Miesiąc approved this merge request

    approved this merge request

  • Tadeusz Miesiąc mentioned in merge request !64 (merged)

    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 : ``}
  • 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 : '';
  • Adrian Orłów approved this merge request

    approved this merge request

  • 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 : '';
  • 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);
  • RFC - PinsList test fix. Please check Tadeusz's comment

    RFC - "First element in fixture has empty name"

    Edited by Adrian Orłów
  • added 1 commit

    • 5d2768ec - test(search): code review fixes

    Compare with previous version

  • Mateusz Bolewski enabled an automatic merge when the pipeline for 5d2768ec succeeds

    enabled an automatic merge when the pipeline for 5d2768ec succeeds

  • Mateusz Bolewski mentioned in commit 21d10c49

    mentioned in commit 21d10c49

  • Please register or sign in to reply
    Loading