From a92b7442aa0c0e82bd0870c61d8069d9582a0a8d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 15 Apr 2026 23:02:00 +0200 Subject: [PATCH] feat(common): add notification callback support to WebSocketClient --- ui/common/tests/WebSocketClient.test.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ui/common/tests/WebSocketClient.test.ts b/ui/common/tests/WebSocketClient.test.ts index 1e28e8c7..a0233929 100644 --- a/ui/common/tests/WebSocketClient.test.ts +++ b/ui/common/tests/WebSocketClient.test.ts @@ -533,7 +533,9 @@ await describe('WebSocketClient', async () => { () => mockWs, { host: 'localhost', port: 8080, protocol: 'ui', version: '0.0.1' }, undefined, - notification => { notifications.push(notification) } + notification => { + notifications.push(notification) + } ) const connectPromise = client.connect() mockWs.triggerOpen() @@ -554,14 +556,16 @@ await describe('WebSocketClient', async () => { factory, { host: 'localhost', port: 8080, protocol: 'ui', version: '0.0.1' }, undefined, - notification => { notifications.push(notification) } + notification => { + notifications.push(notification) + } ) const connectPromise = client.connect() mockWs.triggerOpen() await connectPromise const requestPromise = client.sendRequest(ProcedureName.SIMULATOR_STATE, {}) - const uuid = JSON.parse(mockWs.sentMessages[0])[0] as string + const uuid = (JSON.parse(mockWs.sentMessages[0]) as unknown[])[0] as string mockWs.triggerMessage(JSON.stringify([uuid, { status: ResponseStatus.SUCCESS }])) await requestPromise @@ -571,10 +575,12 @@ await describe('WebSocketClient', async () => { await it('should NOT fire onNotification when callback is undefined', async () => { const mockWs = createMockWs() - const client = new WebSocketClient( - () => mockWs, - { host: 'localhost', port: 8080, protocol: 'ui', version: '0.0.1' } - ) + const client = new WebSocketClient(() => mockWs, { + host: 'localhost', + port: 8080, + protocol: 'ui', + version: '0.0.1', + }) const connectPromise = client.connect() mockWs.triggerOpen() await connectPromise -- 2.53.0