9eee997731
移动壳 HostBridge 协议名和版本改为共享契约常量 移动壳配置检查锁定主动导航和 deep link 宿主上下文补写 桌面壳主窗口 capability 移除 Tauri core 默认权限 桌面壳配置检查拒绝 core 默认权限和插件权限外露 更新原生壳方案与共享决策记录
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
|
|
import {
|
|
HOST_BRIDGE_PROTOCOL,
|
|
HOST_BRIDGE_VERSION,
|
|
} from '../../../../packages/shared/src/contracts/hostBridge';
|
|
import { parseMobileWebViewHistoryStateMessage } from './webViewHistory';
|
|
|
|
describe('parseMobileWebViewHistoryStateMessage', () => {
|
|
test('解析移动 WebView H5 路由栈状态消息', () => {
|
|
expect(
|
|
parseMobileWebViewHistoryStateMessage(
|
|
JSON.stringify({
|
|
type: 'genarrative.mobile.historyState',
|
|
canGoBack: true,
|
|
}),
|
|
),
|
|
).toEqual({
|
|
canGoBack: true,
|
|
});
|
|
expect(
|
|
parseMobileWebViewHistoryStateMessage(
|
|
JSON.stringify({
|
|
type: 'genarrative.mobile.historyState',
|
|
canGoBack: false,
|
|
}),
|
|
),
|
|
).toEqual({
|
|
canGoBack: false,
|
|
});
|
|
});
|
|
|
|
test('忽略非移动路由状态消息', () => {
|
|
expect(parseMobileWebViewHistoryStateMessage('not-json')).toBeNull();
|
|
expect(
|
|
parseMobileWebViewHistoryStateMessage(
|
|
JSON.stringify({
|
|
bridge: HOST_BRIDGE_PROTOCOL,
|
|
version: HOST_BRIDGE_VERSION,
|
|
method: 'host.getRuntime',
|
|
}),
|
|
),
|
|
).toBeNull();
|
|
expect(
|
|
parseMobileWebViewHistoryStateMessage(
|
|
JSON.stringify({
|
|
type: 'genarrative.mobile.historyState',
|
|
canGoBack: 'true',
|
|
}),
|
|
),
|
|
).toBeNull();
|
|
});
|
|
});
|