@@ -71,21 +71,19 @@ describe.each([
7171 await client . index ( indexPk . uid ) . waitForPendingUpdate ( updateId )
7272 } )
7373
74-
7574 test ( `${ permission } key: Add documents to uid with primary key in batch` , async ( ) => {
76- const updateIds : number [ ] = await client
75+ const response : EnqueuedUpdate [ ] = await client
7776 . index ( indexPk . uid )
7877 . addDocumentsInBatch ( dataset , 4 )
79- . then ( ( response : EnqueuedUpdate [ ] ) => {
80- expect ( response ) . toBeInstanceOf ( Array ) ;
81- expect ( response ) . toHaveLength ( 2 ) ;
82- expect ( response [ 0 ] ) . toHaveProperty ( 'updateId' , expect . any ( Number ) )
83- const tempIds :number [ ] = [ ] ;
84- response . forEach ( ( entry ) => tempIds . push ( entry . updateId ) )
85- return tempIds
86- } )
87- for ( let updateId of updateIds ) {
88- await client . index ( indexPk . uid ) . waitForPendingUpdate ( updateId )
78+ expect ( response ) . toBeInstanceOf ( Array )
79+ expect ( response ) . toHaveLength ( 2 )
80+ expect ( response [ 0 ] ) . toHaveProperty ( 'updateId' , expect . any ( Number ) )
81+ for ( const enqueuedUpdate of response ) {
82+ const addResponse = await client
83+ . index ( indexPk . uid )
84+ . waitForPendingUpdate ( enqueuedUpdate . updateId )
85+ expect ( addResponse . status ) . toBe ( 'processed' )
86+ expect ( addResponse . type . name ) . toBe ( 'DocumentsAddition' )
8987 }
9088 } )
9189
@@ -227,30 +225,19 @@ describe.each([
227225 } )
228226
229227 test ( `${ permission } key: Update document from index that has a primary key in batch` , async ( ) => {
230- const id = 456
231- const title = 'The Little Prince'
232- const comment = 'Updated comment'
233-
234- const updateIds = await client
235- . index ( indexPk . uid )
236- . updateDocumentsInBatch ( [ { id, title } , { id, comment} ] , 1 )
237- . then ( ( response : EnqueuedUpdate [ ] ) => {
238- expect ( response ) . toHaveLength ( 2 )
239- expect ( response [ 0 ] ) . toHaveProperty ( 'updateId' , expect . any ( Number ) )
240- const tempIds :number [ ] = [ ] ;
241- response . forEach ( ( entry ) => tempIds . push ( entry . updateId ) )
242- return tempIds
243- } )
244- await client . index ( indexPk . uid ) . waitForPendingUpdate ( updateIds [ 0 ] )
245- await client . index ( indexPk . uid ) . waitForPendingUpdate ( updateIds [ 1 ] )
246- await client
228+ const response : EnqueuedUpdate [ ] = await client
247229 . index ( indexPk . uid )
248- . getDocument ( id )
249- . then ( ( response ) => {
250- expect ( response ) . toHaveProperty ( 'id' , id )
251- expect ( response ) . toHaveProperty ( 'title' , title )
252- expect ( response ) . toHaveProperty ( 'comment' , comment )
253- } )
230+ . updateDocumentsInBatch ( dataset , 2 )
231+ expect ( response ) . toBeInstanceOf ( Array )
232+ expect ( response ) . toHaveLength ( 4 )
233+ expect ( response [ 0 ] ) . toHaveProperty ( 'updateId' , expect . any ( Number ) )
234+ for ( const enqueuedUpdate of response ) {
235+ const addResponse = await client
236+ . index ( indexPk . uid )
237+ . waitForPendingUpdate ( enqueuedUpdate . updateId )
238+ expect ( addResponse . status ) . toBe ( 'processed' )
239+ expect ( addResponse . type . name ) . toBe ( 'DocumentsPartial' )
240+ }
254241 } )
255242
256243 test ( `${ permission } key: Add document with update documents function from index that has NO primary key` , async ( ) => {
0 commit comments