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