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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user