Files
MeshPort/apps/meshport_lab/test/advanced_pages_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

100 lines
3.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:meshport_lab/features/proxy_source_pages.dart';
import 'package:meshport_lab/features/detail_pages.dart';
import 'package:meshport_lab/features/configuration_pages.dart';
import 'package:meshport_client_core/meshport_client_core.dart';
void main() {
const channel = MethodChannel('meshport/system_vpn');
tearDown(
() => TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, null),
);
testWidgets('file import fills draft and requires explicit node preview', (
tester,
) async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
channel,
(call) async =>
call.method == 'import_file' ? 'socks://127.0.0.1:1001' : null,
);
await tester.pumpWidget(const MaterialApp(home: ProxyImportPage()));
await tester.tap(find.text('文件导入'));
await tester.pumpAndSettle();
expect(find.text('确认导入'), findsNothing);
await tester.tap(find.text('解析并预览'));
await tester.pumpAndSettle();
expect(find.text('确认导入'), findsOneWidget);
});
testWidgets('subscription options and metadata survive save', (tester) async {
Map<String, dynamic>? result;
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) => TextButton(
onPressed: () async {
result = await Navigator.push<Map<String, dynamic>>(
context,
MaterialPageRoute(
builder: (_) => const SubscriptionEditor(
subscription: {
'id': 's',
'name': 'Test',
'url': 'https://example.test/sub',
'updated': '2026-10-10T00:00:00Z',
'auto_update': true,
'interval_minutes': 360,
},
),
),
);
},
child: const Text('open'),
),
),
),
);
await tester.tap(find.text('open'));
await tester.pumpAndSettle();
await tester.tap(find.text('自动更新订阅'));
await tester.tap(find.text('保存草稿'));
await tester.pumpAndSettle();
expect(result?['auto_update'], false);
expect(result?['updated'], '2026-10-10T00:00:00Z');
});
testWidgets(
'startup screen reads actual status without registering login item',
(tester) async {
final calls = <String>[];
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (call) async {
calls.add(call.method);
return {'login_status': 'requires_approval', 'auto_connect': false};
});
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(body: StartupPageBody(channel: channel)),
),
);
await tester.pumpAndSettle();
expect(find.text('打开系统登录项,允许 MeshPort'), findsOneWidget);
expect(calls, ['startup_status']);
},
);
testWidgets('DoT default port is accepted and saved', (tester) async {
final p = ProxyProfile();
await tester.pumpWidget(
MaterialApp(
home: DnsPage(profile: p, changed: () {}),
),
);
await tester.enterText(find.byType(TextField).at(1), 'tls://dns.example');
await tester.tap(find.text('保存草稿'));
await tester.pumpAndSettle();
expect(p.directDnsServer, 'tls://dns.example');
});
}