mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Backend: notifications now show a plain "-" for an absent name, vendor, or device type (was empty string / "(unknown)" / "Unknown"), via a single UNKNOWN_PLACEHOLDER constant. Frontend: - Empty/unknown values render as an em dash everywhere, centralised in a new Placeholders.emptyValue constant (replaces inline '—' and '(unknown)'). - Route paths moved to a new Routes class, used by the router and every navigation call site. - Device event type modelled as a DeviceEventType enum mirroring the backend (NewDevice/DeviceSeen) instead of bare string comparisons. - Hardcoded EdgeInsets/SizedBox spacing replaced with existing Insets tokens. Tests and formatting updated; all backend and frontend tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
59 lines
1.5 KiB
Dart
59 lines
1.5 KiB
Dart
import 'package:dio/dio.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:frontend/widgets/scanner_status_card.dart';
|
|
|
|
import '../helpers/backend_test_harness.dart';
|
|
import '../helpers/pump_app.dart';
|
|
|
|
ScannerStatus _resolve(BuildContext context, int value, double elapsed) =>
|
|
(color: Colors.green, label: 'Value $value', sublabels: ['detail line']);
|
|
|
|
void main() {
|
|
setUp(() async {
|
|
await setUpBackendForTest();
|
|
});
|
|
|
|
testWidgets('shows a spinner, then the resolved label and sublabels', (
|
|
tester,
|
|
) async {
|
|
await pumpScreen(
|
|
tester,
|
|
ScannerStatusCard<int>(
|
|
title: 'Probe',
|
|
fetch: ({cancelToken}) async => 42,
|
|
resolver: _resolve,
|
|
),
|
|
);
|
|
|
|
expect(find.byType(CircularProgressIndicator), findsOneWidget);
|
|
|
|
await pumpUntilFound(tester, find.text('Value 42'));
|
|
|
|
expect(find.text('Probe'), findsOneWidget);
|
|
expect(find.text('detail line'), findsOneWidget);
|
|
|
|
await tearDownTree(tester);
|
|
});
|
|
|
|
testWidgets('renders an Error state when the fetch fails', (tester) async {
|
|
await pumpScreen(
|
|
tester,
|
|
ScannerStatusCard<int>(
|
|
title: 'Probe',
|
|
fetch: ({cancelToken}) async => throw DioException(
|
|
requestOptions: RequestOptions(path: '/x'),
|
|
type: DioExceptionType.connectionError,
|
|
),
|
|
resolver: _resolve,
|
|
),
|
|
);
|
|
|
|
await pumpUntilFound(tester, find.text('Error'));
|
|
|
|
expect(find.text('Error'), findsOneWidget);
|
|
|
|
await tearDownTree(tester);
|
|
});
|
|
}
|