import { imageCompare } from '../common/image-compare' ; import { SearchBuilderPage } from './search-builder.po.spec' ; describe ( 'Search Builder Tests' , ( ) => { let page ; beforeEach ( async ( ) => { page = new SearchBuilderPage . Page ( ) ; await page . getPage ( ) ; } ) ; it ( 'should have the correct initial state' , async ( ) => { let query = await page . getQueryObject ( ) ; expect ( query . keywords . length ) . toBe ( 0 ) ; expect ( query . any . length ) . toBe ( 0 ) ; expect ( query . all . length ) . toBe ( 0 ) ; expect ( query . none . length ) . toBe ( 0 ) ; expect ( await page . getValid ( ) ) . toBeTruthy ( ) ; expect ( await imageCompare ( 'search-builder-initial' ) ) . toEqual ( 0 ) ; } ) ; it ( 'should be able to add a text component' , async ( ) => { await page . addTextField ( ) ; let query = await page . getQueryObject ( ) ; expect ( query . keywords . length ) . toBe ( 1 ) ; expect ( query . any . length ) . toBe ( 0 ) ; expect ( query . all . length ) . toBe ( 0 ) ; expect ( query . none . length ) . toBe ( 0 ) ; expect ( await page . getValid ( ) ) . toBeTruthy ( ) ; expect ( await imageCompare ( 'search-builder-text' ) ) . toEqual ( 0 ) ; } ) ; it ( 'should be able to add a date component' , async ( ) => { await page . addDateField ( ) ; let query = await page . getQueryObject ( ) ; expect ( query . keywords . length ) . toBe ( 0 ) ; expect ( query . any . length ) . toBe ( 1 ) ; expect ( query . all . length ) . toBe ( 0 ) ; expect ( query . none . length ) . toBe ( 0 ) ; expect ( await page . getValid ( ) ) . toBeTruthy ( ) ; } ) ; it ( 'should be able to add a date range component' , async ( ) => { await page . addDateRangeField ( ) ; let query = await page . getQueryObject ( ) ; expect ( query . keywords . length ) . toBe ( 0 ) ; expect ( query . any . length ) . toBe ( 0 ) ; expect ( query . all . length ) . toBe ( 1 ) ; expect ( query . none . length ) . toBe ( 0 ) ; expect ( await page . getValid ( ) ) . toBeTruthy ( ) ; } ) ; it ( 'should be able to add a select component' , async ( ) => { await page . addSelectField ( ) ; let query = await page . getQueryObject ( ) ; expect ( query . keywords . length ) . toBe ( 0 ) ; expect ( query . any . length ) . toBe ( 0 ) ; expect ( query . all . length ) . toBe ( 0 ) ; expect ( query . none . length ) . toBe ( 1 ) ; expect ( await page . getValid ( ) ) . toBeTruthy ( ) ; expect ( await imageCompare ( 'search-builder-select' ) ) . toEqual ( 0 ) ; } ) ; it ( 'should update when the query object changes' , async ( ) => { await page . setQuery ( ) ; let query = await page . getQueryObject ( ) ; expect ( query . keywords . length ) . toBe ( 1 ) ; expect ( query . any . length ) . toBe ( 1 ) ; expect ( query . all . length ) . toBe ( 1 ) ; expect ( query . none . length ) . toBe ( 1 ) ; expect ( await page . getValid ( ) ) . toBeTruthy ( ) ; } ) ; } ) ;