import { And , Given , Then , When } from 'cypress-cucumber-preprocessor/steps' ; import { InstallXOptions } from '../../../../src/x-installer/x-installer/types' ; Given ( 'following config: hide if equals query {boolean}, requested items {int}' , ( hideIfEqualsQuery , maxItemsToRequest ) => { const config = { querySuggestions : { config : { hideIfEqualsQuery , maxItemsToRequest } } , historyQueries : { config : { hideIfEqualsQuery : false } } } ; cy . visit ( '/?useMockedAdapter=true' , { qs : { xModules : JSON . stringify ( config ) } } ) ; } ) ; And ( 'no query suggestions are displayed' , ( ) => { cy . getByDataTest ( 'query-suggestion' ) . should ( 'not.exist' ) ; } ) ; Then ( 'at most {int} query suggestions are displayed' , ( maxItemsToRequest ) => { cy . getByDataTest ( 'query-suggestion' ) . should ( 'have.length.at.least' , 1 ) . and ( 'have.length.at.most' , maxItemsToRequest ) ; } ) ; And ( 'all query suggestions contain the searched query' , function ( this ) { const wordsInQuery = this . searchedQuery . split ( ' ' ) ; cy . getByDataTest ( 'query-suggestion' ) . should ( suggestions => { suggestions . each ( ( _ , e ) => { for ( const word of wordsInQuery ) { expect ( e ) . to . contain ( word ) ; } } ) ; } ) ; } ) ; When ( 'query suggestion number {int} is clicked' , ( querySuggestionItem ) => { cy . getByDataTest ( 'query-suggestion' ) . eq ( querySuggestionItem ) . click ( ) . invoke ( 'text' ) . as ( 'searchedQuery' ) ; } ) ; Then ( '{string} term is not included as first query suggestion is {boolean}' , ( query , hideIfEqualsQuery ) => { if ( hideIfEqualsQuery ) { cy . getByDataTest ( 'query-suggestion' ) . first ( ) . should ( 'not.have.text' , query ) ; } else { cy . getByDataTest ( 'query-suggestion' ) . first ( ) . should ( 'have.text' , query ) ; } } ) ;