import expect from '@kbn/expect' ; import { LIST_URL } from '@kbn/securitysolution-list-constants' ; import { FtrProviderContext } from '../../common/ftr_provider_context' ; import { getCreateMinimalListSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_list_schema.mock' ; import { createListsIndex , deleteListsIndex , removeListServerGeneratedProperties , } from '../../utils' ; import { getListResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/list_schema.mock' ; export default ( { getService } ) : void => { const supertest = getService ( 'supertest' ) ; const log = getService ( 'log' ) ; describe ( 'find_lists' , ( ) => { describe ( 'find lists' , ( ) => { beforeEach ( async ( ) => { await createListsIndex ( supertest , log ) ; } ) ; afterEach ( async ( ) => { await deleteListsIndex ( supertest , log ) ; } ) ; it ( 'should return an empty find body correctly if no lists are loaded' , async ( ) => { const { body } = await supertest . get ( `${ LIST_URL }/_find` ) . set ( 'kbn-xsrf' , 'true' ) . send ( ) . expect ( 200 ) ; expect ( body ) . to . eql ( { cursor : 'WzBd' , data : [ ] , page : 1 , per_page : 20 , total : 0 , } ) ; } ) ; it ( 'should return a single list when a single list is loaded from a find with defaults added' , async ( ) => { await supertest . post ( LIST_URL ) . set ( 'kbn-xsrf' , 'true' ) . send ( getCreateMinimalListSchemaMock ( ) ) . expect ( 200 ) ; const { body } = await supertest . get ( `${ LIST_URL }/_find` ) . set ( 'kbn-xsrf' , 'true' ) . send ( ) . expect ( 200 ) ; body . data = [ removeListServerGeneratedProperties ( body . data [ 0 ] ) ] ; delete body . cursor ; expect ( body ) . to . eql ( { data : [ getListResponseMockWithoutAutoGeneratedValues ( ) ] , page : 1 , per_page : 20 , total : 1 , } ) ; } ) ; } ) ; } ) ; } ;