Skip to content

Commit 7a65942

Browse files
committed
More fixes
1 parent 82226fa commit 7a65942

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

packages/firestore/test/unit/local/counting_query_engine.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ import { PersistencePromise } from '../../../src/local/persistence_promise';
2424
import { PersistenceTransaction } from '../../../src/local/persistence_transaction';
2525
import { QueryEngine } from '../../../src/local/query_engine';
2626
import { RemoteDocumentCache } from '../../../src/local/remote_document_cache';
27-
import {
28-
DocumentKeySet,
29-
DocumentMap
30-
} from '../../../src/model/collections';
27+
import { DocumentKeySet, DocumentMap } from '../../../src/model/collections';
3128
import { MutationType } from '../../../src/model/mutation';
3229

3330
/**
@@ -157,8 +154,8 @@ export class CountingQueryEngine extends QueryEngine {
157154
return {
158155
getOverlay: (transaction, key) => {
159156
return subject.getOverlay(transaction, key).next(result => {
157+
this.overlaysReadByKey += 1;
160158
if (!!result) {
161-
this.overlaysReadByKey += 1;
162159
this.overlayTypes[key.toString()] = result.mutation.type;
163160
}
164161
return result;
@@ -167,7 +164,7 @@ export class CountingQueryEngine extends QueryEngine {
167164

168165
getOverlays: (transaction, keys) => {
169166
return subject.getOverlays(transaction, keys).next(result => {
170-
this.overlaysReadByKey += result.size();
167+
this.overlaysReadByKey += keys.length;
171168
result.forEach((key, overlay) => {
172169
this.overlayTypes[key.toString()] = overlay.mutation.type;
173170
});

packages/firestore/test/unit/local/local_store_indexeddb.test.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646
IndexKind,
4747
IndexOffset
4848
} from '../../../src/model/field_index';
49-
import { Mutation } from '../../../src/model/mutation';
49+
import { Mutation, MutationType } from '../../../src/model/mutation';
5050
import { MutationBatch } from '../../../src/model/mutation_batch';
5151
import { RemoteEvent } from '../../../src/remote/remote_event';
5252
import {
@@ -156,7 +156,11 @@ class AsyncLocalStoreTester {
156156
);
157157
}
158158

159-
assertOverlaysRead(byKey: number, byCollection: number): void {
159+
assertOverlaysRead(
160+
byKey: number,
161+
byCollection: number,
162+
overlayTypes: { [k: string]: MutationType }
163+
): void {
160164
expect(this.queryEngine.overlaysReadByCollection).to.equal(
161165
byCollection,
162166
'Overlays read (by collection)'
@@ -165,6 +169,10 @@ class AsyncLocalStoreTester {
165169
byKey,
166170
'Overlays read (by key)'
167171
);
172+
expect(this.queryEngine.overlayTypes).to.deep.equal(
173+
overlayTypes,
174+
'Overlay types read'
175+
);
168176
}
169177

170178
assertQueryReturned(...keys: string[]): void {
@@ -354,7 +362,10 @@ describe('LocalStore w/ IndexedDB Persistence (Non generic)', () => {
354362

355363
const queryMatches = query('coll', filter('matches', '==', true));
356364
await test.executeQuery(queryMatches);
357-
test.assertOverlaysRead(1, 1);
365+
test.assertOverlaysRead(1, 1, {
366+
[key('coll/a').toString()]: MutationType.Set,
367+
[key('coll/b').toString()]: MutationType.Set
368+
});
358369
test.assertQueryReturned('coll/a', 'coll/b');
359370
});
360371

@@ -390,7 +401,9 @@ describe('LocalStore w/ IndexedDB Persistence (Non generic)', () => {
390401
// The query engine first reads the documents by key and then re-runs the query without limit.
391402
await test.executeQuery(queryCount);
392403
test.assertRemoteDocumentsRead(5, 0);
393-
test.assertOverlaysRead(5, 1);
404+
test.assertOverlaysRead(5, 1, {
405+
[key('coll/b').toString()]: MutationType.Delete
406+
});
394407
test.assertQueryReturned('coll/a', 'coll/c');
395408
});
396409

@@ -423,7 +436,7 @@ describe('LocalStore w/ IndexedDB Persistence (Non generic)', () => {
423436

424437
await test.executeQuery(queryCount);
425438
test.assertRemoteDocumentsRead(2, 0);
426-
test.assertOverlaysRead(2, 0);
439+
test.assertOverlaysRead(2, 0, {});
427440
test.assertQueryReturned('coll/a', 'coll/c');
428441
});
429442

@@ -441,7 +454,9 @@ describe('LocalStore w/ IndexedDB Persistence (Non generic)', () => {
441454

442455
const queryTime = query('coll', orderBy('time', 'asc'));
443456
await test.executeQuery(queryTime);
444-
test.assertOverlaysRead(1, 0);
457+
test.assertOverlaysRead(1, 0, {
458+
[key('coll/a').toString()]: MutationType.Set
459+
});
445460
test.assertQueryReturned('coll/a');
446461
});
447462
});

0 commit comments

Comments
 (0)