Skip to content

Commit 7111081

Browse files
committed
test(cli): fix lifecycle test structure — single top-level describe
1 parent a5c1a4d commit 7111081

3 files changed

Lines changed: 15 additions & 30 deletions

File tree

ui/cli/src/client/ws-adapter.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,43 +58,43 @@ export const createWsAdapter = (ws: WsWebSocket): WebSocketLike => {
5858
}
5959

6060
return {
61-
close(code?: number, reason?: string): void {
61+
close (code?: number, reason?: string): void {
6262
ws.close(code, reason)
6363
},
64-
get onclose(): ((event: { code: number; reason: string }) => void) | null {
64+
get onclose (): ((event: { code: number; reason: string }) => void) | null {
6565
return oncloseCallback
6666
},
6767

68-
set onclose(callback: ((event: { code: number; reason: string }) => void) | null) {
68+
set onclose (callback: ((event: { code: number; reason: string }) => void) | null) {
6969
oncloseCallback = callback
7070
},
71-
get onerror(): ((event: { error: unknown; message: string }) => void) | null {
71+
get onerror (): ((event: { error: unknown; message: string }) => void) | null {
7272
return onerrorCallback
7373
},
7474

75-
set onerror(callback: ((event: { error: unknown; message: string }) => void) | null) {
75+
set onerror (callback: ((event: { error: unknown; message: string }) => void) | null) {
7676
onerrorCallback = callback
7777
},
78-
get onmessage(): ((event: { data: string }) => void) | null {
78+
get onmessage (): ((event: { data: string }) => void) | null {
7979
return onmessageCallback
8080
},
8181

82-
set onmessage(callback: ((event: { data: string }) => void) | null) {
82+
set onmessage (callback: ((event: { data: string }) => void) | null) {
8383
onmessageCallback = callback
8484
},
85-
get onopen(): (() => void) | null {
85+
get onopen (): (() => void) | null {
8686
return onopenCallback
8787
},
8888

89-
set onopen(callback: (() => void) | null) {
89+
set onopen (callback: (() => void) | null) {
9090
onopenCallback = callback
9191
},
9292

93-
get readyState(): WebSocketReadyState {
93+
get readyState (): WebSocketReadyState {
9494
return ws.readyState as WebSocketReadyState
9595
},
9696

97-
send(data: string): void {
97+
send (data: string): void {
9898
ws.send(data)
9999
},
100100
}

ui/cli/tests/lifecycle.test.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { describe, it } from 'node:test'
44
import { ConnectionError } from '../src/client/errors.js'
55
import { executeCommand } from '../src/client/lifecycle.js'
66

7-
await describe('CLI error types', async () => {
7+
await describe('lifecycle', async () => {
88
await it('should create ConnectionError with url', () => {
99
const err = new ConnectionError('ws://localhost:8080')
1010
assert.strictEqual(err.name, 'ConnectionError')
@@ -17,23 +17,8 @@ await describe('CLI error types', async () => {
1717
const err = new ConnectionError('ws://localhost:8080', cause)
1818
assert.strictEqual(err.cause, cause)
1919
})
20-
})
21-
22-
await describe('lifecycle deadline sharing', async () => {
23-
await it('should compute remaining timeout after connect phase', () => {
24-
// This test verifies the deadline sharing logic by checking that:
25-
// 1. A budget is computed from timeoutMs or default
26-
// 2. startTime is recorded before connect
27-
// 3. remaining is computed as budget - elapsed
28-
// 4. remaining is passed to sendRequest
29-
30-
// We verify this indirectly by checking that the code compiles and
31-
// the lifecycle module exports executeCommand with the correct signature
32-
assert.ok(typeof executeCommand === 'function')
3320

34-
// The actual deadline sharing is tested via integration:
35-
// - WebSocketClient.sendRequest accepts optional timeoutMs parameter
36-
// - lifecycle.ts passes remaining budget to sendRequest
37-
// Both are verified by their respective unit tests
21+
await it('should export executeCommand function', () => {
22+
assert.strictEqual(typeof executeCommand, 'function')
3823
})
3924
})

ui/common/tests/WebSocketClient.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ await describe('WebSocketClient', async () => {
382382
assert.ok(error.message.includes('timed out'))
383383
assert.ok(error.message.includes('50ms'))
384384
// Should timeout around 50ms, definitely not 60s
385-
assert.ok(elapsed < 500, `Expected timeout within 500ms, got ${elapsed}ms`)
385+
assert.ok(elapsed < 500, `Expected timeout within 500ms, got ${elapsed.toString()}ms`)
386386
return true
387387
}
388388
)

0 commit comments

Comments
 (0)