16
16
*/
17
17
18
18
import { expect } from 'chai' ;
19
-
20
- import { RealtimePipeline } from '../../../src/api/realtime_pipeline' ;
21
19
import {
22
20
RealtimePipelineSnapshot ,
23
21
ResultChange
@@ -31,6 +29,7 @@ import {
31
29
Bytes ,
32
30
collection ,
33
31
collectionGroup ,
32
+ CollectionReference ,
34
33
deleteDoc ,
35
34
disableNetwork ,
36
35
doc ,
@@ -41,6 +40,7 @@ import {
41
40
enableNetwork ,
42
41
endAt ,
43
42
endBefore ,
43
+ Firestore ,
44
44
GeoPoint ,
45
45
getDocs as getDocsProd ,
46
46
limit ,
@@ -51,109 +51,32 @@ import {
51
51
query ,
52
52
QuerySnapshot ,
53
53
setDoc ,
54
+ setLogLevel ,
54
55
startAfter ,
55
56
startAt ,
56
57
Timestamp ,
57
58
updateDoc ,
58
59
where ,
59
60
writeBatch ,
60
- CollectionReference ,
61
- WriteBatch ,
62
- Firestore ,
63
- Query ,
64
- Unsubscribe ,
65
- setLogLevel ,
66
- getDocsFromCache
61
+ WriteBatch
67
62
} from '../util/firebase_export' ;
68
63
import {
69
64
apiDescribe ,
65
+ apiPipelineDescribe ,
66
+ checkOnlineAndOfflineResultsMatchWithPipelineMode ,
67
+ getDocs ,
68
+ onSnapshot ,
69
+ PERSISTENCE_MODE_UNSPECIFIED ,
70
70
RetryError ,
71
71
toChangesArray ,
72
72
toDataArray ,
73
- PERSISTENCE_MODE_UNSPECIFIED ,
74
73
withEmptyTestCollection ,
75
74
withRetry ,
76
75
withTestCollection ,
77
- withTestDb ,
78
- apiPipelineDescribe ,
79
- PipelineMode ,
80
- checkOnlineAndOfflineResultsMatchWithPipelineMode
76
+ withTestDb
81
77
} from '../util/helpers' ;
82
78
import { USE_EMULATOR } from '../util/settings' ;
83
79
import { captureExistenceFilterMismatches } from '../util/testing_hooks_util' ;
84
- import { pipelineFromStages } from '../../util/pipelines' ;
85
-
86
- function getDocs (
87
- pipelineMode : PipelineMode ,
88
- queryOrPipeline : Query | RealtimePipeline
89
- ) {
90
- if ( pipelineMode === 'query-to-pipeline' ) {
91
- if ( queryOrPipeline instanceof Query ) {
92
- const ppl = queryOrPipeline . firestore
93
- . pipeline ( )
94
- . createFrom ( queryOrPipeline ) ;
95
- return getDocsProd (
96
- new RealtimePipeline (
97
- ppl . _db ,
98
- ppl . userDataReader ,
99
- ppl . _userDataWriter ,
100
- ppl . stages
101
- )
102
- ) ;
103
- } else {
104
- return getDocsProd ( queryOrPipeline ) ;
105
- }
106
- }
107
-
108
- return getDocsProd ( queryOrPipeline as Query ) ;
109
- }
110
-
111
- function onSnapshot (
112
- pipelineMode : PipelineMode ,
113
- queryOrPipeline : Query | RealtimePipeline ,
114
- observer : unknown
115
- ) : Unsubscribe ;
116
- function onSnapshot (
117
- pipelineMode : PipelineMode ,
118
- queryOrPipeline : Query | RealtimePipeline ,
119
- options : unknown ,
120
- observer : unknown
121
- ) : Unsubscribe ;
122
- function onSnapshot (
123
- pipelineMode : PipelineMode ,
124
- queryOrPipeline : Query | RealtimePipeline ,
125
- optionsOrObserver : unknown ,
126
- observer ?: unknown
127
- ) : Unsubscribe {
128
- const obs = observer || optionsOrObserver ;
129
- const options = observer
130
- ? optionsOrObserver
131
- : {
132
- includeMetadataChanges : false ,
133
- source : 'default'
134
- } ;
135
- if ( pipelineMode === 'query-to-pipeline' ) {
136
- if ( queryOrPipeline instanceof Query ) {
137
- const ppl = queryOrPipeline . firestore
138
- . pipeline ( )
139
- . createFrom ( queryOrPipeline ) ;
140
- return onSnapshotProd (
141
- new RealtimePipeline (
142
- ppl . _db ,
143
- ppl . userDataReader ,
144
- ppl . _userDataWriter ,
145
- ppl . stages
146
- ) ,
147
- options as any ,
148
- obs as any
149
- ) ;
150
- } else {
151
- return onSnapshotProd ( queryOrPipeline , options as any , obs as any ) ;
152
- }
153
- }
154
-
155
- return onSnapshotProd ( queryOrPipeline as Query , options as any , obs as any ) ;
156
- }
157
80
158
81
function results ( outputs : RealtimePipelineSnapshot | QuerySnapshot ) {
159
82
if ( outputs instanceof RealtimePipelineSnapshot ) {
0 commit comments