Files
clide/test/builtin/claude/image_thumbnail_test.dart
jpmschweitzerandClaude Opus 4.8 adbd8e285a harden SettingsStore against notify-after-dispose for fire-and-forget writes
set() doesn't await its file write, so a write in flight when the store is
disposed (app shutdown, or a closing test) would assert on a disposed
ChangeNotifier. Skip the post-write notify once disposed via a _disposed guard +
_safeNotify. Surfaced by the T-293 theme-persistence test flaking under the
loaded parallel run; also the correct behaviour for graceful shutdown.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 18:05:53 +02:00

42 lines
1.5 KiB
Dart

/// Tests for ImageThumbnail (T-236 / T-254): a bounded, keyboard-activatable
/// image preview that opens the lightbox and degrades gracefully.
library;
import 'package:clide/builtin/claude/src/image_thumbnail.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../helpers/kernel_fixture.dart';
import '../../helpers/widget_harness.dart';
void main() {
group('ImageThumbnail', () {
late KernelFixture f;
setUp(() async => f = await KernelFixture.create());
tearDown(() => f.dispose());
testWidgets('carries an a11y label from the file name', (tester) async {
await tester.pumpWidget(harness(f, const ImageThumbnail(path: '/tmp/clide/paste-9.png')));
await tester.pump();
expect(find.bySemanticsLabel('Image paste-9.png'), findsOneWidget);
});
testWidgets('a missing file degrades to a placeholder without throwing', (tester) async {
await tester.pumpWidget(harness(f, const ImageThumbnail(path: '/no/such/file.png')));
await tester.pumpAndSettle();
expect(find.byType(ImageThumbnail), findsOneWidget);
expect(tester.takeException(), isNull);
});
testWidgets('tapping opens the lightbox via the dialog router', (tester) async {
await tester.pumpWidget(harness(f, const ImageThumbnail(path: '/no/such/file.png')));
await tester.pump();
expect(f.services.dialog.isOpen, isFalse);
await tester.tap(find.byType(ImageThumbnail));
await tester.pump();
expect(f.services.dialog.isOpen, isTrue);
});
});
}