|
15 | 15 | * limitations under the License.
|
16 | 16 | */
|
17 | 17 |
|
18 |
| -import { newQueryForPath } from '../../../src/core/query'; |
19 |
| -import { deletedDoc, doc, filter, query } from '../../util/helpers'; |
| 18 | +import { doc, query } from '../../util/helpers'; |
20 | 19 |
|
21 | 20 | import { describeSpec, specTest } from './describe_spec';
|
22 | 21 | import { spec } from './spec_builder';
|
23 | 22 |
|
24 | 23 | describeSpec('Collections:', [], () => {
|
25 |
| - specTest('8474', [], () => { |
26 |
| - // onSnapshot(fullQuery) |
27 |
| - const fullQuery = query('collection'); |
28 |
| - |
29 |
| - // getDocs(filterQuery) |
30 |
| - const filterQuery = query('collection', filter('included', '==', true)); |
31 |
| - |
32 |
| - const docA = doc('collection/a', 1000, { key: 'a', included: false }); |
33 |
| - const docA2 = doc('collection/a', 1007, { key: 'a', included: true }); |
34 |
| - const docC = doc('collection/c', 1002, { key: 'c', included: true }); |
35 |
| - |
36 |
| - const limboQueryC = newQueryForPath(docC.key.path); |
37 |
| - |
38 |
| - return ( |
39 |
| - spec() |
40 |
| - // onSnapshot(fullQuery) - fullQuery is listening to documents in the collection for the full test |
41 |
| - .userListens(fullQuery) |
42 |
| - .watchAcksFull(fullQuery, 1001, docA, docC) |
43 |
| - .expectEvents(fullQuery, { |
44 |
| - fromCache: false, |
45 |
| - added: [docA, docC] |
46 |
| - }) |
47 |
| - |
48 |
| - // docC was deleted, this puts docC in limbo and causes a snapshot from cache (metadata-only change) |
49 |
| - .watchSends({ removed: [fullQuery] }, docC) |
50 |
| - .watchCurrents(fullQuery, 'resume-token-1002') |
51 |
| - .watchSnapshots(1002) |
52 |
| - .expectLimboDocs(docC.key) |
53 |
| - .expectEvents(fullQuery, { |
54 |
| - fromCache: true |
55 |
| - }) |
56 |
| - |
57 |
| - // User begins getDocs(filterQuery) |
58 |
| - .userListensForGet(filterQuery) |
59 |
| - |
60 |
| - // getDocs(filterQuery) will not resolve on the snapshot from cache |
61 |
| - .expectEvents(filterQuery, { |
62 |
| - fromCache: true, |
63 |
| - added: [docC] |
64 |
| - }) |
65 |
| - |
66 |
| - // Watch acks limbo and filter queries |
67 |
| - .watchAcks(limboQueryC) |
68 |
| - .watchAcks(filterQuery) |
69 |
| - |
70 |
| - // Watch responds to limboQueryC - docC was deleted |
71 |
| - .watchSends({ affects: [limboQueryC] }) |
72 |
| - .watchCurrents(limboQueryC, 'resume-token-1009') |
73 |
| - .watchSnapshots(1009, [limboQueryC, fullQuery]) |
74 |
| - |
75 |
| - // However, docC is still in limbo because there has not been a global snapshot |
76 |
| - .expectLimboDocs(docC.key) |
77 |
| - |
78 |
| - // Rapid events of document update and delete caused by application |
79 |
| - .watchSends({ removed: [filterQuery] }, docA) |
80 |
| - .watchCurrents(filterQuery, 'resume-token-1004') |
81 |
| - .watchSends({ affects: [filterQuery] }, docC) |
82 |
| - .watchCurrents(filterQuery, 'resume-token-1005') |
83 |
| - .watchSends({ removed: [filterQuery] }, docC) |
84 |
| - .watchSends({ affects: [filterQuery] }, docA2) |
85 |
| - .watchCurrents(filterQuery, 'resume-token-1007') |
86 |
| - |
87 |
| - .watchSnapshots(1010, [fullQuery, limboQueryC]) |
88 |
| - |
89 |
| - // All changes are current and we get a global snapshot |
90 |
| - .watchSnapshots(1010, []) |
91 |
| - |
92 |
| - // Now docC is out of limbo |
93 |
| - .expectLimboDocs() |
94 |
| - .expectEvents(fullQuery, { |
95 |
| - fromCache: false, |
96 |
| - modified: [docA2], |
97 |
| - removed: [docC] |
98 |
| - }) |
99 |
| - // Now getDocs(filterQuery) can be resolved |
100 |
| - .expectEvents(filterQuery, { |
101 |
| - fromCache: false, |
102 |
| - removed: [docC], |
103 |
| - added: [docA2] |
104 |
| - }) |
105 |
| - ); |
106 |
| - }); |
107 |
| - specTest('8474-deleted', [], () => { |
108 |
| - // onSnapshot(fullQuery) |
109 |
| - const fullQuery = query('collection'); |
110 |
| - |
111 |
| - // getDocs(filterQuery) |
112 |
| - const filterQuery = query('collection', filter('included', '==', true)); |
113 |
| - |
114 |
| - const docA = doc('collection/a', 1000, { key: 'a', included: false }); |
115 |
| - const docA2 = doc('collection/a', 1007, { key: 'a', included: true }); |
116 |
| - const docC = doc('collection/c', 1002, { key: 'c', included: true }); |
117 |
| - const docCDeleted = deletedDoc('collection/c', 1009); |
118 |
| - |
119 |
| - const limboQueryC = newQueryForPath(docC.key.path); |
120 |
| - |
121 |
| - return ( |
122 |
| - spec() |
123 |
| - // onSnapshot(fullQuery) - fullQuery is listening to documents in the collection for the full test |
124 |
| - .userListens(fullQuery) |
125 |
| - .watchAcksFull(fullQuery, 1001, docA, docC) |
126 |
| - .expectEvents(fullQuery, { |
127 |
| - fromCache: false, |
128 |
| - added: [docA, docC] |
129 |
| - }) |
130 |
| - |
131 |
| - // docC was deleted, this puts docC in limbo and causes a snapshot from cache (metadata-only change) |
132 |
| - .watchSends({ removed: [fullQuery] }, docC) |
133 |
| - .watchCurrents(fullQuery, 'resume-token-1002') |
134 |
| - .watchSnapshots(1002) |
135 |
| - .expectLimboDocs(docC.key) |
136 |
| - .expectEvents(fullQuery, { |
137 |
| - fromCache: true |
138 |
| - }) |
139 |
| - |
140 |
| - // User begins getDocs(filterQuery) |
141 |
| - .userListensForGet(filterQuery) |
142 |
| - |
143 |
| - // getDocs(filterQuery) will not resolve on the snapshot from cache |
144 |
| - .expectEvents(filterQuery, { |
145 |
| - fromCache: true, |
146 |
| - added: [docC] |
147 |
| - }) |
148 |
| - |
149 |
| - // Watch acks limbo and filter queries |
150 |
| - .watchAcks(limboQueryC) |
151 |
| - .watchAcks(filterQuery) |
152 |
| - |
153 |
| - // Watch responds to limboQueryC - docC was deleted |
154 |
| - .watchSends({ affects: [limboQueryC] }, docCDeleted) |
155 |
| - .watchCurrents(limboQueryC, 'resume-token-1009') |
156 |
| - .watchSnapshots(1009, [limboQueryC, fullQuery]) |
157 |
| - |
158 |
| - // However, docC is still in limbo because there has not been a global snapshot |
159 |
| - .expectLimboDocs(docC.key) |
160 |
| - |
161 |
| - // Rapid events of document update and delete caused by application |
162 |
| - .watchSends({ removed: [filterQuery] }, docA) |
163 |
| - .watchCurrents(filterQuery, 'resume-token-1004') |
164 |
| - .watchSends({ affects: [filterQuery] }, docC) |
165 |
| - .watchCurrents(filterQuery, 'resume-token-1005') |
166 |
| - .watchSends({ removed: [filterQuery] }, docC) |
167 |
| - .watchSends({ affects: [filterQuery] }, docA2) |
168 |
| - .watchCurrents(filterQuery, 'resume-token-1007') |
169 |
| - |
170 |
| - .watchSnapshots(1010, [fullQuery, limboQueryC]) |
171 |
| - |
172 |
| - // All changes are current and we get a global snapshot |
173 |
| - .watchSnapshots(1010, []) |
174 |
| - |
175 |
| - // Now docC is out of limbo |
176 |
| - .expectLimboDocs() |
177 |
| - .expectEvents(fullQuery, { |
178 |
| - fromCache: false, |
179 |
| - modified: [docA2], |
180 |
| - removed: [docC] |
181 |
| - }) |
182 |
| - // Now getDocs(filterQuery) can be resolved |
183 |
| - .expectEvents(filterQuery, { |
184 |
| - fromCache: false, |
185 |
| - removed: [docC], |
186 |
| - added: [docA2] |
187 |
| - }) |
188 |
| - |
189 |
| - // No more expected events |
190 |
| - .watchSnapshots(1100, []) |
191 |
| - ); |
192 |
| - }); |
193 |
| - |
194 | 24 | specTest('Events are raised after watch ack', [], () => {
|
195 | 25 | const query1 = query('collection');
|
196 | 26 | const doc1 = doc('collection/key', 1000, { foo: 'bar' });
|
|
0 commit comments