@@ -45,71 +45,9 @@ function verifyInProgress(
45
45
expect ( p . documentsLoaded ) . to . equal ( expectedDocuments ) ;
46
46
}
47
47
48
- /**
49
- * Returns a testing bundle string for the given projectId.
50
- *
51
- * The function is commented out, but kept for documentation purpose. It accesses SDK
52
- * internals, which is not available in test:minified.
53
- *
54
- * The tests uses `BUNDLE_TEMPLATE` as test data instead, which is generated from this function
55
- * and replaced with different project IDs when required. To update `BUNDLE_TEMPALTE`, you
56
- * need to uncomment the function, and copy/paste from the console output to `BUNDLE_TEMPALTE`.
57
- * It is manual, but should be required only rarely.
58
- */
59
- /*
60
- function bundleWithTestDocsAndQueries(projectId: string): string {
61
- const testDocs: { [key: string]: firestore.DocumentData } = {
62
- a: { k: { stringValue: 'a' }, bar: { integerValue: 1 } },
63
- b: { k: { stringValue: 'b' }, bar: { integerValue: 2 } }
64
- };
65
-
66
- const a = key('coll-1/a');
67
- const b = key('coll-1/b');
68
- const builder = new TestBundleBuilder(new DatabaseId(projectId));
69
-
70
- builder.addNamedQuery(
71
- 'limit',
72
- { seconds: 1000, nanos: 9999 },
73
- (collectionReference('coll-1')
74
- .orderBy('bar', 'desc')
75
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
- .limit(1) as any)._query
77
- );
78
- builder.addNamedQuery(
79
- 'limit-to-last',
80
- { seconds: 1000, nanos: 9999 },
81
- (collectionReference('coll-1')
82
- .orderBy('bar', 'desc')
83
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
- .limitToLast(1) as any)._query
85
- );
86
-
87
- builder.addDocumentMetadata(a, { seconds: 1000, nanos: 9999 }, true);
88
- builder.addDocument(
89
- a,
90
- { seconds: 1, nanos: 9 },
91
- { seconds: 1, nanos: 9 },
92
- testDocs.a
93
- );
94
- builder.addDocumentMetadata(b, { seconds: 1000, nanos: 9999 }, true);
95
- builder.addDocument(
96
- b,
97
- { seconds: 1, nanos: 9 },
98
- { seconds: 1, nanos: 9 },
99
- testDocs.b
100
- );
101
-
102
- return builder
103
- .build('test-bundle', { seconds: 1001, nanos: 9999 })
104
- .toString();
105
- }
106
-
107
- console.log(
108
- `${bundleWithTestDocsAndQueries('test-project')}`
109
- );
110
- */
111
-
112
48
const TEMPLATE_PROJECT_ID = 'test-project' ;
49
+ // This template is generated from bundleWithTestDocsAndQueries in '../util/internal_helpsers.ts',
50
+ // and manually copied here.
113
51
const BUNDLE_TEMPLATE =
114
52
'125{"metadata":{"id":"test-bundle","createTime":{"seconds":1001,"nanos":9999},"version":1,"totalDocuments":2,"totalBytes":1503}}374{"namedQuery":{"name":"limit","readTime":{"seconds":1000,"nanos":9999},"bundledQuery":{"parent":"projects/test-project/databases/(default)/documents","structuredQuery":{"from":[{"collectionId":"coll-1"}],"orderBy":[{"field":{"fieldPath":"bar"},"direction":"DESCENDING"},{"field":{"fieldPath":"__name__"},"direction":"DESCENDING"}],"limit":{"value":1}},"limitType":"FIRST"}}}381{"namedQuery":{"name":"limit-to-last","readTime":{"seconds":1000,"nanos":9999},"bundledQuery":{"parent":"projects/test-project/databases/(default)/documents","structuredQuery":{"from":[{"collectionId":"coll-1"}],"orderBy":[{"field":{"fieldPath":"bar"},"direction":"DESCENDING"},{"field":{"fieldPath":"__name__"},"direction":"DESCENDING"}],"limit":{"value":1}},"limitType":"LAST"}}}147{"documentMetadata":{"name":"projects/test-project/databases/(default)/documents/coll-1/a","readTime":{"seconds":1000,"nanos":9999},"exists":true}}218{"document":{"name":"projects/test-project/databases/(default)/documents/coll-1/a","createTime":{"seconds":1,"nanos":9},"updateTime":{"seconds":1,"nanos":9},"fields":{"k":{"stringValue":"a"},"bar":{"integerValue":1}}}}147{"documentMetadata":{"name":"projects/test-project/databases/(default)/documents/coll-1/b","readTime":{"seconds":1000,"nanos":9999},"exists":true}}218{"document":{"name":"projects/test-project/databases/(default)/documents/coll-1/b","createTime":{"seconds":1,"nanos":9},"updateTime":{"seconds":1,"nanos":9},"fields":{"k":{"stringValue":"b"},"bar":{"integerValue":2}}}}' ;
115
53
0 commit comments