Ocideck/test/table_editor_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

66 lines
1.9 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/editors/table_editor.dart';
void main() {
Future<Slide> pasteIntoFirstCell(WidgetTester tester, String clip) async {
var updated = Slide.create(SlideType.table);
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform,
(call) async {
if (call.method == 'Clipboard.getData') {
return <String, dynamic>{'text': clip};
}
return null;
},
);
addTearDown(
() => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform,
null,
),
);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: TableEditor(slide: updated, onUpdate: (s) => updated = s),
),
),
);
// Field 0 is the title; the first table cell is the next TextField.
await tester.tap(find.byType(TextField).at(1));
await tester.pump();
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyDownEvent(LogicalKeyboardKey.keyV);
await tester.sendKeyUpEvent(LogicalKeyboardKey.keyV);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pump();
return updated;
}
testWidgets('pasting a spreadsheet selection fills and grows the grid', (
tester,
) async {
final updated = await pasteIntoFirstCell(
tester,
'Naam\tScore\nJan\t8\nPiet\t9\n',
);
expect(updated.tableRows, [
['Naam', 'Score'],
['Jan', '8'],
['Piet', '9'],
]);
});
testWidgets('pasting plain text stays inside the one cell', (tester) async {
final updated = await pasteIntoFirstCell(tester, 'hallo wereld');
expect(updated.tableRows, [
['hallo wereld', ''],
['', ''],
]);
});
}