Refactor widget tests for H5 line generation and validation

- Simplified tests for H5 line creation, focusing on single line generation with a numeric 16-digit label.
- Updated assertions to validate the generated H5 line's label and URI structure.
- Removed redundant tests related to default H5 line URLs and local access, consolidating functionality into fewer tests.
- Added new tests to ensure correct URL generation from configured fallback order and query parameter handling.
- Enhanced test coverage for restoring cached H5 line URLs and validating their structure.
This commit is contained in:
Booker
2026-06-06 03:48:20 +07:00
parent 4b652a090d
commit 15d767100a
4 changed files with 381 additions and 1073 deletions

View File

@@ -1,17 +1,11 @@
# im_webview_app
Flutter WebView 套壳 App启动后会请求 `/client_config/query` 获取 H5 线路配置,并加载第一条可用线路
Flutter WebView 套壳 App启动时只会生成并加载一个 H5 URL如果当前 URL 探测或加载失败,壳层会重新生成下一个 URL 并替换当前 WebView项目运行过程中始终只持有一个 H5 URL
默认情况下,非本地 Web 访问会使用当前服务地址的 origin 作为 H5 线路和接口域名,例如访问 `https://app.example.com/app/` 时会请求 `https://app.example.com/client_config/query`。本地访问(如 `localhost``127.0.0.1`)继续使用固定兜底域名 `https://h5-test.imharry.work/`
默认 URL 来自代码中的泛域名模板,会生成 16 位数字子域名,并通过查询参数把 Flutter 壳请求地址传给 H5
## H5 线路切换
线路切换在 Flutter 套壳层完成。远程配置不可用时,会先使用启动兜底线路;也可以在打包时覆盖启动线路或配置接口地址:
```bash
flutter build apk --release --dart-define=H5_LINE_URLS=https://h5-one.example/,https://h5-two.example/
flutter build apk --release --dart-define=CLIENT_CONFIG_QUERY_URL=https://api.example.com/client_config/query
flutter build apk --release --dart-define=BOOTSTRAP_H5_LINE_URL=https://h5-one.example/
```text
https://1234567890123456.albzyuxq.vip/?flutter_shell=1&flutter_shell_url=https%3A%2F%2F1234567890123456.albzyuxq.vip
```
## 本地打包