Skip to content

Commit 2e90f88

Browse files
Add Watch update perf test
1 parent 718953e commit 2e90f88

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

packages/firestore/test/unit/specs/perf_spec.test.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { Query } from '../../../src/core/query';
18-
import { doc, orderBy, path } from '../../util/helpers';
18+
import { doc, filter, orderBy, path } from '../../util/helpers';
1919

2020
import { describeSpec, specTest } from './describe_spec';
2121
import { spec } from './spec_builder';
@@ -238,5 +238,50 @@ describeSpec(
238238
return steps;
239239
}
240240
);
241+
242+
specTest(
243+
'Process 25 target updates and wait for snapshot',
244+
['exclusive'],
245+
() => {
246+
const queriesPerStep = 25;
247+
248+
let currentVersion = 1;
249+
let steps = spec().withGCEnabled(false);
250+
251+
for (let i = 1; i <= STEP_COUNT; ++i) {
252+
const collPath = `collection/${i}/coll`;
253+
const matchingDoc = doc(`${collPath}/${i}`, ++currentVersion, {
254+
val: -1
255+
});
256+
257+
const queries = [];
258+
259+
for (let j = 0; j < queriesPerStep; ++j) {
260+
const query = Query.atPath(path(collPath)).addFilter(
261+
filter('val', '<=', j)
262+
);
263+
queries.push(query);
264+
steps = steps.userListens(query).watchAcks(query);
265+
}
266+
267+
steps = steps
268+
.watchSends({ affects: queries }, matchingDoc)
269+
.watchSnapshots(++currentVersion);
270+
271+
for (const query of queries) {
272+
steps = steps.expectEvents(query, {
273+
added: [matchingDoc],
274+
fromCache: true
275+
});
276+
}
277+
278+
for (const query of queries) {
279+
steps = steps.userUnlistens(query).watchRemoves(query);
280+
}
281+
}
282+
283+
return steps;
284+
}
285+
);
241286
}
242287
);

0 commit comments

Comments
 (0)