@@ -92,51 +92,6 @@ void main() {
92
92
});
93
93
});
94
94
95
- testWidgets ('pagination' , (WidgetTester tester) async {
96
- // Check that `lastProcessedId` returned from an initial
97
- // response is used as `anchorId` for the subsequent request.
98
- final narrow = TopicNarrow .ofMessage (eg.streamMessage ());
99
- await prepare (tester);
100
-
101
- connection.prepare (json: UpdateMessageFlagsForNarrowResult (
102
- processedCount: 1000 , updatedCount: 890 ,
103
- firstProcessedId: 1 , lastProcessedId: 1989 ,
104
- foundOldest: true , foundNewest: false ).toJson ());
105
- markNarrowAsRead (context, narrow);
106
- final apiNarrow = narrow.apiEncode ()..add (ApiNarrowIsUnread ());
107
- check (connection.lastRequest).isA< http.Request > ()
108
- ..method.equals ('POST' )
109
- ..url.path.equals ('/api/v1/messages/flags/narrow' )
110
- ..bodyFields.deepEquals ({
111
- 'anchor' : 'oldest' ,
112
- 'include_anchor' : 'false' ,
113
- 'num_before' : '0' ,
114
- 'num_after' : '1000' ,
115
- 'narrow' : jsonEncode (apiNarrow),
116
- 'op' : 'add' ,
117
- 'flag' : 'read' ,
118
- });
119
-
120
- connection.prepare (json: UpdateMessageFlagsForNarrowResult (
121
- processedCount: 20 , updatedCount: 10 ,
122
- firstProcessedId: 2000 , lastProcessedId: 2023 ,
123
- foundOldest: false , foundNewest: true ).toJson ());
124
- await tester.pumpAndSettle ();
125
- check (find.bySubtype <SnackBar >().evaluate ()).length.equals (1 );
126
- check (connection.lastRequest).isA< http.Request > ()
127
- ..method.equals ('POST' )
128
- ..url.path.equals ('/api/v1/messages/flags/narrow' )
129
- ..bodyFields.deepEquals ({
130
- 'anchor' : '1989' ,
131
- 'include_anchor' : 'false' ,
132
- 'num_before' : '0' ,
133
- 'num_after' : '1000' ,
134
- 'narrow' : jsonEncode (apiNarrow),
135
- 'op' : 'add' ,
136
- 'flag' : 'read' ,
137
- });
138
- });
139
-
140
95
testWidgets ('on mark-all-as-read when Unreads.oldUnreadsMissing: true' , (tester) async {
141
96
const narrow = CombinedFeedNarrow ();
142
97
await prepare (tester);
@@ -152,36 +107,6 @@ void main() {
152
107
check (store.unreads.oldUnreadsMissing).isFalse ();
153
108
});
154
109
155
- testWidgets ('on invalid response' , (WidgetTester tester) async {
156
- final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
157
- final narrow = TopicNarrow .ofMessage (eg.streamMessage ());
158
- await prepare (tester);
159
- connection.prepare (json: UpdateMessageFlagsForNarrowResult (
160
- processedCount: 1000 , updatedCount: 0 ,
161
- firstProcessedId: null , lastProcessedId: null ,
162
- foundOldest: true , foundNewest: false ).toJson ());
163
- markNarrowAsRead (context, narrow);
164
- await tester.pump (Duration .zero);
165
- final apiNarrow = narrow.apiEncode ()..add (ApiNarrowIsUnread ());
166
- check (connection.lastRequest).isA< http.Request > ()
167
- ..method.equals ('POST' )
168
- ..url.path.equals ('/api/v1/messages/flags/narrow' )
169
- ..bodyFields.deepEquals ({
170
- 'anchor' : 'oldest' ,
171
- 'include_anchor' : 'false' ,
172
- 'num_before' : '0' ,
173
- 'num_after' : '1000' ,
174
- 'narrow' : jsonEncode (apiNarrow),
175
- 'op' : 'add' ,
176
- 'flag' : 'read' ,
177
- });
178
-
179
- await tester.pumpAndSettle ();
180
- checkErrorDialog (tester,
181
- expectedTitle: zulipLocalizations.errorMarkAsReadFailedTitle,
182
- expectedMessage: zulipLocalizations.errorInvalidResponse);
183
- });
184
-
185
110
testWidgets ('CombinedFeedNarrow on legacy server' , (WidgetTester tester) async {
186
111
const narrow = CombinedFeedNarrow ();
187
112
await prepare (tester);
@@ -276,19 +201,6 @@ void main() {
276
201
'flag' : 'read' ,
277
202
});
278
203
});
279
-
280
- testWidgets ('catch-all api errors' , (WidgetTester tester) async {
281
- final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
282
- const narrow = CombinedFeedNarrow ();
283
- await prepare (tester);
284
- connection.prepare (exception: http.ClientException ('Oops' ));
285
- markNarrowAsRead (context, narrow);
286
- await tester.pump (Duration .zero);
287
- await tester.pumpAndSettle ();
288
- checkErrorDialog (tester,
289
- expectedTitle: zulipLocalizations.errorMarkAsReadFailedTitle,
290
- expectedMessage: 'NetworkException: Oops (ClientException: Oops)' );
291
- });
292
204
});
293
205
294
206
group ('updateMessageFlagsStartingFromAnchor' , () {
@@ -332,5 +244,90 @@ void main() {
332
244
});
333
245
check (await didPass).isTrue ();
334
246
});
247
+
248
+ testWidgets ('pagination' , (WidgetTester tester) async {
249
+ // Check that `lastProcessedId` returned from an initial
250
+ // response is used as `anchorId` for the subsequent request.
251
+ await prepare (tester);
252
+
253
+ connection.prepare (json: UpdateMessageFlagsForNarrowResult (
254
+ processedCount: 1000 , updatedCount: 890 ,
255
+ firstProcessedId: 1 , lastProcessedId: 1989 ,
256
+ foundOldest: true , foundNewest: false ).toJson ());
257
+ final didPass = invokeUpdateMessageFlagsStartingFromAnchor ();
258
+ check (connection.lastRequest).isA< http.Request > ()
259
+ ..method.equals ('POST' )
260
+ ..url.path.equals ('/api/v1/messages/flags/narrow' )
261
+ ..bodyFields.deepEquals ({
262
+ 'anchor' : 'oldest' ,
263
+ 'include_anchor' : 'false' ,
264
+ 'num_before' : '0' ,
265
+ 'num_after' : '1000' ,
266
+ 'narrow' : jsonEncode (apiNarrow),
267
+ 'op' : 'add' ,
268
+ 'flag' : 'read' ,
269
+ });
270
+
271
+ connection.prepare (json: UpdateMessageFlagsForNarrowResult (
272
+ processedCount: 20 , updatedCount: 10 ,
273
+ firstProcessedId: 2000 , lastProcessedId: 2023 ,
274
+ foundOldest: false , foundNewest: true ).toJson ());
275
+ await tester.pumpAndSettle ();
276
+ check (find.bySubtype <SnackBar >().evaluate ()).length.equals (1 );
277
+ check (connection.lastRequest).isA< http.Request > ()
278
+ ..method.equals ('POST' )
279
+ ..url.path.equals ('/api/v1/messages/flags/narrow' )
280
+ ..bodyFields.deepEquals ({
281
+ 'anchor' : '1989' ,
282
+ 'include_anchor' : 'false' ,
283
+ 'num_before' : '0' ,
284
+ 'num_after' : '1000' ,
285
+ 'narrow' : jsonEncode (apiNarrow),
286
+ 'op' : 'add' ,
287
+ 'flag' : 'read' ,
288
+ });
289
+ check (await didPass).isTrue ();
290
+ });
291
+
292
+ testWidgets ('on invalid response' , (WidgetTester tester) async {
293
+ final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
294
+ await prepare (tester);
295
+ connection.prepare (json: UpdateMessageFlagsForNarrowResult (
296
+ processedCount: 1000 , updatedCount: 0 ,
297
+ firstProcessedId: null , lastProcessedId: null ,
298
+ foundOldest: true , foundNewest: false ).toJson ());
299
+ final didPass = invokeUpdateMessageFlagsStartingFromAnchor ();
300
+ await tester.pump (Duration .zero);
301
+ check (connection.lastRequest).isA< http.Request > ()
302
+ ..method.equals ('POST' )
303
+ ..url.path.equals ('/api/v1/messages/flags/narrow' )
304
+ ..bodyFields.deepEquals ({
305
+ 'anchor' : 'oldest' ,
306
+ 'include_anchor' : 'false' ,
307
+ 'num_before' : '0' ,
308
+ 'num_after' : '1000' ,
309
+ 'narrow' : jsonEncode (apiNarrow),
310
+ 'op' : 'add' ,
311
+ 'flag' : 'read' ,
312
+ });
313
+
314
+ await tester.pumpAndSettle ();
315
+ checkErrorDialog (tester,
316
+ expectedTitle: onFailedTitle,
317
+ expectedMessage: zulipLocalizations.errorInvalidResponse);
318
+ check (await didPass).isFalse ();
319
+ });
320
+
321
+ testWidgets ('catch-all api errors' , (WidgetTester tester) async {
322
+ await prepare (tester);
323
+ connection.prepare (exception: http.ClientException ('Oops' ));
324
+ final didPass = invokeUpdateMessageFlagsStartingFromAnchor ();
325
+ await tester.pump (Duration .zero);
326
+ await tester.pumpAndSettle ();
327
+ checkErrorDialog (tester,
328
+ expectedTitle: onFailedTitle,
329
+ expectedMessage: 'NetworkException: Oops (ClientException: Oops)' );
330
+ check (await didPass).isFalse ();
331
+ });
335
332
});
336
333
}
0 commit comments