From 361f3b4368d51b017d76a8f58f39fed6d8f685e0 Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Sat, 30 May 2026 21:16:14 -0400 Subject: [PATCH] fix(ext/tests): router register_this_device test references current API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../router/__tests__/router.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/extension/src/service-worker/router/__tests__/router.test.ts b/extension/src/service-worker/router/__tests__/router.test.ts index 117610f..0c7dbbe 100644 --- a/extension/src/service-worker/router/__tests__/router.test.ts +++ b/extension/src/service-worker/router/__tests__/router.test.ts @@ -378,18 +378,18 @@ describe('setup tab exception scope', () => { // --- register_this_device: wasm returns a JS object, not a JSON string --- // -// The #[wasm_bindgen] binding for `generate_device_keypair` uses -// `serde-wasm-bindgen` and returns a plain JsValue (object), not a JSON -// string. Calling JSON.parse on it throws `SyntaxError: "[object Object]" -// is not valid JSON`. This regression test pins the contract. +// The #[wasm_bindgen] binding for `register_device` uses `serde-wasm-bindgen` +// and returns a plain JsValue (object), not a JSON string. Calling +// JSON.parse on it would throw `SyntaxError: "[object Object]" is not +// valid JSON`. This regression test pins that contract. 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(); state.gitHost = {} as never; - state.wasm.generate_device_keypair = () => ({ - public_key_hex: 'aa'.repeat(32), - private_key_base64: 'AAAA', + state.wasm.register_device = () => ({ + signing_public_key: 'aa'.repeat(32), + deploy_public_key: 'bb'.repeat(32), }); vi.mocked(devices.addDevice).mockClear();