feat(app): undo deleting a card

Deleting a card, from the list or while studying, asks first ("Delete
flashcard?"), then offers Undo for a few seconds ("Flashcard deleted").
Meanwhile the card leaves every list and session; once the time to
undo is over, its revisions are blanked and it is deleted for good, as
notes and studysets already are (CardDeletions, a DelayedDeletions).
Undo while studying puts the card back into the round where it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-07 21:52:03 +02:00
commit 2b188641c3
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -110,10 +110,8 @@ void main() {
expect(find.text('Changed on two devices'), findsOneWidget);
});
testWidgets("a card's options delete it, after asking", (tester) async {
final id = await cards.create('japanese', card('猫', 'cat'));
await showList(tester);
/// Deletes the card shown through its options, saying yes.
Future<void> delete(WidgetTester tester) async {
await tester.tap(
find.descendant(
of: find.byType(CardTile),
@ -126,11 +124,38 @@ void main() {
await tester.pump();
await tester.pump();
await tester.pumpAndSettle();
expect(find.text('Delete flashcard?'), findsOneWidget);
await tester.tap(find.widgetWithText(FilledButton, 'Delete'));
await tester.pumpAndSettle();
}
expect(gateway.deletions, ['blank $id', 'delete $id']);
testWidgets("a card's options delete it, after asking; once the time to "
'undo is over, for good', (tester) async {
final id = await cards.create('japanese', card('猫', 'cat'));
await showList(tester);
await delete(tester);
expect(find.text('Flashcard deleted'), findsOneWidget);
expect(find.text('No flashcards yet'), findsOneWidget);
expect(gateway.deletions, isEmpty);
await tester.pump(const Duration(seconds: 5));
await tester.pumpAndSettle();
expect(gateway.deletions, ['blank $id', 'delete $id']);
});
testWidgets('Undo keeps a card deleted a moment ago', (tester) async {
await cards.create('japanese', card('猫', 'cat'));
await showList(tester);
await delete(tester);
await tester.tap(find.text('Undo'));
await tester.pumpAndSettle();
await tester.pump(const Duration(seconds: 5));
await tester.pumpAndSettle();
expect(find.text('猫'), findsOneWidget);
expect(gateway.deletions, isEmpty);
});
testWidgets("a card's options report it and bury it, each shown on the "