|
15 | 15 | */
|
16 | 16 |
|
17 | 17 | import { Query } from '../../../src/core/query';
|
18 |
| -import { doc, orderBy, path } from '../../util/helpers'; |
| 18 | +import { doc, filter, orderBy, path } from '../../util/helpers'; |
19 | 19 |
|
20 | 20 | import { describeSpec, specTest } from './describe_spec';
|
21 | 21 | import { spec } from './spec_builder';
|
@@ -238,5 +238,52 @@ describeSpec(
|
238 | 238 | return steps;
|
239 | 239 | }
|
240 | 240 | );
|
| 241 | + |
| 242 | + specTest('Process 25 target updates and wait for snapshot', [], () => { |
| 243 | + const queriesPerStep = 25; |
| 244 | + |
| 245 | + let currentVersion = 1; |
| 246 | + let steps = spec().withGCEnabled(false); |
| 247 | + |
| 248 | + for (let i = 1; i <= STEP_COUNT; ++i) { |
| 249 | + // We use a different subcollection for each iteration to ensure |
| 250 | + // that we use distinct and non-overlapping collection queries. |
| 251 | + const collPath = `collection/${i}/coll`; |
| 252 | + const matchingDoc = doc(`${collPath}/matches`, ++currentVersion, { |
| 253 | + val: -1 |
| 254 | + }); |
| 255 | + |
| 256 | + const queries = []; |
| 257 | + |
| 258 | + // Create `queriesPerStep` listens, each against collPath but with a |
| 259 | + // unique query constraint. |
| 260 | + for (let j = 0; j < queriesPerStep; ++j) { |
| 261 | + const query = Query.atPath(path(collPath)).addFilter( |
| 262 | + filter('val', '<=', j) |
| 263 | + ); |
| 264 | + queries.push(query); |
| 265 | + steps = steps.userListens(query).watchAcks(query); |
| 266 | + } |
| 267 | + |
| 268 | + steps = steps |
| 269 | + .watchSends({ affects: queries }, matchingDoc) |
| 270 | + .watchSnapshots(++currentVersion); |
| 271 | + |
| 272 | + // Registers the snapshot expectations with the spec runner. |
| 273 | + for (const query of queries) { |
| 274 | + steps = steps.expectEvents(query, { |
| 275 | + added: [matchingDoc], |
| 276 | + fromCache: true |
| 277 | + }); |
| 278 | + } |
| 279 | + |
| 280 | + // Unlisten and clean up the query. |
| 281 | + for (const query of queries) { |
| 282 | + steps = steps.userUnlistens(query).watchRemoves(query); |
| 283 | + } |
| 284 | + } |
| 285 | + |
| 286 | + return steps; |
| 287 | + }); |
241 | 288 | }
|
242 | 289 | );
|
0 commit comments