@@ -169,32 +169,40 @@ void main() {
169
169
await prepareOutboxMessage (destination: DmDestination (
170
170
userIds: [eg.selfUser.userId, eg.otherUser.userId]));
171
171
checkState ().equals (OutboxMessageState .hidden);
172
+ checkNotNotified ();
172
173
173
174
async .elapse (kLocalEchoDebounceDuration);
174
175
checkState ().equals (OutboxMessageState .waiting);
176
+ checkNotNotified (); // TODO once (it appears)
175
177
176
178
await receiveMessage (eg.dmMessage (from: eg.selfUser, to: [eg.otherUser]));
177
179
check (store.outboxMessages).isEmpty ();
180
+ checkNotifiedOnce ();
178
181
}));
179
182
180
183
test ('smoke stream message: hidden -> waiting -> (delete)' , () => awaitFakeAsync ((async ) async {
181
184
await prepareOutboxMessage (destination: StreamDestination (
182
185
stream.streamId, eg.t ('foo' )));
183
186
checkState ().equals (OutboxMessageState .hidden);
187
+ checkNotNotified ();
184
188
185
189
async .elapse (kLocalEchoDebounceDuration);
186
190
checkState ().equals (OutboxMessageState .waiting);
191
+ checkNotNotified (); // TODO once (it appears)
187
192
188
193
await receiveMessage (eg.streamMessage (stream: stream, topic: 'foo' ));
189
194
check (store.outboxMessages).isEmpty ();
195
+ checkNotifiedOnce ();
190
196
}));
191
197
192
198
test ('hidden -> waiting and never transition to waitPeriodExpired' , () => awaitFakeAsync ((async ) async {
193
199
await prepareOutboxMessage ();
194
200
checkState ().equals (OutboxMessageState .hidden);
201
+ checkNotNotified ();
195
202
196
203
async .elapse (kLocalEchoDebounceDuration);
197
204
checkState ().equals (OutboxMessageState .waiting);
205
+ checkNotNotified (); // TODO once (it appears)
198
206
199
207
// Wait till we reach at least [kSendMessageOfferRestoreWaitPeriod] after
200
208
// the send request was initiated.
@@ -204,16 +212,19 @@ void main() {
204
212
// The outbox message should stay in the waiting state;
205
213
// it should not transition to waitPeriodExpired.
206
214
checkState ().equals (OutboxMessageState .waiting);
215
+ checkNotNotified ();
207
216
}));
208
217
209
218
test ('waiting -> waitPeriodExpired' , () => awaitFakeAsync ((async ) async {
210
219
await prepareOutboxMessageToFailAfterDelay (
211
220
kSendMessageOfferRestoreWaitPeriod + Duration (seconds: 1 ));
212
221
async .elapse (kLocalEchoDebounceDuration);
213
222
checkState ().equals (OutboxMessageState .waiting);
223
+ checkNotNotified (); // TODO once (it appears)
214
224
215
225
async .elapse (kSendMessageOfferRestoreWaitPeriod - kLocalEchoDebounceDuration);
216
226
checkState ().equals (OutboxMessageState .waitPeriodExpired);
227
+ checkNotNotified (); // TODO once (it offers restore)
217
228
218
229
await check (outboxMessageFailFuture).throws ();
219
230
}));
@@ -231,10 +242,12 @@ void main() {
231
242
destination: streamDestination, content: 'content' );
232
243
async .elapse (kSendMessageOfferRestoreWaitPeriod);
233
244
checkState ().equals (OutboxMessageState .waitPeriodExpired);
245
+ checkNotNotified (); // TODO twice (it appears; it offers restore)
234
246
235
247
// Wait till the [sendMessage] request succeeds.
236
248
await future;
237
249
checkState ().equals (OutboxMessageState .waiting);
250
+ checkNotNotified (); // TODO once (it un-offers restore)
238
251
239
252
// Wait till we reach at least [kSendMessageOfferRestoreWaitPeriod] after
240
253
// returning to the waiting state.
@@ -243,15 +256,18 @@ void main() {
243
256
// The outbox message should stay in the waiting state;
244
257
// it should not transition to waitPeriodExpired.
245
258
checkState ().equals (OutboxMessageState .waiting);
259
+ checkNotNotified ();
246
260
}));
247
261
248
262
group ('… -> failed' , () {
249
263
test ('hidden -> failed' , () => awaitFakeAsync ((async ) async {
250
264
await prepareOutboxMessageToFailAfterDelay (Duration .zero);
251
265
checkState ().equals (OutboxMessageState .hidden);
266
+ checkNotNotified ();
252
267
253
268
await check (outboxMessageFailFuture).throws ();
254
269
checkState ().equals (OutboxMessageState .failed);
270
+ checkNotNotified (); // TODO once (it appears, offering restore)
255
271
256
272
// Wait till we reach at least [kSendMessageOfferRestoreWaitPeriod] after
257
273
// the send request was initiated.
@@ -260,62 +276,74 @@ void main() {
260
276
// The outbox message should stay in the failed state;
261
277
// it should not transition to waitPeriodExpired.
262
278
checkState ().equals (OutboxMessageState .failed);
279
+ checkNotNotified ();
263
280
}));
264
281
265
282
test ('waiting -> failed' , () => awaitFakeAsync ((async ) async {
266
283
await prepareOutboxMessageToFailAfterDelay (
267
284
kLocalEchoDebounceDuration + Duration (seconds: 1 ));
268
285
async .elapse (kLocalEchoDebounceDuration);
269
286
checkState ().equals (OutboxMessageState .waiting);
287
+ checkNotNotified (); // TODO once (it appears)
270
288
271
289
await check (outboxMessageFailFuture).throws ();
272
290
checkState ().equals (OutboxMessageState .failed);
291
+ checkNotNotified (); // TODO once (it offers restore)
273
292
}));
274
293
275
294
test ('waitPeriodExpired -> failed' , () => awaitFakeAsync ((async ) async {
276
295
await prepareOutboxMessageToFailAfterDelay (
277
296
kSendMessageOfferRestoreWaitPeriod + Duration (seconds: 1 ));
278
297
async .elapse (kSendMessageOfferRestoreWaitPeriod);
279
298
checkState ().equals (OutboxMessageState .waitPeriodExpired);
299
+ checkNotNotified (); // TODO twice (it appears; it offers restore)
280
300
281
301
await check (outboxMessageFailFuture).throws ();
282
302
checkState ().equals (OutboxMessageState .failed);
303
+ checkNotNotified (); // TODO once (it shows failure text)
283
304
}));
284
305
});
285
306
286
307
group ('… -> (delete)' , () {
287
308
test ('hidden -> (delete) because event received' , () => awaitFakeAsync ((async ) async {
288
309
await prepareOutboxMessage ();
289
310
checkState ().equals (OutboxMessageState .hidden);
311
+ checkNotNotified ();
290
312
291
313
await receiveMessage ();
292
314
check (store.outboxMessages).isEmpty ();
315
+ checkNotifiedOnce ();
293
316
}));
294
317
295
318
test ('hidden -> (delete) when event arrives before send request fails' , () => awaitFakeAsync ((async ) async {
296
319
// Set up an error to fail `sendMessage` with a delay, leaving time for
297
320
// the message event to arrive.
298
321
await prepareOutboxMessageToFailAfterDelay (const Duration (seconds: 1 ));
299
322
checkState ().equals (OutboxMessageState .hidden);
323
+ checkNotNotified ();
300
324
301
325
// Received the message event while the message is being sent.
302
326
await receiveMessage ();
303
327
check (store.outboxMessages).isEmpty ();
328
+ checkNotifiedOnce ();
304
329
305
330
// Complete the send request. There should be no error despite
306
331
// the send request failure, because the outbox message is not
307
332
// in the store any more.
308
333
await check (outboxMessageFailFuture).completes ();
309
334
async .elapse (const Duration (seconds: 1 ));
335
+ checkNotNotified ();
310
336
}));
311
337
312
338
test ('waiting -> (delete) because event received' , () => awaitFakeAsync ((async ) async {
313
339
await prepareOutboxMessage ();
314
340
async .elapse (kLocalEchoDebounceDuration);
315
341
checkState ().equals (OutboxMessageState .waiting);
342
+ checkNotNotified (); // TODO once (it appears)
316
343
317
344
await receiveMessage ();
318
345
check (store.outboxMessages).isEmpty ();
346
+ checkNotifiedOnce ();
319
347
}));
320
348
321
349
test ('waiting -> (delete) when event arrives before send request fails' , () => awaitFakeAsync ((async ) async {
@@ -325,15 +353,18 @@ void main() {
325
353
kLocalEchoDebounceDuration + Duration (seconds: 1 ));
326
354
async .elapse (kLocalEchoDebounceDuration);
327
355
checkState ().equals (OutboxMessageState .waiting);
356
+ checkNotNotified (); // TODO once (it appears)
328
357
329
358
// Received the message event while the message is being sent.
330
359
await receiveMessage ();
331
360
check (store.outboxMessages).isEmpty ();
361
+ checkNotifiedOnce ();
332
362
333
363
// Complete the send request. There should be no error despite
334
364
// the send request failure, because the outbox message is not
335
365
// in the store any more.
336
366
await check (outboxMessageFailFuture).completes ();
367
+ checkNotNotified ();
337
368
}));
338
369
339
370
test ('waitPeriodExpired -> (delete) when event arrives before send request fails' , () => awaitFakeAsync ((async ) async {
@@ -343,15 +374,18 @@ void main() {
343
374
kSendMessageOfferRestoreWaitPeriod + Duration (seconds: 1 ));
344
375
async .elapse (kSendMessageOfferRestoreWaitPeriod);
345
376
checkState ().equals (OutboxMessageState .waitPeriodExpired);
377
+ checkNotNotified (); // TODO twice (it appears; it offers restore)
346
378
347
379
// Received the message event while the message is being sent.
348
380
await receiveMessage ();
349
381
check (store.outboxMessages).isEmpty ();
382
+ checkNotifiedOnce ();
350
383
351
384
// Complete the send request. There should be no error despite
352
385
// the send request failure, because the outbox message is not
353
386
// in the store any more.
354
387
await check (outboxMessageFailFuture).completes ();
388
+ checkNotNotified ();
355
389
}));
356
390
357
391
test ('waitPeriodExpired -> (delete) because outbox message was taken' , () => awaitFakeAsync ((async ) async {
@@ -361,27 +395,33 @@ void main() {
361
395
kSendMessageOfferRestoreWaitPeriod + Duration (seconds: 1 ));
362
396
async .elapse (kSendMessageOfferRestoreWaitPeriod);
363
397
checkState ().equals (OutboxMessageState .waitPeriodExpired);
398
+ checkNotNotified (); // TODO twice (it appears; it offers restore)
364
399
365
400
store.takeOutboxMessage (store.outboxMessages.keys.single);
366
401
check (store.outboxMessages).isEmpty ();
402
+ checkNotNotified (); // TODO once (it disappears)
367
403
}));
368
404
369
405
test ('failed -> (delete) because event received' , () => awaitFakeAsync ((async ) async {
370
406
await prepareOutboxMessageToFailAfterDelay (Duration .zero);
371
407
await check (outboxMessageFailFuture).throws ();
372
408
checkState ().equals (OutboxMessageState .failed);
409
+ checkNotNotified (); // TODO once (it appears, offering restore)
373
410
374
411
await receiveMessage ();
375
412
check (store.outboxMessages).isEmpty ();
413
+ checkNotifiedOnce ();
376
414
}));
377
415
378
416
test ('failed -> (delete) because outbox message was taken' , () => awaitFakeAsync ((async ) async {
379
417
await prepareOutboxMessageToFailAfterDelay (Duration .zero);
380
418
await check (outboxMessageFailFuture).throws ();
381
419
checkState ().equals (OutboxMessageState .failed);
420
+ checkNotNotified (); // TODO once (it appears, offering restore)
382
421
383
422
store.takeOutboxMessage (store.outboxMessages.keys.single);
384
423
check (store.outboxMessages).isEmpty ();
424
+ checkNotNotified (); // TODO once (it disappears)
385
425
}));
386
426
});
387
427
@@ -423,11 +463,13 @@ void main() {
423
463
await check (store.sendMessage (
424
464
destination: StreamDestination (stream.streamId, eg.t ('topic' )),
425
465
content: 'content' )).throws ();
466
+ checkNotNotified (); // TODO once (it appears, offering restore)
426
467
}
427
468
428
469
final localMessageIds = store.outboxMessages.keys.toList ();
429
470
store.takeOutboxMessage (localMessageIds.removeAt (5 ));
430
471
check (store.outboxMessages).keys.deepEquals (localMessageIds);
472
+ checkNotNotified (); // TODO once (it disappears)
431
473
});
432
474
433
475
group ('reconcileMessages' , () {
0 commit comments