@@ -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,93 @@ 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
+ final narrow = TopicNarrow .ofMessage (eg.streamMessage ());
252
+ await prepare (tester);
253
+
254
+ connection.prepare (json: UpdateMessageFlagsForNarrowResult (
255
+ processedCount: 1000 , updatedCount: 890 ,
256
+ firstProcessedId: 1 , lastProcessedId: 1989 ,
257
+ foundOldest: true , foundNewest: false ).toJson ());
258
+ markNarrowAsRead (context, narrow);
259
+ final apiNarrow = narrow.apiEncode ()..add (ApiNarrowIsUnread ());
260
+ check (connection.lastRequest).isA< http.Request > ()
261
+ ..method.equals ('POST' )
262
+ ..url.path.equals ('/api/v1/messages/flags/narrow' )
263
+ ..bodyFields.deepEquals ({
264
+ 'anchor' : 'oldest' ,
265
+ 'include_anchor' : 'false' ,
266
+ 'num_before' : '0' ,
267
+ 'num_after' : '1000' ,
268
+ 'narrow' : jsonEncode (apiNarrow),
269
+ 'op' : 'add' ,
270
+ 'flag' : 'read' ,
271
+ });
272
+
273
+ connection.prepare (json: UpdateMessageFlagsForNarrowResult (
274
+ processedCount: 20 , updatedCount: 10 ,
275
+ firstProcessedId: 2000 , lastProcessedId: 2023 ,
276
+ foundOldest: false , foundNewest: true ).toJson ());
277
+ await tester.pumpAndSettle ();
278
+ check (find.bySubtype <SnackBar >().evaluate ()).length.equals (1 );
279
+ check (connection.lastRequest).isA< http.Request > ()
280
+ ..method.equals ('POST' )
281
+ ..url.path.equals ('/api/v1/messages/flags/narrow' )
282
+ ..bodyFields.deepEquals ({
283
+ 'anchor' : '1989' ,
284
+ 'include_anchor' : 'false' ,
285
+ 'num_before' : '0' ,
286
+ 'num_after' : '1000' ,
287
+ 'narrow' : jsonEncode (apiNarrow),
288
+ 'op' : 'add' ,
289
+ 'flag' : 'read' ,
290
+ });
291
+ });
292
+
293
+ testWidgets ('on invalid response' , (WidgetTester tester) async {
294
+ final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
295
+ final narrow = TopicNarrow .ofMessage (eg.streamMessage ());
296
+ await prepare (tester);
297
+ connection.prepare (json: UpdateMessageFlagsForNarrowResult (
298
+ processedCount: 1000 , updatedCount: 0 ,
299
+ firstProcessedId: null , lastProcessedId: null ,
300
+ foundOldest: true , foundNewest: false ).toJson ());
301
+ markNarrowAsRead (context, narrow);
302
+ await tester.pump (Duration .zero);
303
+ final apiNarrow = narrow.apiEncode ()..add (ApiNarrowIsUnread ());
304
+ check (connection.lastRequest).isA< http.Request > ()
305
+ ..method.equals ('POST' )
306
+ ..url.path.equals ('/api/v1/messages/flags/narrow' )
307
+ ..bodyFields.deepEquals ({
308
+ 'anchor' : 'oldest' ,
309
+ 'include_anchor' : 'false' ,
310
+ 'num_before' : '0' ,
311
+ 'num_after' : '1000' ,
312
+ 'narrow' : jsonEncode (apiNarrow),
313
+ 'op' : 'add' ,
314
+ 'flag' : 'read' ,
315
+ });
316
+
317
+ await tester.pumpAndSettle ();
318
+ checkErrorDialog (tester,
319
+ expectedTitle: zulipLocalizations.errorMarkAsReadFailedTitle,
320
+ expectedMessage: zulipLocalizations.errorInvalidResponse);
321
+ });
322
+
323
+ testWidgets ('catch-all api errors' , (WidgetTester tester) async {
324
+ final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
325
+ const narrow = CombinedFeedNarrow ();
326
+ await prepare (tester);
327
+ connection.prepare (exception: http.ClientException ('Oops' ));
328
+ markNarrowAsRead (context, narrow);
329
+ await tester.pump (Duration .zero);
330
+ await tester.pumpAndSettle ();
331
+ checkErrorDialog (tester,
332
+ expectedTitle: zulipLocalizations.errorMarkAsReadFailedTitle,
333
+ expectedMessage: 'NetworkException: Oops (ClientException: Oops)' );
334
+ });
335
335
});
336
336
}
0 commit comments