import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:im_webview_app/config/app_config.dart'; import 'package:im_webview_app/main.dart'; void main() { test('creates the WebView shell app widget', () { expect( const ImWebViewApp(shellBranding: ShellBranding.fallback), isA(), ); }); test('creates one wildcard H5 line with a numeric 16 digit label', () { final line = AppConfig.h5Line; expect(line.label, '线路1'); expect( line.uri.host, matches(RegExp(r'^[1-9][0-9]{15}\.(albzyuxq|zdyswvnt|gxifpxcr)\.vip$')), ); }); test('generates the next single URL from the configured fallback order', () { var index = 0; const labels = [ '1234567890123456', '2234567890123456', '3234567890123456', ]; final first = AppConfig.createRandomH5Line( attempt: 0, wildcardFactory: () => labels[index++]); final second = AppConfig.createRandomH5Line( attempt: 1, wildcardFactory: () => labels[index++]); final third = AppConfig.createRandomH5Line( attempt: 2, wildcardFactory: () => labels[index++]); expect(first.uri.host, '1234567890123456.albzyuxq.vip'); expect(second.uri.host, '2234567890123456.zdyswvnt.vip'); expect(third.uri.host, '3234567890123456.gxifpxcr.vip'); }); test('passes Flutter shell request URL to H5 through query parameters', () { final line = AppConfig.createRandomH5Line( wildcardFactory: () => '1234567890123456', ); final uri = line.uri; expect(uri.queryParameters[AppConfig.flutterShellMarkerQueryKey], '1'); expect( uri.queryParameters[AppConfig.flutterShellUrlQueryKey], 'https://1234567890123456.albzyuxq.vip', ); expect( AppConfig.originForUrl(line.url), 'https://1234567890123456.albzyuxq.vip', ); }); test('restores a cached H5 line URL with the single line label', () { final line = AppConfig.h5LineFromUrl( 'https://1234567890123456.albzyuxq.vip/?flutter_shell=1', ); expect(line.label, '线路1'); expect(line.uri.host, '1234567890123456.albzyuxq.vip'); }); }