mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-19 15:14:23 +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>
86 lines
2.9 KiB
Dart
86 lines
2.9 KiB
Dart
// Proves the shared app-errors reporter end to end inside the test runner:
|
|
// one uncaught error and one wait over a second each become exactly one
|
|
// uploaded entry, and both carry the build. The sink writes to a file in
|
|
// place of RTDB so the probe needs no network.
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
import 'dart:ui';
|
|
|
|
import 'package:crdt_sync_flutter/crdt_sync_flutter.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:material_ui/material_ui.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
void main() {
|
|
late FlutterExceptionHandler? savedFlutter;
|
|
late ErrorCallback? savedAsync;
|
|
late Directory dir;
|
|
|
|
setUp(() {
|
|
SharedPreferences.setMockInitialValues({});
|
|
savedFlutter = FlutterError.onError;
|
|
savedAsync = PlatformDispatcher.instance.onError;
|
|
dir = Directory.systemTemp.createTempSync('app_errors_probe');
|
|
});
|
|
|
|
tearDown(() {
|
|
FlutterError.onError = savedFlutter;
|
|
PlatformDispatcher.instance.onError = savedAsync;
|
|
AppErrors.instance = null;
|
|
dir.deleteSync(recursive: true);
|
|
});
|
|
|
|
testWidgets('one error and one 2 s wait upload with the build', (t) async {
|
|
// The deliberate error must not fail the test, so the handler the
|
|
// reporter chains to is a no-op.
|
|
FlutterError.onError = (_) {};
|
|
final errors = await installAppErrors(
|
|
const AppErrorsConfig(
|
|
app: 'todo',
|
|
repo: 'kuhyx/todo-app',
|
|
package: 'todo',
|
|
build: 4242,
|
|
version: '1.2.3',
|
|
),
|
|
);
|
|
final out = File('${dir.path}/sink.jsonl');
|
|
final uploader = errors.connect(
|
|
sink: () async =>
|
|
(path, values) async => out.writeAsStringSync(
|
|
'${jsonEncode({'path': path, 'values': values})}\n',
|
|
mode: FileMode.append,
|
|
),
|
|
deviceId: () async => 'probe-device',
|
|
startDelay: Duration.zero,
|
|
);
|
|
|
|
FlutterError.onError!(
|
|
FlutterErrorDetails(exception: StateError('probe boom')),
|
|
);
|
|
|
|
await t.pumpWidget(
|
|
const WaitWatch(operation: 'probe.wait', child: SizedBox()),
|
|
);
|
|
await t.runAsync(() => Future<void>.delayed(const Duration(seconds: 2)));
|
|
await t.pumpWidget(const SizedBox());
|
|
|
|
await t.runAsync(uploader.flush);
|
|
uploader.dispose();
|
|
|
|
final entries = [
|
|
for (final line in out.readAsLinesSync())
|
|
for (final v
|
|
in ((jsonDecode(line) as Map)['values'] as Map).values.cast<Map>())
|
|
v,
|
|
];
|
|
final kinds = entries.map((e) => e['kind']).toList()..sort();
|
|
expect(kinds, ['perf.slow', 'uncaught.flutter']);
|
|
expect(entries.map((e) => e['build']).toSet(), {4242});
|
|
expect(entries.map((e) => e['repo']).toSet(), {'kuhyx/todo-app'});
|
|
final slow = entries.firstWhere((e) => e['kind'] == 'perf.slow');
|
|
expect(slow['operation'], 'probe.wait');
|
|
expect(slow['durationMs'] as int, greaterThanOrEqualTo(2000));
|
|
});
|
|
}
|