upload diagnostic screenshots

This commit is contained in:
Vadim 2025-03-28 16:56:54 +01:00
parent d2a21d0e68
commit 4045d5a4cb
2 changed files with 134 additions and 98 deletions

View file

@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:lightmeter/data/models/ev_source_type.dart';
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
import 'package:lightmeter/data/shared_prefs_service.dart';
@ -53,6 +54,7 @@ void testE2E(String description) {
customFilms: {},
);
try {
/// Create Praktica + Zenitar profile from scratch
await tester.openSettings();
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
@ -114,7 +116,7 @@ void testE2E(String description) {
tester,
equipmentProfile: mockEquipmentProfiles[0],
film: mockFilms[0],
fastest: 'f/1.8 - 1/200',
fastest: 'f/1.8 - 1/20',
slowest: 'f/16 - 1/2.5',
iso: '400',
nd: '2',
@ -157,6 +159,10 @@ void testE2E(String description) {
await tester.deleteEdits();
expect(find.text(mockEquipmentProfiles[0].name), findsNothing);
expect(find.text(mockEquipmentProfiles[1].name), findsOneWidget);
} on TestFailure catch (_) {
await tester._takeScreenshot('screenshot_e2e');
rethrow;
}
},
);
}
@ -349,3 +355,10 @@ void expectMeasureButton(double ev) {
matching: find.text('${ev.toStringAsFixed(1)}\n${S.current.ev}'),
);
}
extension on WidgetTester {
Future<void> _takeScreenshot(String name) async {
await IntegrationTestWidgetsFlutterBinding.instance.takeScreenshot(name);
await pumpAndSettle();
}
}

View file

@ -1,5 +1,28 @@
import 'dart:io';
import 'package:integration_test/integration_test_driver_extended.dart';
import 'package:uuid/v4.dart';
Future<void> main() async {
await integrationDriver();
await integrationDriver(
onScreenshot: (name, bytes, [_]) async {
final id = const UuidV4().generate();
final path = 'e2e_diagnostics/screenshot_$id.png';
final file = await File(path).create(recursive: true);
file.writeAsBytesSync(bytes);
final result = await Process.run(
"curl",
[
"-F",
'file=@${file.path}',
"https://shot.withfra.me/new",
],
);
stdout.write(result.stdout);
stderr.write(result.stderr);
return true;
},
);
}