Ocideck/test/add_slide_dialog_test.dart
Brenno de Winter 68725341a7 Add image-library dedupe and untagged filter, UI text scaling, table paste
Image library:
- "Clean up duplicates" finds byte-identical images by md5, keeps one
  file per group (preferring the most-used, then the oldest), merges
  the tags/descriptions and captions of the copies, repoints slides in
  open decks and in .md presentations on disk, and deletes the copies
  after a confirmation that lists every group.
- A header toggle filters to images without tags/description, so it is
  easy to see which ones still need attention.
- The delete warning now also lists presentations on disk that still
  reference the image (marked "not open"), next to the open decks.

Editor and accessibility (already in tree):
- Interface text scaling up to 200%, keyboard-operable panel divider,
  keyboard-first add-slide dialog, and screen-reader improvements.
- Paste a spreadsheet/CSV/markdown selection into a table cell to fill
  the whole grid.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 13:36:44 +02:00

86 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ocideck/models/slide.dart';
import 'package:ocideck/widgets/dialogs/add_slide_dialog.dart';
void main() {
Future<SlideType?> Function() openDialog(WidgetTester tester) {
SlideType? picked;
return () async {
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) => Center(
child: ElevatedButton(
onPressed: () async =>
picked = await AddSlideDialog.show(context),
child: const Text('open'),
),
),
),
),
);
await tester.tap(find.text('open'));
await tester.pumpAndSettle();
return picked;
};
}
testWidgets('every slide type shows a wireframe preview', (tester) async {
await openDialog(tester)();
final painters = tester
.widgetList<CustomPaint>(find.byType(CustomPaint))
.map((p) => p.painter)
.whereType<SlideTypePreviewPainter>()
.map((p) => p.type)
.toSet();
expect(painters, SlideType.values.toSet());
});
testWidgets('type cards are labelled buttons (WCAG name/role)', (
tester,
) async {
final handle = tester.ensureSemantics();
await openDialog(tester)();
expect(
tester.getSemantics(find.text('Tabel')),
isSemantics(isButton: true, isFocusable: true, label: 'Tabel'),
);
handle.dispose();
});
testWidgets('the dialog is fully keyboard-operable', (tester) async {
SlideType? picked;
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) => Center(
child: ElevatedButton(
onPressed: () async => picked = await AddSlideDialog.show(context),
child: const Text('open'),
),
),
),
),
);
await tester.tap(find.text('open'));
await tester.pumpAndSettle();
// The first card (title slide) is focused on open; tab moves to the
// second card and Enter activates it.
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(picked, SlideType.section);
});
testWidgets('escape closes the dialog without choosing', (tester) async {
await openDialog(tester)();
expect(find.byType(AddSlideDialog), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byType(AddSlideDialog), findsNothing);
});
}