refactor(app): delayed deletions move into halkyon_app (ADR 0030, D24)
Learn's DelayedDeletions, unchanged, with its test, so that Train's workouts can be deleted with an undo as Learn's items are. Learn's deletions import it from halkyon_app now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
dd778cb2cd
commit
39b43217f6
1 changed files with 24 additions and 6 deletions
49
packages/halkyon_app/test/async/delayed_deletions_test.dart
Normal file
49
packages/halkyon_app/test/async/delayed_deletions_test.dart
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_app/halkyon_app.dart';
|
||||
|
||||
import '../support/eventually.dart';
|
||||
|
||||
void main() {
|
||||
late List<String> deleted;
|
||||
late DelayedDeletions deletions;
|
||||
|
||||
setUp(() {
|
||||
deleted = [];
|
||||
deletions = DelayedDeletions(
|
||||
(id) async => deleted.add(id),
|
||||
undoWindow: const Duration(milliseconds: 10),
|
||||
);
|
||||
});
|
||||
tearDown(() => deletions.dispose());
|
||||
|
||||
test('a held deletion waits past the time to undo, until it is let go: '
|
||||
'then it takes its time to undo', () async {
|
||||
deletions.hold('a');
|
||||
await Future<void>.delayed(const Duration(milliseconds: 50));
|
||||
expect(deletions.pending, {'a'});
|
||||
expect(deleted, isEmpty);
|
||||
|
||||
deletions.delete('a');
|
||||
expect(deletions.pending, {'a'});
|
||||
await eventually(() => deletions.pending.isEmpty);
|
||||
expect(deleted, ['a']);
|
||||
});
|
||||
|
||||
test('a held deletion can be undone', () async {
|
||||
deletions
|
||||
..hold('a')
|
||||
..undo('a');
|
||||
expect(deletions.pending, isEmpty);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 50));
|
||||
expect(deleted, isEmpty);
|
||||
});
|
||||
|
||||
test('closing drops a held deletion: the item stays', () async {
|
||||
deletions.hold('a');
|
||||
await deletions.dispose();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 50));
|
||||
|
||||
expect(deleted, isEmpty);
|
||||
deletions = DelayedDeletions((id) async {});
|
||||
});
|
||||
}
|
||||
Loading…
Reference in a new issue