@@ -94,32 +94,18 @@ describe.each([{ permission: 'Master' }, { permission: 'Private' }])(
94
94
95
95
const tasks = await client . getTasks ( )
96
96
97
- expect ( tasks . results [ 0 ] ) . toHaveProperty (
98
- 'status' ,
99
- TaskStatus . TASK_SUCCEEDED
100
- )
101
- expect ( tasks . results [ 0 ] . indexUid ) . toEqual ( index . uid )
102
- expect ( tasks . results [ 0 ] . status ) . toEqual ( TaskStatus . TASK_SUCCEEDED )
103
- expect ( tasks . results [ 0 ] . type ) . toEqual (
104
- TaskTypes . DOCUMENTS_ADDITION_OR_UPDATE
105
- )
106
- expect ( tasks . results [ 0 ] . enqueuedAt ) . toBeDefined ( )
107
- expect ( tasks . results [ 0 ] . uid ) . toBeDefined ( )
108
- expect ( tasks . results [ 0 ] . type ) . toEqual (
109
- TaskTypes . DOCUMENTS_ADDITION_OR_UPDATE
110
- )
111
- expect ( tasks . results [ 0 ] . duration ) . toBeDefined ( )
112
- expect ( tasks . results [ 0 ] . finishedAt ) . toBeDefined ( )
113
- expect ( tasks . results [ 0 ] . startedAt ) . toBeDefined ( )
97
+ expect ( tasks . results ) . toBeInstanceOf ( Array )
98
+ expect ( tasks . results [ 0 ] . uid ) . toEqual ( enqueuedTask . taskUid )
114
99
} )
115
100
116
101
test ( `${ permission } key: Get all tasks with type filter` , async ( ) => {
117
102
const client = await getClient ( permission )
118
103
const task1 = await client . index ( index . uid ) . addDocuments ( [ { id : 1 } ] )
119
- await client . waitForTask ( task1 . taskUid )
120
-
121
104
const task2 = await client . index ( index . uid ) . deleteDocument ( 1 )
105
+ const task3 = await client . createIndex ( index2 . uid )
106
+ await client . waitForTask ( task1 . taskUid )
122
107
await client . waitForTask ( task2 . taskUid )
108
+ await client . waitForTask ( task3 . taskUid )
123
109
124
110
const tasks = await client . getTasks ( {
125
111
type : [
@@ -144,19 +130,17 @@ describe.each([{ permission: 'Master' }, { permission: 'Private' }])(
144
130
const tasks = await client . getTasks ( {
145
131
status : [ TaskStatus . TASK_SUCCEEDED , TaskStatus . TASK_FAILED ] ,
146
132
} )
147
- const onlySuccesFullTasks = new Set (
133
+ const onlySuccesfullTasks = new Set (
148
134
tasks . results . map ( ( task ) => task . status )
149
135
)
150
136
151
- expect ( onlySuccesFullTasks . size ) . toEqual ( 2 )
137
+ expect ( onlySuccesfullTasks . size ) . toEqual ( 2 )
152
138
} )
153
139
154
140
test ( `${ permission } key: Get all tasks with indexUid filter` , async ( ) => {
155
141
const client = await getClient ( permission )
156
- const task1 = await client . index ( index . uid ) . addDocuments ( [ { id : 1 } ] )
157
- const task2 = await client . index ( index2 . uid ) . addDocuments ( [ { id : 1 } ] )
158
- await client . waitForTask ( task1 . taskUid )
159
- await client . waitForTask ( task2 . taskUid )
142
+ await client . index ( index . uid ) . addDocuments ( [ { id : 1 } ] )
143
+ await client . index ( index2 . uid ) . addDocuments ( [ { id : 1 } ] )
160
144
161
145
const tasks = await client . getTasks ( {
162
146
indexUid : [ index . uid , index2 . uid ] ,
@@ -170,30 +154,15 @@ describe.each([{ permission: 'Master' }, { permission: 'Private' }])(
170
154
171
155
test ( `${ permission } key: Get all indexes tasks with index instance` , async ( ) => {
172
156
const client = await getClient ( permission )
173
- const enqueuedTask = await client
174
- . index ( index . uid )
175
- . addDocuments ( [ { id : 1 } ] )
176
- await client . waitForTask ( enqueuedTask . taskUid )
157
+ await client . index ( index . uid ) . addDocuments ( [ { id : 1 } ] )
158
+ await client . index ( index2 . uid ) . addDocuments ( [ { id : 1 } ] )
177
159
178
160
const tasks = await client . index ( index . uid ) . getTasks ( )
179
-
180
- expect ( tasks . results [ 0 ] ) . toHaveProperty (
181
- 'status' ,
182
- TaskStatus . TASK_SUCCEEDED
183
- )
184
- expect ( tasks . results [ 0 ] . indexUid ) . toEqual ( index . uid )
185
- expect ( tasks . results [ 0 ] . status ) . toEqual ( TaskStatus . TASK_SUCCEEDED )
186
- expect ( tasks . results [ 0 ] . type ) . toEqual (
187
- TaskTypes . DOCUMENTS_ADDITION_OR_UPDATE
188
- )
189
- expect ( tasks . results [ 0 ] . enqueuedAt ) . toBeDefined ( )
190
- expect ( tasks . results [ 0 ] . uid ) . toBeDefined ( )
191
- expect ( tasks . results [ 0 ] . type ) . toEqual (
192
- TaskTypes . DOCUMENTS_ADDITION_OR_UPDATE
161
+ const onlyTaskWithSameUid = new Set (
162
+ tasks . results . map ( ( task ) => task . indexUid )
193
163
)
194
- expect ( tasks . results [ 0 ] . duration ) . toBeDefined ( )
195
- expect ( tasks . results [ 0 ] . finishedAt ) . toBeDefined ( )
196
- expect ( tasks . results [ 0 ] . startedAt ) . toBeDefined ( )
164
+
165
+ expect ( onlyTaskWithSameUid . size ) . toEqual ( 2 )
197
166
} )
198
167
199
168
test ( `${ permission } key: Try to get a task that does not exist` , async ( ) => {
0 commit comments