import { And , Given , Then , When } from 'cypress-cucumber-preprocessor/steps' ; import { InstallXOptions } from '../../../../src/x-installer/x-installer/types' ; Given ( 'following config: hide session queries {boolean}, requested items {int}, loadOnInit {boolean}' , ( hideSessionQueries , maxItemsToRequest , loadOnInit ) => { const config = { nextQueries : { config : { hideSessionQueries , maxItemsToRequest , loadOnInit } } , historyQueries : { config : { hideIfEqualsQuery : false } } } ; cy . visit ( '/?useMockedAdapter=true' , { qs : { xModules : JSON . stringify ( config ) } } ) ; } ) ; And ( 'at most {int} next queries are displayed' , ( maxItemsToRequest ) => { cy . getByDataTest ( 'next-query' ) . should ( 'have.length.at.least' , 1 ) . and ( 'have.length.at.most' , maxItemsToRequest ) ; } ) ; When ( 'next query number {int} is clicked' , ( nextQueryItem ) => { cy . getByDataTest ( 'next-query' ) . eq ( nextQueryItem ) . click ( ) . invoke ( 'text' ) . as ( 'searchedQuery' ) ; } ) ; And ( 'next queries do not contain the searched query' , function ( this ) { cy . checkNextQueries ( this . searchedQuery , false ) ; } ) ; And ( 'next queries do not contain the history query is {boolean}' , function ( this , hideSessionQueries ) { if ( hideSessionQueries ) { cy . getByDataTest ( 'next-query' ) . should ( nextQueries => { nextQueries . each ( ( _ , e ) => { expect ( e ) . to . not . have . text ( this . historicalQuery ) ; } ) ; } ) ; } else { cy . getByDataTest ( 'next-query' ) . first ( ) . should ( 'have.text' , this . historicalQuery ) ; } } ) ; Then ( 'next queries contain the history query' , function ( this ) { cy . getByDataTest ( 'next-query' ) . first ( ) . should ( 'have.text' , this . historicalQuery ) ; } ) ; When ( 'the page is reloaded' , ( ) => { cy . reload ( ) ; } ) ; And ( 'next queries are still displayed' , function ( this ) { cy . getByDataTest ( 'next-query' ) . should ( 'have.text' , this . nextQueries ) ; } ) ; Then ( 'next queries are still displayed is {boolean}' , function ( this , loadOnInit ) { if ( loadOnInit ) { cy . getByDataTest ( 'next-query' ) . should ( 'have.text' , this . nextQueries ) ; } else { cy . getByDataTest ( 'next-query' ) . should ( 'not.exist' ) ; } } ) ;