|
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 { newQueryForPath } from '../../../src/core/query'; |
| 19 | +import { deletedDoc, doc, filter, query } from '../../util/helpers'; |
20 | 20 |
|
21 | 21 | import { describeSpec, specTest } from './describe_spec';
|
22 | 22 | import { spec } from './spec_builder';
|
23 | 23 |
|
24 | 24 | describeSpec('Collections:', [], () => {
|
25 |
| - |
26 | 25 | specTest('8474', [], () => {
|
27 |
| - |
28 | 26 | // onSnapshot(fullQuery)
|
29 | 27 | const fullQuery = query('collection');
|
30 | 28 |
|
31 | 29 | // getDocs(filterQuery)
|
32 | 30 | const filterQuery = query('collection', filter('included', '==', true));
|
33 | 31 |
|
34 |
| - const docA = doc('collection/a', 1000, {key: 'a', included: false}); |
35 |
| - const docA2 = doc('collection/a', 1007, {key: 'a', included: true}); |
36 |
| - const docC = doc('collection/c', 1002, {key: 'c', included: true}); |
| 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 }); |
37 | 35 |
|
38 | 36 | const limboQueryC = newQueryForPath(docC.key.path);
|
39 | 37 |
|
40 |
| - return spec() |
41 |
| - // onSnapshot(fullQuery) - fullQuery is listening to documents in the collection for the full test |
42 |
| - .userListens(fullQuery) |
43 |
| - .watchAcksFull(fullQuery, 1001, docA, docC) |
44 |
| - .expectEvents(fullQuery, { |
45 |
| - fromCache: false, |
46 |
| - added: [docA, docC] |
47 |
| - }) |
48 |
| - |
49 |
| - // docC was deleted, this puts docC in limbo and causes a snapshot from cache (metadata-only change) |
50 |
| - .watchSends({removed: [fullQuery]}, docC) |
51 |
| - .watchCurrents(fullQuery, 'resume-token-1002') |
52 |
| - .watchSnapshots(1002) |
53 |
| - .expectLimboDocs(docC.key) |
54 |
| - .expectEvents(fullQuery, { |
55 |
| - fromCache: true, |
56 |
| - }) |
57 |
| - |
58 |
| - // User begins getDocs(filterQuery) |
59 |
| - .userListensForGet(filterQuery) |
60 |
| - |
61 |
| - // getDocs(filterQuery) will not resolve on the snapshot from cache |
62 |
| - .expectEvents(filterQuery, { |
63 |
| - fromCache: true, |
64 |
| - added: [docC] |
65 |
| - }) |
66 |
| - |
67 |
| - // Watch acks limbo and filter queries |
68 |
| - .watchAcks(limboQueryC) |
69 |
| - .watchAcks(filterQuery) |
70 |
| - |
71 |
| - // Watch responds to limboQueryC - docC was deleted |
72 |
| - .watchSends({affects: [limboQueryC]}) |
73 |
| - .watchCurrents(limboQueryC, 'resume-token-1009') |
74 |
| - .watchSnapshots(1009, [limboQueryC, fullQuery]) |
75 |
| - |
76 |
| - // However, docC is still in limbo because there has not been a global snapshot |
77 |
| - .expectLimboDocs(docC.key) |
78 |
| - |
79 |
| - // Rapid events of document update and delete caused by application |
80 |
| - .watchSends({removed: [filterQuery]}, docA) |
81 |
| - .watchCurrents(filterQuery, 'resume-token-1004') |
82 |
| - .watchSends({affects: [filterQuery]}, docC) |
83 |
| - .watchCurrents(filterQuery, 'resume-token-1005') |
84 |
| - .watchSends({removed: [filterQuery]}, docC) |
85 |
| - .watchSends({affects: [filterQuery]}, docA2) |
86 |
| - .watchCurrents(filterQuery, 'resume-token-1007') |
87 |
| - |
88 |
| - .watchSnapshots(1010, [fullQuery, limboQueryC]) |
89 |
| - |
90 |
| - // All changes are current and we get a global snapshot |
91 |
| - .watchSnapshots(1010, []) |
92 |
| - |
93 |
| - // Now docC is out of limbo |
94 |
| - .expectLimboDocs() |
95 |
| - .expectEvents(fullQuery, { |
96 |
| - fromCache: false, |
97 |
| - modified: [docA2], |
98 |
| - removed: [docC] |
99 |
| - }) |
100 |
| - // Now getDocs(filterQuery) can be resolved |
101 |
| - .expectEvents(filterQuery, { |
102 |
| - fromCache: false, |
103 |
| - removed: [docC], |
104 |
| - added: [docA2] |
105 |
| - }); |
| 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 | 106 | });
|
107 | 107 | specTest('8474-deleted', [], () => {
|
108 |
| - |
109 | 108 | // onSnapshot(fullQuery)
|
110 | 109 | const fullQuery = query('collection');
|
111 | 110 |
|
112 | 111 | // getDocs(filterQuery)
|
113 | 112 | const filterQuery = query('collection', filter('included', '==', true));
|
114 | 113 |
|
115 |
| - const docA = doc('collection/a', 1000, {key: 'a', included: false}); |
116 |
| - const docA2 = doc('collection/a', 1007, {key: 'a', included: true}); |
117 |
| - const docC = doc('collection/c', 1002, {key: 'c', included: true}); |
| 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 }); |
118 | 117 | const docCDeleted = deletedDoc('collection/c', 1009);
|
119 | 118 |
|
120 | 119 | const limboQueryC = newQueryForPath(docC.key.path);
|
121 | 120 |
|
122 |
| - return 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, []); |
| 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 | + ); |
191 | 192 | });
|
192 | 193 |
|
193 | 194 | specTest('Events are raised after watch ack', [], () => {
|
|
0 commit comments