feat: 更新 H5 线路配置逻辑,添加默认线路处理和相关单元测试
This commit is contained in:
@@ -20,6 +20,30 @@ void main() {
|
||||
expect(Uri.parse(lines.first.url).path, '/');
|
||||
});
|
||||
|
||||
test('uses current non-local service origin as default H5 line', () {
|
||||
final urls = AppConfig.defaultH5LineUrlsForBaseUri(
|
||||
Uri.parse('https://app.example.com/shell/index.html?from=local#hash'),
|
||||
);
|
||||
|
||||
expect(urls, ['https://app.example.com/']);
|
||||
});
|
||||
|
||||
test('preserves current service port when building default H5 line', () {
|
||||
final urls = AppConfig.defaultH5LineUrlsForBaseUri(
|
||||
Uri.parse('https://chat.example.com:8443/app/'),
|
||||
);
|
||||
|
||||
expect(urls, ['https://chat.example.com:8443/']);
|
||||
});
|
||||
|
||||
test('keeps fixed bootstrap H5 line for local browser access', () {
|
||||
final urls = AppConfig.defaultH5LineUrlsForBaseUri(
|
||||
Uri.parse('http://localhost:3000/'),
|
||||
);
|
||||
|
||||
expect(urls, ['https://h5-test.imharry.work/']);
|
||||
});
|
||||
|
||||
test('uses fixed client config query parameters', () {
|
||||
expect(AppConfig.clientConfigQueryPayload, {
|
||||
'device': 'h5',
|
||||
@@ -31,6 +55,20 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('builds client config query APIs from current service origin', () {
|
||||
final uris = AppConfig.clientConfigQueryUrisForHomeUri(
|
||||
Uri.parse('https://app.example.com/app/index.html?from=local#hash'),
|
||||
);
|
||||
|
||||
expect(
|
||||
uris.map((uri) => uri.toString()),
|
||||
[
|
||||
'https://app.example.com/client_config/query',
|
||||
'https://app.example.com/api/user/client_config/query',
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
test('splits client config resourceUrl into indexed H5 lines', () {
|
||||
final lines = AppConfig.h5LinesFromResourceUrl(
|
||||
'line-one.example\nhttps://line-two.example/app\n\nline-three.example',
|
||||
|
||||
Reference in New Issue
Block a user