diff --git a/scripts/check-native-shells.mjs b/scripts/check-native-shells.mjs index 300b2bdcc..049678edd 100644 --- a/scripts/check-native-shells.mjs +++ b/scripts/check-native-shells.mjs @@ -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),