mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-20 07:45:37 +01:00
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
file-length / file length <= 250 lines (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
release-apk / release (APK) (push) Has been cancelled
repo-contract / repo contract (push) Has been cancelled
crdt_sync_flutter 0.9.0's installAppErrors in main(): uncaught errors and every spinner shown over 1 s (WaitWatch: sync.run, mirror.test) upload to RTDB /todo/errors/<device> with the versionCode, where the PC app-errors ingest files board tickets (kuhyx/utils DOCS-app-errors.md). The app moves to material_ui first: sync_settings_ui 0.8.x and design_system 0.4.x sit on it, and Flutter 3.50 deprecates flutter/material. Pins: crdt_sync 0.14.1, csf 0.9.0, ssui 0.8.3, gda 0.5.1, design_system 0.4.1, image 4.13.1, mcp_dart 2.4.4. file_picker stays 13.3.3, held by data_transfer_flutter 0.2.2 (allowlisted, self-clearing). appRoute takes a route name so each report names its screen; the release build passes APP_BUILD/APP_VERSION. Nothing new on screen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
98 lines
3.3 KiB
Dart
98 lines
3.3 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:material_ui/material_ui.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:image/image.dart' as img;
|
|
import 'package:todo/attachments/image_store_scope.dart';
|
|
import 'package:todo/images/attachment_ref.dart';
|
|
import 'package:todo/ui/images/image_embed.dart';
|
|
import 'package:todo/ui/images/attachment_strip.dart';
|
|
import 'package:todo/ui/images/image_viewer_screen.dart';
|
|
|
|
import '../fake_image_store.dart';
|
|
|
|
void main() {
|
|
final ref = AttachmentRef.create('n1');
|
|
late FakeImageStore store;
|
|
late Directory dir;
|
|
|
|
setUp(() {
|
|
store = FakeImageStore();
|
|
dir = Directory.systemTemp.createTempSync('embed');
|
|
final file = File('${dir.path}/a.jpg')
|
|
..writeAsBytesSync(img.encodeJpg(img.Image(width: 4, height: 4)));
|
|
store.localPath = file.path;
|
|
});
|
|
tearDown(() => dir.deleteSync(recursive: true));
|
|
|
|
Future<void> pump(WidgetTester tester, Widget child) => tester.pumpWidget(
|
|
ImageStoreScope(
|
|
store: store,
|
|
child: MaterialApp(
|
|
home: Scaffold(body: SizedBox(width: 200, height: 200, child: child)),
|
|
),
|
|
),
|
|
);
|
|
|
|
testWidgets('a local image renders and opens full screen', (tester) async {
|
|
await pump(tester, ImageEmbed(ref: ref));
|
|
expect(find.byType(Image), findsOneWidget);
|
|
expect(find.byIcon(Icons.cloud_upload_outlined), findsNothing);
|
|
await tester.tap(find.byType(ImageEmbed));
|
|
await tester.pumpAndSettle();
|
|
expect(find.byType(ImageViewerScreen), findsOneWidget);
|
|
expect(find.byType(InteractiveViewer), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('a queued image carries the upload badge', (tester) async {
|
|
store.pending.add(ref);
|
|
await pump(tester, ImageEmbed(ref: ref));
|
|
expect(find.byIcon(Icons.cloud_upload_outlined), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('a missing image is a placeholder and not tappable', (
|
|
tester,
|
|
) async {
|
|
store.missing.add(ref);
|
|
await pump(tester, ImageEmbed(ref: ref));
|
|
expect(find.byIcon(Icons.cloud_download_outlined), findsOneWidget);
|
|
await tester.tap(find.byType(ImageEmbed));
|
|
await tester.pumpAndSettle();
|
|
expect(find.byType(ImageViewerScreen), findsNothing);
|
|
});
|
|
|
|
testWidgets('a broken file or url falls back to the placeholder', (
|
|
tester,
|
|
) async {
|
|
store.localPath = '${dir.path}/gone.jpg';
|
|
await pump(tester, ImageEmbed(ref: ref));
|
|
await tester.runAsync(
|
|
() => Future<void>.delayed(const Duration(milliseconds: 50)),
|
|
);
|
|
await tester.pump();
|
|
expect(find.byIcon(Icons.cloud_download_outlined), findsOneWidget);
|
|
store.network = true;
|
|
store.changed();
|
|
await tester.pump();
|
|
await tester.runAsync(
|
|
() => Future<void>.delayed(const Duration(milliseconds: 50)),
|
|
);
|
|
await tester.pump();
|
|
expect(find.byIcon(Icons.cloud_download_outlined), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('the strip shows one thumbnail per linked image', (tester) async {
|
|
final other = AttachmentRef.create('n2');
|
|
await pump(
|
|
tester,
|
|
AttachmentStrip(text: 'x\n${ref.imageMarkdown}\n${other.imageMarkdown}'),
|
|
);
|
|
expect(find.byType(ImageEmbed), findsNWidgets(2));
|
|
});
|
|
|
|
testWidgets('the strip is empty without images', (tester) async {
|
|
await pump(tester, const AttachmentStrip(text: 'no images'));
|
|
expect(find.byType(ImageEmbed), findsNothing);
|
|
});
|
|
}
|