Ocideck/test/presentation_info_dialog_test.dart
Brenno de Winter ebc9710283
Some checks failed
CI / Format · Analyze · Test (push) Has been cancelled
CI / Format · Analyze · Test (pull_request) Has been cancelled
Small UX tweaks: tab close affordance and date quick-fill
- Show the tab close button for an open presentation tab even when it is the
  only tab.
- Double-click the date field in the presentation-info dialog to fill in
  today's date.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 21:50:23 +02:00

33 lines
1.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ocideck/models/deck.dart';
import 'package:ocideck/widgets/dialogs/presentation_info_dialog.dart';
void main() {
testWidgets('double-clicking date fills in the current date', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: PresentationInfoDialog(deck: Deck(title: 'Test')),
),
),
);
final dateField = find.byWidgetPredicate(
(widget) =>
widget is TextField && widget.decoration?.labelText == 'Datum',
);
final now = DateTime.now();
String twoDigits(int value) => value.toString().padLeft(2, '0');
final expected =
'${now.year}-${twoDigits(now.month)}-${twoDigits(now.day)}';
await tester.tap(dateField);
await tester.pump(const Duration(milliseconds: 50));
await tester.tap(dateField);
await tester.pump(const Duration(milliseconds: 100));
final field = tester.widget<TextField>(dateField);
expect(field.controller!.text, expected);
});
}