Files
MeshPort/apps/meshport_lab/test/widget_test.dart
T
shenleiandClaude Haiku 5.5 2f185f914d Snapshot uncommitted work: proxy UI, sing-box integration, socks bridge
- Lab app: proxy panel, node editor, configuration and detail pages,
  responsive layout, and related tests
- Add meshport-socks crate and sing-box bridge scripts/docs
- Add singbox_flutter binding and meshport_client_core package
- FFI, VPN helper (unified mac path), and Android/macOS runner updates
- Docs for architecture, client runtime, UI design, and validation
- UI design output artifacts under outputs/ui

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-12 10:06:15 +09:00

73 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:meshport_lab/features/lab_screen.dart';
void main() {
testWidgets('China bypass can be selected and switched to global', (
tester,
) async {
await tester.pumpWidget(
const MaterialApp(home: LabScreen(initializeNative: false)),
);
await tester.tap(find.text('代理').last);
await tester.pumpAndSettle();
final mode = find.byWidgetPredicate(
(w) =>
w is DropdownButtonFormField<String> &&
w.decoration.labelText == '普通互联网流量模式',
);
await tester.ensureVisible(mode);
await tester.tap(mode);
await tester.pumpAndSettle();
await tester.tap(find.text('绕过中国大陆').last);
await tester.pumpAndSettle();
expect(find.textContaining('中国大陆 IP 和普通私网直连'), findsOneWidget);
await tester.tap(mode);
await tester.pumpAndSettle();
await tester.tap(find.text('全局代理').last);
await tester.pumpAndSettle();
expect(find.textContaining('中国大陆 IP 和普通私网直连'), findsNothing);
expect(tester.takeException(), isNull);
});
testWidgets('Starts disconnected and exposes networking configuration', (
tester,
) async {
await tester.pumpWidget(
const MaterialApp(home: LabScreen(initializeNative: false)),
);
expect(find.text('尚未连接'), findsOneWidget);
await tester.tap(find.text('组网').last);
await tester.pumpAndSettle();
await tester.tap(find.text('基础配置'));
await tester.pumpAndSettle();
expect(find.text('网络密钥'), findsOneWidget);
expect(find.text('保存草稿'), findsOneWidget);
});
testWidgets('proxy import requires preview and preserves draft separation', (
tester,
) async {
await tester.pumpWidget(
const MaterialApp(home: LabScreen(initializeNative: false)),
);
await tester.tap(find.text('代理').last);
await tester.pumpAndSettle();
expect(find.text('普通互联网流量模式'), findsOneWidget);
await tester.ensureVisible(find.text('导入与预览'));
await tester.tap(find.text('导入与预览'));
await tester.pumpAndSettle();
await tester.enterText(
find.byType(TextField).last,
'socks5://127.0.0.1:1080#Preview',
);
await tester.tap(find.text('解析并预览'));
await tester.pumpAndSettle();
expect(find.text('导入预览'), findsOneWidget);
expect(find.text('Preview'), findsOneWidget);
await tester.tap(find.text('确认导入'));
await tester.pumpAndSettle();
expect(find.text('Preview'), findsOneWidget);
expect(find.text('安全保存配置'), findsOneWidget);
});
}