Skip to content

Commit e4058e0

Browse files
committed
Improve port diagnostics and keyboard test naming
1 parent d037034 commit e4058e0

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

cli/src/__tests__/e2e/test-db-utils.ts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ export function generateContainerName(describeId: string): string {
2727
* Find an available port starting from the given base port
2828
*/
2929
export function findAvailablePort(basePort: number = 5433): number {
30-
// Try ports starting from basePort
31-
for (let port = basePort; port < basePort + 100; port++) {
30+
for (let port = basePort; port < basePort + 200; port++) {
3231
try {
3332
execSync(`lsof -i:${port}`, { stdio: 'pipe' })
3433
// Port is in use, try next
@@ -60,8 +59,11 @@ export async function createE2EDatabase(describeId: string): Promise<E2EDatabase
6059
}
6160
)
6261
} catch (error) {
62+
const logs = safeContainerLogs(containerName)
6363
const errorMessage = error instanceof Error ? error.message : String(error)
64-
throw new Error(`Failed to start e2e database container: ${errorMessage}`)
64+
throw new Error(
65+
`Failed to start e2e database container: ${errorMessage}${logs ? `\n\nContainer logs:\n${logs}` : ''}`,
66+
)
6567
}
6668

6769
// Wait for the database to be ready
@@ -120,7 +122,12 @@ async function waitForDatabase(port: number, timeoutMs: number = 30000): Promise
120122
}
121123
}
122124

123-
throw new Error(`Database did not become ready within ${timeoutMs}ms`)
125+
const logs = safeContainerLogsByPort(port)
126+
throw new Error(
127+
`Database did not become ready within ${timeoutMs}ms on port ${port}${
128+
logs ? `\n\nContainer logs:\n${logs}` : ''
129+
}`,
130+
)
124131
}
125132

126133
/**
@@ -260,6 +267,28 @@ function sleep(ms: number): Promise<void> {
260267
return new Promise((resolve) => setTimeout(resolve, ms))
261268
}
262269

270+
function safeContainerLogs(containerName: string): string | null {
271+
try {
272+
return execSync(`docker logs ${containerName}`, { encoding: 'utf8', stdio: 'pipe' })
273+
} catch {
274+
return null
275+
}
276+
}
277+
278+
function safeContainerLogsByPort(port: number): string | null {
279+
try {
280+
const name = execSync(
281+
`docker ps --format '{{.Names}}' --filter "publish=${port}" --filter "name=manicode-e2e-"`,
282+
{ encoding: 'utf8', stdio: 'pipe' },
283+
)
284+
const containerName = name.trim().split('\n').filter(Boolean)[0]
285+
if (!containerName) return null
286+
return safeContainerLogs(containerName)
287+
} catch {
288+
return null
289+
}
290+
}
291+
263292
/**
264293
* Test user credentials - matches seed.e2e.sql
265294
*/

cli/src/utils/__tests__/keyboard-actions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ describe('resolveChatKeyboardAction', () => {
247247
})
248248
})
249249

250-
test('enter submits (no menu intercept)', () => {
250+
test('enter selects in slash menu', () => {
251251
expect(resolveChatKeyboardAction(enterKey, slashMenuState)).toEqual({
252252
type: 'slash-menu-select',
253253
})

0 commit comments

Comments
 (0)