halkyon/packages/halkyon_ui/test/widget/undo_snack_bar_test.dart

80 lines
2.1 KiB
Dart
Raw Normal View History

import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_ui/halkyon_ui.dart';
import 'package:material_ui/material_ui.dart';
void main() {
late int undos;
feat(todo): quick add's keys, sub-projects' colours, a task's menu on a right click, and the completed tasks deleted at once The developer's list of 9 Nov 2026, Todo's part: - Quick add: the down arrow and Tab move into the description, with its cursor (halkyon_editor's fix); Escape closes the projects or labels suggested first, then closes quick add, what was typed discarded; the project's chip shows the project's colour. - A project without a colour of its own shows its parent's, the nearest ancestor's with one (colorOfProject, TodoCubit.colorOf), wherever a project's colour shows; the project editor's "Same colour as its parent" keeps it so, and the parent picker shows each project in its colour. A project of its own always has one. - The task pane's x closes it, always; Close left the ⋮ menu. - A task's row opens its menu on a right click: Mark as done, Date, Move to, Labels, Priority, Deadline, Duplicate and Delete, the selection's actions for that one task. - Delete completed tasks, in the ⋮ of the Inbox, Today, Upcoming and a project, with Undo: the tasks leave the list at once and are deleted once the snack bar goes without its Undo (halkyon_ui's showUndoSnackBar gains onKept). Whats-New: Quick add: the arrow keys and Tab reach the description, and Escape closes it without saving. Whats-New-De: Schnell hinzufügen: Pfeiltasten und Tab erreichen die Beschreibung, und Escape schließt es, ohne zu speichern. Whats-New: Sub-projects take their parent's colour unless they have their own. Whats-New-De: Unterprojekte übernehmen die Farbe ihres übergeordneten Projekts, wenn sie keine eigene haben. Whats-New: A right click on a task opens its menu, with Move to and more; Delete completed tasks clears a list, with Undo. Whats-New-De: Ein Rechtsklick auf eine Aufgabe öffnet ihr Menü, mit Verschieben nach und mehr; Erledigte Aufgaben löschen räumt eine Liste auf, mit Rückgängig. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-09 23:12:43 +01:00
late int kept;
feat(todo): quick add's keys, sub-projects' colours, a task's menu on a right click, and the completed tasks deleted at once The developer's list of 9 Nov 2026, Todo's part: - Quick add: the down arrow and Tab move into the description, with its cursor (halkyon_editor's fix); Escape closes the projects or labels suggested first, then closes quick add, what was typed discarded; the project's chip shows the project's colour. - A project without a colour of its own shows its parent's, the nearest ancestor's with one (colorOfProject, TodoCubit.colorOf), wherever a project's colour shows; the project editor's "Same colour as its parent" keeps it so, and the parent picker shows each project in its colour. A project of its own always has one. - The task pane's x closes it, always; Close left the ⋮ menu. - A task's row opens its menu on a right click: Mark as done, Date, Move to, Labels, Priority, Deadline, Duplicate and Delete, the selection's actions for that one task. - Delete completed tasks, in the ⋮ of the Inbox, Today, Upcoming and a project, with Undo: the tasks leave the list at once and are deleted once the snack bar goes without its Undo (halkyon_ui's showUndoSnackBar gains onKept). Whats-New: Quick add: the arrow keys and Tab reach the description, and Escape closes it without saving. Whats-New-De: Schnell hinzufügen: Pfeiltasten und Tab erreichen die Beschreibung, und Escape schließt es, ohne zu speichern. Whats-New: Sub-projects take their parent's colour unless they have their own. Whats-New-De: Unterprojekte übernehmen die Farbe ihres übergeordneten Projekts, wenn sie keine eigene haben. Whats-New: A right click on a task opens its menu, with Move to and more; Delete completed tasks clears a list, with Undo. Whats-New-De: Ein Rechtsklick auf eine Aufgabe öffnet ihr Menü, mit Verschieben nach und mehr; Erledigte Aufgaben löschen räumt eine Liste auf, mit Rückgängig. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-09 23:12:43 +01:00
setUp(() {
undos = 0;
kept = 0;
});
/// Shows "Studyset archived" with a way to undo it.
Future<void> archive(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: HalkyonUiLocalizations.localizationsDelegates,
supportedLocales: HalkyonUiLocalizations.supportedLocales,
home: Scaffold(
body: Builder(
builder: (context) => TextButton(
onPressed: () => showUndoSnackBar(
context,
message: 'Studyset archived',
onUndo: () => undos++,
feat(todo): quick add's keys, sub-projects' colours, a task's menu on a right click, and the completed tasks deleted at once The developer's list of 9 Nov 2026, Todo's part: - Quick add: the down arrow and Tab move into the description, with its cursor (halkyon_editor's fix); Escape closes the projects or labels suggested first, then closes quick add, what was typed discarded; the project's chip shows the project's colour. - A project without a colour of its own shows its parent's, the nearest ancestor's with one (colorOfProject, TodoCubit.colorOf), wherever a project's colour shows; the project editor's "Same colour as its parent" keeps it so, and the parent picker shows each project in its colour. A project of its own always has one. - The task pane's x closes it, always; Close left the ⋮ menu. - A task's row opens its menu on a right click: Mark as done, Date, Move to, Labels, Priority, Deadline, Duplicate and Delete, the selection's actions for that one task. - Delete completed tasks, in the ⋮ of the Inbox, Today, Upcoming and a project, with Undo: the tasks leave the list at once and are deleted once the snack bar goes without its Undo (halkyon_ui's showUndoSnackBar gains onKept). Whats-New: Quick add: the arrow keys and Tab reach the description, and Escape closes it without saving. Whats-New-De: Schnell hinzufügen: Pfeiltasten und Tab erreichen die Beschreibung, und Escape schließt es, ohne zu speichern. Whats-New: Sub-projects take their parent's colour unless they have their own. Whats-New-De: Unterprojekte übernehmen die Farbe ihres übergeordneten Projekts, wenn sie keine eigene haben. Whats-New: A right click on a task opens its menu, with Move to and more; Delete completed tasks clears a list, with Undo. Whats-New-De: Ein Rechtsklick auf eine Aufgabe öffnet ihr Menü, mit Verschieben nach und mehr; Erledigte Aufgaben löschen räumt eine Liste auf, mit Rückgängig. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-09 23:12:43 +01:00
onKept: () => kept++,
),
child: const Text('Archive'),
),
),
),
),
);
await tester.tap(find.text('Archive'));
await tester.pumpAndSettle();
}
testWidgets('offers to undo', (tester) async {
await archive(tester);
expect(find.text('Studyset archived'), findsOneWidget);
await tester.tap(find.text('Undo'));
await tester.pumpAndSettle();
expect(undos, 1);
expect(find.text('Studyset archived'), findsNothing);
});
testWidgets('goes by itself after three seconds', (tester) async {
await archive(tester);
await tester.pump(const Duration(seconds: 3));
await tester.pumpAndSettle();
expect(find.text('Studyset archived'), findsNothing);
expect(undos, 0);
});
feat(todo): quick add's keys, sub-projects' colours, a task's menu on a right click, and the completed tasks deleted at once The developer's list of 9 Nov 2026, Todo's part: - Quick add: the down arrow and Tab move into the description, with its cursor (halkyon_editor's fix); Escape closes the projects or labels suggested first, then closes quick add, what was typed discarded; the project's chip shows the project's colour. - A project without a colour of its own shows its parent's, the nearest ancestor's with one (colorOfProject, TodoCubit.colorOf), wherever a project's colour shows; the project editor's "Same colour as its parent" keeps it so, and the parent picker shows each project in its colour. A project of its own always has one. - The task pane's x closes it, always; Close left the ⋮ menu. - A task's row opens its menu on a right click: Mark as done, Date, Move to, Labels, Priority, Deadline, Duplicate and Delete, the selection's actions for that one task. - Delete completed tasks, in the ⋮ of the Inbox, Today, Upcoming and a project, with Undo: the tasks leave the list at once and are deleted once the snack bar goes without its Undo (halkyon_ui's showUndoSnackBar gains onKept). Whats-New: Quick add: the arrow keys and Tab reach the description, and Escape closes it without saving. Whats-New-De: Schnell hinzufügen: Pfeiltasten und Tab erreichen die Beschreibung, und Escape schließt es, ohne zu speichern. Whats-New: Sub-projects take their parent's colour unless they have their own. Whats-New-De: Unterprojekte übernehmen die Farbe ihres übergeordneten Projekts, wenn sie keine eigene haben. Whats-New: A right click on a task opens its menu, with Move to and more; Delete completed tasks clears a list, with Undo. Whats-New-De: Ein Rechtsklick auf eine Aufgabe öffnet ihr Menü, mit Verschieben nach und mehr; Erledigte Aufgaben löschen räumt eine Liste auf, mit Rückgängig. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-09 23:12:43 +01:00
testWidgets('tells once it went without Undo, so what waited for it '
'happens then', (tester) async {
await archive(tester);
expect(kept, 0, reason: 'not while it shows');
await tester.pump(const Duration(seconds: 3));
await tester.pumpAndSettle();
expect(kept, 1);
});
testWidgets('never tells it was kept once undone', (tester) async {
await archive(tester);
await tester.tap(find.text('Undo'));
await tester.pumpAndSettle();
await tester.pump(const Duration(seconds: 5));
expect(kept, 0);
});
}