Skip to content

Commit 3b7f88c

Browse files
committed
Harden CLI e2e setup for CI
1 parent 9cbdf1d commit 3b7f88c

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

cli/src/__tests__/e2e/full-stack.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ describe('E2E: Chat Interaction', () => {
5656
console.log('\n🚀 Starting E2E test context for Chat Interaction...')
5757
ctx = await createE2ETestContext('chat-interaction')
5858
console.log('✅ E2E test context ready\n')
59-
})
59+
}, TIMEOUT_MS)
6060

6161
afterAll(async () => {
6262
console.log('\n🧹 Cleaning up E2E test context...')
6363
await ctx?.cleanup()
6464
console.log('✅ Cleanup complete\n')
65-
})
65+
}, TIMEOUT_MS)
6666

6767
test(
6868
'can start CLI and see welcome message',
@@ -122,13 +122,13 @@ describe('E2E: Slash Commands', () => {
122122
console.log('\n🚀 Starting E2E test context for Slash Commands...')
123123
ctx = await createE2ETestContext('slash-commands')
124124
console.log('✅ E2E test context ready\n')
125-
})
125+
}, TIMEOUT_MS)
126126

127127
afterAll(async () => {
128128
console.log('\n🧹 Cleaning up E2E test context...')
129129
await ctx?.cleanup()
130130
console.log('✅ Cleanup complete\n')
131-
})
131+
}, TIMEOUT_MS)
132132

133133
test(
134134
'/new command clears conversation',
@@ -194,13 +194,13 @@ describe('E2E: User Authentication', () => {
194194
console.log('\n🚀 Starting E2E test context for User Authentication...')
195195
ctx = await createE2ETestContext('user-auth')
196196
console.log('✅ E2E test context ready\n')
197-
})
197+
}, TIMEOUT_MS)
198198

199199
afterAll(async () => {
200200
console.log('\n🧹 Cleaning up E2E test context...')
201201
await ctx?.cleanup()
202202
console.log('✅ Cleanup complete\n')
203-
})
203+
}, TIMEOUT_MS)
204204

205205
test(
206206
'authenticated user can access CLI',
@@ -257,13 +257,13 @@ describe('E2E: Agent Modes', () => {
257257
console.log('\n🚀 Starting E2E test context for Agent Modes...')
258258
ctx = await createE2ETestContext('agent-modes')
259259
console.log('✅ E2E test context ready\n')
260-
})
260+
}, TIMEOUT_MS)
261261

262262
afterAll(async () => {
263263
console.log('\n🧹 Cleaning up E2E test context...')
264264
await ctx?.cleanup()
265265
console.log('✅ Cleanup complete\n')
266-
})
266+
}, TIMEOUT_MS)
267267

268268
test(
269269
'can switch to lite mode',
@@ -332,13 +332,13 @@ describe('E2E: Additional Slash Commands', () => {
332332
)
333333
ctx = await createE2ETestContext('additional-slash-commands')
334334
console.log('✅ E2E test context ready\n')
335-
})
335+
}, TIMEOUT_MS)
336336

337337
afterAll(async () => {
338338
console.log('\n🧹 Cleaning up E2E test context...')
339339
await ctx?.cleanup()
340340
console.log('✅ Cleanup complete\n')
341-
})
341+
}, TIMEOUT_MS)
342342

343343
test(
344344
'/init command shows project configuration prompt',
@@ -516,13 +516,13 @@ describe('E2E: CLI Flags', () => {
516516
console.log('\n🚀 Starting E2E test context for CLI Flags...')
517517
ctx = await createE2ETestContext('cli-flags')
518518
console.log('✅ E2E test context ready\n')
519-
})
519+
}, TIMEOUT_MS)
520520

521521
afterAll(async () => {
522522
console.log('\n🧹 Cleaning up E2E test context...')
523523
await ctx?.cleanup()
524524
console.log('✅ Cleanup complete\n')
525-
})
525+
}, TIMEOUT_MS)
526526

527527
test(
528528
'--help flag shows usage information',
@@ -618,13 +618,13 @@ describe('E2E: Keyboard Interactions', () => {
618618
console.log('\n🚀 Starting E2E test context for Keyboard Interactions...')
619619
ctx = await createE2ETestContext('keyboard-interactions')
620620
console.log('✅ E2E test context ready\n')
621-
})
621+
}, TIMEOUT_MS)
622622

623623
afterAll(async () => {
624624
console.log('\n🧹 Cleaning up E2E test context...')
625625
await ctx?.cleanup()
626626
console.log('✅ Cleanup complete\n')
627-
})
627+
}, TIMEOUT_MS)
628628

629629
test(
630630
'Ctrl+C once shows exit warning',
@@ -760,13 +760,13 @@ describe('E2E: Error Scenarios', () => {
760760
console.log('\n🚀 Starting E2E test context for Error Scenarios...')
761761
ctx = await createE2ETestContext('error-scenarios')
762762
console.log('✅ E2E test context ready\n')
763-
})
763+
}, TIMEOUT_MS)
764764

765765
afterAll(async () => {
766766
console.log('\n🧹 Cleaning up E2E test context...')
767767
await ctx?.cleanup()
768768
console.log('✅ Cleanup complete\n')
769-
})
769+
}, TIMEOUT_MS)
770770

771771
test(
772772
'low credits user sees warning or credit info',

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,17 @@ export interface E2ETestContext {
181181
* Create a full e2e test context with database, server, and CLI utilities
182182
*/
183183
export async function createE2ETestContext(describeId: string): Promise<E2ETestContext> {
184-
const { createE2EDatabase, destroyE2EDatabase, E2E_TEST_USERS } = await import('./test-db-utils')
185-
const { startE2EServer, stopE2EServer } = await import('./test-server-utils')
184+
const {
185+
createE2EDatabase,
186+
destroyE2EDatabase,
187+
cleanupOrphanedContainers,
188+
E2E_TEST_USERS,
189+
} = await import('./test-db-utils')
190+
const { startE2EServer, stopE2EServer, cleanupOrphanedServers } = await import('./test-server-utils')
191+
192+
// Clean up any leftovers from previous runs (important on CI retries)
193+
cleanupOrphanedContainers()
194+
cleanupOrphanedServers()
186195

187196
// Start database
188197
const db = await createE2EDatabase(describeId)

0 commit comments

Comments
 (0)