Skip to content

Commit 90dceec

Browse files
committed
[red] require explicit reread after recovery generation conflict
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent 5115294 commit 90dceec

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎app/test/unit/draft_recovery_test.dart‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,4 +353,34 @@ void main() {
353353
);
354354
},
355355
);
356+
test(
357+
'conflicting external writer requires reread and explicit choice on Retry',
358+
() async {
359+
final s = Store(), c = container(s);
360+
await recovery(c).start();
361+
editor(c).setContent('first');
362+
expect(await recovery(c).saveRecoveryCopy(), isTrue);
363+
s.snapshot = DraftSnapshot(
364+
name: 'other.py',
365+
content: 'external',
366+
generation: 2,
367+
checkpointTime: DateTime.utc(2026),
368+
);
369+
s.generation = 2;
370+
editor(c).setContent('live newer');
371+
expect(await recovery(c).saveRecoveryCopy(), isFalse);
372+
expect(
373+
c.read(draftRecoveryProvider).failure,
374+
DraftStorageFailure.conflict,
375+
);
376+
await recovery(c).retry();
377+
expect(
378+
c.read(draftRecoveryProvider).status,
379+
DraftRecoveryStatus.decision,
380+
);
381+
expect(c.read(draftRecoveryProvider).candidate?.content, 'external');
382+
expect(c.read(editorDocumentProvider).content, 'live newer');
383+
expect(s.snapshot?.content, 'external');
384+
},
385+
);
356386
}

0 commit comments

Comments
 (0)