fix(ext/tests): router register_this_device test references current API

The router migrated from generate_device_keypair → register_device
(returns signing_public_key + deploy_public_key with private keys
staying internal to WASM). Test still mocked the old function under
the old return shape (public_key_hex / private_key_base64), so the
router's state.wasm.register_device() call failed with
"is not a function".

Updates the mock function name, response shape, and assertion to the
current contract. Test intent (treat the WASM return as a JS object,
not a JSON string) is preserved.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
adlee-was-taken
2026-05-30 21:16:14 -04:00
parent c9802ef392
commit 361f3b4368

View File

@@ -378,18 +378,18 @@ describe('setup tab exception scope', () => {
// --- register_this_device: wasm returns a JS object, not a JSON string --- // --- register_this_device: wasm returns a JS object, not a JSON string ---
// //
// The #[wasm_bindgen] binding for `generate_device_keypair` uses // The #[wasm_bindgen] binding for `register_device` uses `serde-wasm-bindgen`
// `serde-wasm-bindgen` and returns a plain JsValue (object), not a JSON // and returns a plain JsValue (object), not a JSON string. Calling
// string. Calling JSON.parse on it throws `SyntaxError: "[object Object]" // JSON.parse on it would throw `SyntaxError: "[object Object]" is not
// is not valid JSON`. This regression test pins the contract. // valid JSON`. This regression test pins that contract.
describe('register_this_device', () => { describe('register_this_device', () => {
it('treats generate_device_keypair() as an object, not a JSON string', async () => { it('treats register_device() return value as an object, not a JSON string', async () => {
const state = makeState(); const state = makeState();
state.gitHost = {} as never; state.gitHost = {} as never;
state.wasm.generate_device_keypair = () => ({ state.wasm.register_device = () => ({
public_key_hex: 'aa'.repeat(32), signing_public_key: 'aa'.repeat(32),
private_key_base64: 'AAAA', deploy_public_key: 'bb'.repeat(32),
}); });
vi.mocked(devices.addDevice).mockClear(); vi.mocked(devices.addDevice).mockClear();