|
17 | 17 |
|
18 | 18 | import { expect } from 'chai'; |
19 | 19 |
|
| 20 | +import { it } from '../../util/mocha_extensions'; |
20 | 21 | import { CompositeIndexTestHelper } from '../util/composite_index_test_helper'; |
21 | 22 | import { |
22 | 23 | where, |
@@ -196,27 +197,33 @@ apiDescribe('Composite Index Queries', persistence => { |
196 | 197 | }); |
197 | 198 | }); |
198 | 199 |
|
199 | | - it('performs aggregations on documents with all aggregated fields using getAggregationFromServer', () => { |
200 | | - const testDocs = { |
201 | | - a: { author: 'authorA', title: 'titleA', pages: 100, year: 1980 }, |
202 | | - b: { author: 'authorB', title: 'titleB', pages: 50, year: 2020 }, |
203 | | - c: { author: 'authorC', title: 'titleC', pages: 150, year: 2021 }, |
204 | | - d: { author: 'authorD', title: 'titleD', pages: 50 } |
205 | | - }; |
206 | | - const testHelper = new CompositeIndexTestHelper(); |
207 | | - return testHelper.withTestDocs(persistence, testDocs, async coll => { |
208 | | - const snapshot = await getAggregateFromServer(testHelper.query(coll), { |
209 | | - totalPages: sum('pages'), |
210 | | - averagePages: average('pages'), |
211 | | - averageYear: average('year'), |
212 | | - count: count() |
| 200 | + it.skipEmulator.skipEnterprise( |
| 201 | + 'performs aggregations on documents with all aggregated fields using getAggregationFromServer', |
| 202 | + () => { |
| 203 | + const testDocs = { |
| 204 | + a: { author: 'authorA', title: 'titleA', pages: 100, year: 1980 }, |
| 205 | + b: { author: 'authorB', title: 'titleB', pages: 50, year: 2020 }, |
| 206 | + c: { author: 'authorC', title: 'titleC', pages: 150, year: 2021 }, |
| 207 | + d: { author: 'authorD', title: 'titleD', pages: 50 } |
| 208 | + }; |
| 209 | + const testHelper = new CompositeIndexTestHelper(); |
| 210 | + return testHelper.withTestDocs(persistence, testDocs, async coll => { |
| 211 | + const snapshot = await getAggregateFromServer( |
| 212 | + testHelper.query(coll), |
| 213 | + { |
| 214 | + totalPages: sum('pages'), |
| 215 | + averagePages: average('pages'), |
| 216 | + averageYear: average('year'), |
| 217 | + count: count() |
| 218 | + } |
| 219 | + ); |
| 220 | + expect(snapshot.data().totalPages).to.equal(300); |
| 221 | + expect(snapshot.data().averagePages).to.equal(100); |
| 222 | + expect(snapshot.data().averageYear).to.equal(2007); |
| 223 | + expect(snapshot.data().count).to.equal(3); |
213 | 224 | }); |
214 | | - expect(snapshot.data().totalPages).to.equal(300); |
215 | | - expect(snapshot.data().averagePages).to.equal(100); |
216 | | - expect(snapshot.data().averageYear).to.equal(2007); |
217 | | - expect(snapshot.data().count).to.equal(3); |
218 | | - }); |
219 | | - }); |
| 225 | + } |
| 226 | + ); |
220 | 227 |
|
221 | 228 | it('performs aggregates on multiple fields where one aggregate could cause short-circuit due to NaN using getAggregationFromServer', () => { |
222 | 229 | const testDocs = { |
@@ -262,56 +269,62 @@ apiDescribe('Composite Index Queries', persistence => { |
262 | 269 | }); |
263 | 270 | }); |
264 | 271 |
|
265 | | - it('performs aggregates when using `array-contains-any` operator getAggregationFromServer', () => { |
266 | | - const testDocs = { |
267 | | - a: { |
268 | | - author: 'authorA', |
269 | | - title: 'titleA', |
270 | | - pages: 100, |
271 | | - year: 1980, |
272 | | - rating: [5, 1000] |
273 | | - }, |
274 | | - b: { |
275 | | - author: 'authorB', |
276 | | - title: 'titleB', |
277 | | - pages: 50, |
278 | | - year: 2020, |
279 | | - rating: [4] |
280 | | - }, |
281 | | - c: { |
282 | | - author: 'authorC', |
283 | | - title: 'titleC', |
284 | | - pages: 100, |
285 | | - year: 1980, |
286 | | - rating: [2222, 3] |
287 | | - }, |
288 | | - d: { |
289 | | - author: 'authorD', |
290 | | - title: 'titleD', |
291 | | - pages: 50, |
292 | | - year: 2020, |
293 | | - rating: [0] |
294 | | - } |
295 | | - }; |
296 | | - const testHelper = new CompositeIndexTestHelper(); |
297 | | - return testHelper.withTestDocs(persistence, testDocs, async coll => { |
298 | | - const snapshot = await getAggregateFromServer( |
299 | | - testHelper.query(coll, where('rating', 'array-contains-any', [5, 3])), |
300 | | - { |
301 | | - totalRating: sum('rating'), |
302 | | - averageRating: average('rating'), |
303 | | - totalPages: sum('pages'), |
304 | | - averagePages: average('pages'), |
305 | | - countOfDocs: count() |
| 272 | + it.skipEnterprise( |
| 273 | + 'performs aggregates when using `array-contains-any` operator getAggregationFromServer', |
| 274 | + () => { |
| 275 | + const testDocs = { |
| 276 | + a: { |
| 277 | + author: 'authorA', |
| 278 | + title: 'titleA', |
| 279 | + pages: 100, |
| 280 | + year: 1980, |
| 281 | + rating: [5, 1000] |
| 282 | + }, |
| 283 | + b: { |
| 284 | + author: 'authorB', |
| 285 | + title: 'titleB', |
| 286 | + pages: 50, |
| 287 | + year: 2020, |
| 288 | + rating: [4] |
| 289 | + }, |
| 290 | + c: { |
| 291 | + author: 'authorC', |
| 292 | + title: 'titleC', |
| 293 | + pages: 100, |
| 294 | + year: 1980, |
| 295 | + rating: [2222, 3] |
| 296 | + }, |
| 297 | + d: { |
| 298 | + author: 'authorD', |
| 299 | + title: 'titleD', |
| 300 | + pages: 50, |
| 301 | + year: 2020, |
| 302 | + rating: [0] |
306 | 303 | } |
307 | | - ); |
308 | | - expect(snapshot.data().totalRating).to.equal(0); |
309 | | - expect(snapshot.data().averageRating).to.be.null; |
310 | | - expect(snapshot.data().totalPages).to.equal(200); |
311 | | - expect(snapshot.data().averagePages).to.equal(100); |
312 | | - expect(snapshot.data().countOfDocs).to.equal(2); |
313 | | - }); |
314 | | - }); |
| 304 | + }; |
| 305 | + const testHelper = new CompositeIndexTestHelper(); |
| 306 | + return testHelper.withTestDocs(persistence, testDocs, async coll => { |
| 307 | + const snapshot = await getAggregateFromServer( |
| 308 | + testHelper.query( |
| 309 | + coll, |
| 310 | + where('rating', 'array-contains-any', [5, 3]) |
| 311 | + ), |
| 312 | + { |
| 313 | + totalRating: sum('rating'), |
| 314 | + averageRating: average('rating'), |
| 315 | + totalPages: sum('pages'), |
| 316 | + averagePages: average('pages'), |
| 317 | + countOfDocs: count() |
| 318 | + } |
| 319 | + ); |
| 320 | + expect(snapshot.data().totalRating).to.equal(0); |
| 321 | + expect(snapshot.data().averageRating).to.be.null; |
| 322 | + expect(snapshot.data().totalPages).to.equal(200); |
| 323 | + expect(snapshot.data().averagePages).to.equal(100); |
| 324 | + expect(snapshot.data().countOfDocs).to.equal(2); |
| 325 | + }); |
| 326 | + } |
| 327 | + ); |
315 | 328 | }); |
316 | 329 |
|
317 | 330 | describe('Multiple Inequality', () => { |
@@ -950,18 +963,24 @@ apiDescribe('Composite Index Queries', persistence => { |
950 | 963 | }); |
951 | 964 | }); |
952 | 965 |
|
953 | | - it('inequality query will reject if document key appears only in equality filter', () => { |
954 | | - const testHelper = new CompositeIndexTestHelper(); |
955 | | - return testHelper.withTestCollection(persistence, async coll => { |
956 | | - const query_ = testHelper.query( |
957 | | - coll, |
958 | | - where('key', '!=', 42), |
959 | | - where(documentId(), '==', 'doc1') |
960 | | - ); |
961 | | - await expect(testHelper.getDocs(query_)).to.be.eventually.rejectedWith( |
962 | | - 'Equality on key is not allowed if there are other inequality fields and key does not appear in inequalities.' |
963 | | - ); |
964 | | - }); |
965 | | - }); |
| 966 | + // |
| 967 | + it.skipEnterprise( |
| 968 | + 'inequality query will reject if document key appears only in equality filter', |
| 969 | + () => { |
| 970 | + const testHelper = new CompositeIndexTestHelper(); |
| 971 | + return testHelper.withTestCollection(persistence, async coll => { |
| 972 | + const query_ = testHelper.query( |
| 973 | + coll, |
| 974 | + where('key', '!=', 42), |
| 975 | + where(documentId(), '==', 'doc1') |
| 976 | + ); |
| 977 | + await expect( |
| 978 | + testHelper.getDocs(query_) |
| 979 | + ).to.be.eventually.rejectedWith( |
| 980 | + 'Equality on key is not allowed if there are other inequality fields and key does not appear in inequalities.' |
| 981 | + ); |
| 982 | + }); |
| 983 | + } |
| 984 | + ); |
966 | 985 | }); |
967 | 986 | }); |
0 commit comments