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('loads the configured H5 root URL with shell launch params', () { const logo = 'data:image/png;base64,abc+/='; final uri = Uri.parse( AppConfig.homeUrl(appName: 'Shell Test', appLogo: logo), ); expect(uri.scheme, 'https'); expect(uri.host, 'h5-im.imharry.work'); expect(uri.path, '/'); expect(uri.queryParameters['flutter_shell'], '1'); expect(uri.queryParameters.containsKey('shell_app_name'), isFalse); expect(uri.queryParameters.containsKey('shell_app_logo'), isFalse); expect(uri.queryParameters['shell_cache_bust'], isNotEmpty); expect(uri.toString(), isNot(contains('%25'))); expect(Uri.splitQueryString(uri.fragment).containsKey('shell_app_logo'), isFalse); }); test('refreshes an H5 route URL without adding branding to the URL', () { final uri = Uri.parse( AppConfig.withFreshShellParams( 'https://h5-im.imharry.work/login?from=runtime&shell_app_name=Old' '#shell_app_logo=old', ), ); expect(uri.path, '/login'); expect(uri.queryParameters['from'], 'runtime'); expect(uri.queryParameters['flutter_shell'], '1'); expect(uri.queryParameters.containsKey('shell_app_name'), isFalse); expect(uri.queryParameters.containsKey('shell_app_logo'), isFalse); expect(uri.queryParameters['shell_cache_bust'], isNotEmpty); expect(Uri.splitQueryString(uri.fragment).containsKey('shell_app_logo'), isFalse); }); }