feat: 优化 H5 URL 生成逻辑,移除品牌参数;更新测试用例以反映更改

This commit is contained in:
Booker
2026-05-26 20:09:38 +07:00
parent f47895d893
commit 2eef27a0e1
3 changed files with 20 additions and 411 deletions

View File

@@ -11,7 +11,7 @@ void main() {
);
});
test('loads the configured H5 root URL with shell branding', () {
test('loads the configured H5 root URL with shell launch params', () {
const logo = 'data:image/png;base64,abc+/=';
final uri = Uri.parse(
@@ -22,29 +22,29 @@ void main() {
expect(uri.host, 'h5-im.imharry.work');
expect(uri.path, '/');
expect(uri.queryParameters['flutter_shell'], '1');
expect(uri.queryParameters['shell_app_name'], 'Shell Test');
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)['shell_app_logo'], logo);
expect(Uri.splitQueryString(uri.fragment).containsKey('shell_app_logo'),
isFalse);
});
test('keeps shell branding when refreshing an H5 route URL', () {
const logo = 'data:image/png;base64,routeLogo+/=';
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',
appName: 'Shell Route',
appLogo: logo,
'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['shell_app_name'], 'Shell Route');
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)['shell_app_logo'], logo);
expect(Uri.splitQueryString(uri.fragment).containsKey('shell_app_logo'),
isFalse);
});
}