Skip to content

Commit 03be5e7

Browse files
committed
test: add debug logging to failing tests
Add console.log statements to test/web-server.test.ts and test/pty-echo.test.ts to output session details, response statuses, and other debug information to help diagnose PTY spawning issues in CI environment.
1 parent 4e1093f commit 03be5e7

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

test/pty-echo.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ describe('PTY Echo Behavior', () => {
3535
parentSessionId: 'test',
3636
})
3737

38+
console.log('Echo session:', session)
39+
3840
// Wait for PTY to initialize and show prompt
3941
await new Promise((resolve) => setTimeout(resolve, 200))
4042

4143
// Send test input
4244
const success = manager.write(session.id, 'a')
45+
console.log('Write success:', success)
4346
expect(success).toBe(true)
4447

4548
// Wait for echo to be processed
@@ -50,6 +53,8 @@ describe('PTY Echo Behavior', () => {
5053

5154
// Verify echo occurred
5255
const allOutput = receivedOutputs.join('')
56+
console.log('All output:', allOutput)
57+
console.log('Received outputs:', receivedOutputs)
5358
expect(allOutput).toContain('a')
5459

5560
// Should have received some output (prompt + echo)

test/web-server.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,17 @@ describe('Web Server', () => {
137137
parentSessionId: 'test',
138138
})
139139

140+
console.log('Created session:', session)
141+
140142
// Wait for PTY to start
141143
await new Promise((resolve) => setTimeout(resolve, 100))
142144

143145
const response = await fetch(`${serverUrl}/api/sessions/${session.id}`)
146+
console.log('Session response status:', response.status)
144147
expect(response.status).toBe(200)
145148

146149
const sessionData = await response.json()
150+
console.log('Session data:', sessionData)
147151
expect(sessionData.id).toBe(session.id)
148152
expect(sessionData.command).toBe('cat')
149153
expect(sessionData.args).toEqual([])
@@ -152,6 +156,7 @@ describe('Web Server', () => {
152156
it('should return 404 for non-existent session', async () => {
153157
const nonexistentId = `nonexistent-${Math.random().toString(36).substr(2, 9)}`
154158
const response = await fetch(`${serverUrl}/api/sessions/${nonexistentId}`)
159+
console.log('Non-existent response status:', response.status)
155160
expect(response.status).toBe(404)
156161
})
157162

@@ -164,6 +169,8 @@ describe('Web Server', () => {
164169
parentSessionId: 'test',
165170
})
166171

172+
console.log('Input session:', session)
173+
167174
// Wait for PTY to start
168175
await new Promise((resolve) => setTimeout(resolve, 100))
169176

@@ -173,6 +180,8 @@ describe('Web Server', () => {
173180
body: JSON.stringify({ data: 'test input\n' }),
174181
})
175182

183+
console.log('Input response status:', response.status)
184+
176185
// Should return success
177186
expect(response.status).toBe(200)
178187
const result = await response.json()
@@ -190,13 +199,17 @@ describe('Web Server', () => {
190199
parentSessionId: 'test',
191200
})
192201

202+
console.log('Kill session:', session)
203+
193204
// Wait for PTY to start
194205
await new Promise((resolve) => setTimeout(resolve, 100))
195206

196207
const response = await fetch(`${serverUrl}/api/sessions/${session.id}/kill`, {
197208
method: 'POST',
198209
})
199210

211+
console.log('Kill response status:', response.status)
212+
200213
expect(response.status).toBe(200)
201214
const result = await response.json()
202215
expect(result.success).toBe(true)
@@ -211,10 +224,13 @@ describe('Web Server', () => {
211224
parentSessionId: 'test-output',
212225
})
213226

227+
console.log('Output session:', session)
228+
214229
// Wait a bit for output to be captured
215230
await new Promise((resolve) => setTimeout(resolve, 100))
216231

217232
const response = await fetch(`${serverUrl}/api/sessions/${session.id}/buffer/raw`)
233+
console.log('Buffer response status:', response.status)
218234
expect(response.status).toBe(200)
219235

220236
const bufferData = await response.json()

0 commit comments

Comments
 (0)