锁定壳未声明能力门禁
反查移动壳未声明方法测试必须由共享方法清单派生 反查桌面壳未声明方法测试必须由 Rust 能力清单派生
This commit is contained in:
@@ -2853,6 +2853,18 @@ function assertNativeShellCapabilityPlan() {
|
||||
'apps/desktop-shell/src-tauri/src/shell/events.rs',
|
||||
'utf8',
|
||||
);
|
||||
const mobileDispatchTestSource = fs.readFileSync(
|
||||
'apps/mobile-shell/src/host-bridge/dispatch.test.ts',
|
||||
'utf8',
|
||||
);
|
||||
const mobileBridgeTestSource = fs.readFileSync(
|
||||
'apps/mobile-shell/src/host-bridge/bridge.test.ts',
|
||||
'utf8',
|
||||
);
|
||||
const desktopDispatchSource = fs.readFileSync(
|
||||
'apps/desktop-shell/src-tauri/src/host_bridge/dispatch.rs',
|
||||
'utf8',
|
||||
);
|
||||
const wechatProtocol = requireCommonJsModule(
|
||||
'miniprogram/host-bridge/protocol.js',
|
||||
);
|
||||
@@ -2888,6 +2900,42 @@ function assertNativeShellCapabilityPlan() {
|
||||
sharedDesktopCapabilities,
|
||||
'desktop shell runtime capability profile',
|
||||
);
|
||||
for (const [source, label, snippets] of [
|
||||
[
|
||||
mobileDispatchTestSource,
|
||||
'mobile dispatch undeclared method test',
|
||||
[
|
||||
'HOST_BRIDGE_METHODS.filter',
|
||||
'!HOST_BRIDGE_EXPO_MOBILE_IOS_CAPABILITIES.includes(method)',
|
||||
"expect(response.error.code).toBe('unsupported_method')",
|
||||
],
|
||||
],
|
||||
[
|
||||
mobileBridgeTestSource,
|
||||
'mobile bridge undeclared method test',
|
||||
[
|
||||
'HOST_BRIDGE_METHODS.filter',
|
||||
'!HOST_BRIDGE_EXPO_MOBILE_IOS_CAPABILITIES.includes(method)',
|
||||
"expect(failedResponse.error.code).toBe('unsupported_method')",
|
||||
],
|
||||
],
|
||||
]) {
|
||||
for (const snippet of snippets) {
|
||||
if (!source.includes(snippet)) {
|
||||
throw new Error(`${label} must derive unsupported methods from shared method list`);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const snippet of [
|
||||
'HOST_BRIDGE_METHODS\n .iter()',
|
||||
'.filter(|method| !desktop_capabilities.contains(method))',
|
||||
'let response = resolve_host_bridge_request(request(method));',
|
||||
'assert_eq!(error.code, "unsupported_method");',
|
||||
]) {
|
||||
if (!desktopDispatchSource.includes(snippet)) {
|
||||
throw new Error('desktop dispatch test must derive unsupported methods from Rust capability list');
|
||||
}
|
||||
}
|
||||
|
||||
assertSameList(
|
||||
extractDocumentMethodTable(planSource),
|
||||
|
||||
Reference in New Issue
Block a user