补齐移动壳扫码单测

移动壳 scanner helper 增加独立单测覆盖

原生壳结构门禁登记移动扫码测试

宿主壳文档和共享决策同步扫码测试边界
This commit is contained in:
2026-06-20 08:31:49 +08:00
parent fb02e89fa3
commit cb926835b3
6 changed files with 179 additions and 5 deletions
@@ -78,6 +78,11 @@ const protocolPath = new URL('../src/host-bridge/protocol.ts', import.meta.url);
const protocolSource = fs.readFileSync(protocolPath, 'utf8');
const scannerPath = new URL('../src/host-bridge/scanner.ts', import.meta.url);
const scannerSource = fs.readFileSync(scannerPath, 'utf8');
const scannerTestPath = new URL(
'../src/host-bridge/scanner.test.ts',
import.meta.url,
);
const scannerTestSource = fs.readFileSync(scannerTestPath, 'utf8');
const hostBridgeRuntimePath = new URL('../src/host-bridge/runtime.ts', import.meta.url);
const hostBridgeRuntimeSource = fs.readFileSync(hostBridgeRuntimePath, 'utf8');
const hostBridgeRuntimeTestPath = new URL(
@@ -2092,6 +2097,24 @@ for (const scannerSnippet of [
throw new Error(`mobile shell QR scanner module missing ${scannerSnippet}`);
}
}
for (const scannerTestSnippet of [
'subscribeQrScannerState',
'scanQrCode',
'scanMobileHostBridgeQrCode',
'completeQrCodeScan',
'cancelQrCodeScan',
'failQrCodeScan',
'qr scanner already active',
'camera permission denied',
'qr scan cancelled',
'PZ-00000001',
]) {
if (!scannerTestSource.includes(scannerTestSnippet)) {
throw new Error(
`mobile shell QR scanner helper test missing ${scannerTestSnippet}`,
);
}
}
const capabilityQuerySnippet = "capabilities: MOBILE_HOST_CAPABILITIES";
if (shellAppSource.includes(capabilityQuerySnippet)) {