补齐移动壳协议单测

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

原生壳结构门禁登记移动协议测试

宿主壳文档和共享决策同步协议测试边界
This commit is contained in:
2026-06-20 08:44:37 +08:00
parent e5970a4452
commit 8c19700664
6 changed files with 146 additions and 4 deletions
@@ -81,6 +81,11 @@ const notificationsPath = new URL('../src/host-bridge/notifications.ts', import.
const notificationsSource = fs.readFileSync(notificationsPath, 'utf8');
const protocolPath = new URL('../src/host-bridge/protocol.ts', import.meta.url);
const protocolSource = fs.readFileSync(protocolPath, 'utf8');
const protocolTestPath = new URL(
'../src/host-bridge/protocol.test.ts',
import.meta.url,
);
const protocolTestSource = fs.readFileSync(protocolTestPath, 'utf8');
const scannerPath = new URL('../src/host-bridge/scanner.ts', import.meta.url);
const scannerSource = fs.readFileSync(scannerPath, 'utf8');
const scannerTestPath = new URL(
@@ -866,6 +871,25 @@ for (const expectedErrorCode of [
);
}
}
for (const snippet of [
'parseRequest',
'isHostBridgeRequest',
'normalizeMobileHostBridgeError',
'unsupported',
'invalidRequest',
'ok(request(), { shell: ',
'failure(request(), invalidRequest(',
"request({ id: 'bad\\u0000id' })",
"request({ id: 'x'.repeat(129) })",
"method: 'unknown.method'",
"code: 'private_error'",
"nativeStack: 'hidden'",
"message: 'mobile host bridge request failed'",
]) {
if (!protocolTestSource.includes(snippet)) {
throw new Error(`mobile shell protocol helper test missing ${snippet}`);
}
}
if (
!protocolSource.includes('HOST_BRIDGE_ERROR_CODES.has(') ||
!protocolSource.includes('mobile host bridge request failed')