feat(flutter): 增加目录加载诊断与前台重试
This commit is contained in:
1 parent
d68734cdab
commit
730a96559b
10 files changed
+268
-16
No files matched your search
@@ -135,6 +135,9 @@ void main() {
|
||||
|
||||
expect(find.byKey(const Key('home-categories-error')), findsOneWidget);
|
||||
expect(find.text('Retry'), findsOneWidget);
|
||||
expect(find.byKey(const Key('catalog-debug-endpoint')), findsOneWidget);
|
||||
expect(find.byKey(const Key('catalog-debug-error')), findsOneWidget);
|
||||
expect(find.textContaining('discover feed unavailable'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_show_search_results_when_text_changes', (tester) async {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:fruitshorts/core/config/app_config.dart';
|
||||
import 'package:fruitshorts/core/data/services/catalog_retry.dart';
|
||||
import 'package:fruitshorts/core/theme/app_colors.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/home/home_view.dart';
|
||||
|
||||
void main() {
|
||||
tearDown(AppConfig.clearRuntimeBaseUrl);
|
||||
|
||||
testWidgets('should_show_endpoint_and_raw_error_in_debug_failure', (
|
||||
tester,
|
||||
) async {
|
||||
AppConfig.applyRuntimeBaseUrl('http://probe.test:8081');
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
home: Scaffold(
|
||||
body: HomeFailureView(
|
||||
error: 'SocketException: Connection refused',
|
||||
onRetry: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final endpoint = tester.widget<Text>(
|
||||
find.byKey(const Key('catalog-debug-endpoint')),
|
||||
);
|
||||
expect(endpoint.data, '服务地址:http://probe.test:8081');
|
||||
expect(endpoint.style?.fontSize, 12);
|
||||
expect(endpoint.style?.color, AppColors.subtle);
|
||||
expect(endpoint.maxLines, 2);
|
||||
|
||||
final error = tester.widget<Text>(
|
||||
find.byKey(const Key('catalog-debug-error')),
|
||||
);
|
||||
expect(error.data, '错误:SocketException: Connection refused');
|
||||
expect(error.style?.fontSize, 12);
|
||||
expect(error.style?.color, AppColors.subtle);
|
||||
expect(error.maxLines, 2);
|
||||
});
|
||||
|
||||
test('should_probe_before_reloading_catalog', () async {
|
||||
final steps = <String>[];
|
||||
|
||||
await retryCatalogLoad(
|
||||
probe: () async => steps.add('probe'),
|
||||
reload: () async => steps.add('load'),
|
||||
);
|
||||
|
||||
expect(steps, ['probe', 'load']);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user