Skip to content

Commit 4c003aa

Browse files
committed
Tighten E2E assertions and require API key for SDK e2e
1 parent e48eb34 commit 4c003aa

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ if (!sdkBuilt) {
2121
describe.skip('CLI UI Tests', () => {
2222
test('skipped because SDK is not built', () => {})
2323
})
24+
throw new Error('Skipping CLI UI E2E: SDK not built')
2425
}
2526

2627
let cliEnv: Record<string, string> = {}
@@ -274,8 +275,13 @@ describe('CLI UI Tests', () => {
274275
// Give time for process to exit
275276
await sleep(1000)
276277

277-
// Session should have terminated or show exit message
278-
// The test passes if we got here without hanging
278+
const text = await session.text()
279+
const exited =
280+
text.toLowerCase().includes('exit') ||
281+
text.toLowerCase().includes('goodbye') ||
282+
text.toLowerCase().includes('quit') ||
283+
text.trim().length === 0
284+
expect(exited).toBe(true)
279285
} finally {
280286
session.close()
281287
}

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,17 @@ describe('E2E: Keyboard Interactions', () => {
668668
await session.cli.press(['ctrl', 'c'])
669669
await sleep(1500)
670670

671-
// CLI should have exited or show exit state
672-
// Test passes if we got here without hanging
673-
expect(true).toBe(true)
671+
// Either the CLI exits or remains responsive to further input
672+
await session.cli.type('ping')
673+
await sleep(500)
674+
const text = await session.cli.text()
675+
const exited =
676+
text.toLowerCase().includes('exit') ||
677+
text.toLowerCase().includes('goodbye') ||
678+
text.toLowerCase().includes('quit') ||
679+
text.trim().length === 0
680+
const responsive = text.toLowerCase().includes('ping')
681+
expect(exited || responsive).toBe(true)
674682
},
675683
TIMEOUT_MS,
676684
)
@@ -725,9 +733,8 @@ describe('E2E: Keyboard Interactions', () => {
725733

726734
// Text should be modified ("hel" instead of "hello")
727735
text = await session.cli.text()
728-
const hasModifiedText =
729-
text.includes('hel') || !text.includes('hello') || text.length > 0
730-
expect(hasModifiedText).toBe(true)
736+
expect(text.includes('hel')).toBe(true)
737+
expect(text.includes('hello')).toBe(false)
731738
},
732739
TIMEOUT_MS,
733740
)
@@ -747,10 +754,11 @@ describe('E2E: Keyboard Interactions', () => {
747754
await session.cli.press('escape')
748755
await sleep(500)
749756

750-
// Input should be cleared or escape should have an effect
757+
// Ensure input remains responsive after escape
758+
await session.cli.type('x')
759+
await sleep(300)
751760
const text = await session.cli.text()
752-
// The behavior depends on implementation - test passes if CLI is responsive
753-
expect(text.length).toBeGreaterThanOrEqual(0)
761+
expect(text).toContain('x')
754762
},
755763
TIMEOUT_MS,
756764
)
@@ -811,15 +819,13 @@ describe('E2E: Error Scenarios', () => {
811819
await sleep(1500)
812820

813821
const text = await session.cli.text()
814-
// Should show error, unknown command message, or suggestions
815822
const hasErrorOrSuggestion =
816823
text.toLowerCase().includes('unknown') ||
817824
text.toLowerCase().includes('invalid') ||
818825
text.toLowerCase().includes('error') ||
819826
text.toLowerCase().includes('not found') ||
820827
text.toLowerCase().includes('did you mean') ||
821-
text.includes('/invalidcommandxyz') ||
822-
text.length > 0 // At minimum, CLI should still be running
828+
text.includes('/invalidcommandxyz')
823829
expect(hasErrorOrSuggestion).toBe(true)
824830
},
825831
TIMEOUT_MS,
@@ -864,9 +870,7 @@ describe('E2E: Error Scenarios', () => {
864870

865871
const text = await session.cli.text()
866872
// CLI should handle long input without crashing
867-
// May truncate or wrap, but should contain some of the message
868-
const hasLongInput = text.includes('a') || text.length > 0
869-
expect(hasLongInput).toBe(true)
873+
expect(text).toContain('a')
870874
},
871875
TIMEOUT_MS,
872876
)
@@ -883,12 +887,8 @@ describe('E2E: Error Scenarios', () => {
883887
await sleep(500)
884888

885889
const text = await session.cli.text()
886-
// Should contain at least part of the message
887890
const hasSpecialChars =
888-
text.includes('Hello') ||
889-
text.includes('world') ||
890-
text.includes('test') ||
891-
text.length > 0
891+
text.includes('Hello') || text.includes('world') || text.includes('test')
892892
expect(hasSpecialChars).toBe(true)
893893
},
894894
TIMEOUT_MS,

sdk/e2e/features/knowledge-files.e2e.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ describe('Features: Knowledge Files', () => {
2323
beforeAll(() => {
2424
apiKey = process.env.CODEBUFF_API_KEY ?? null
2525
if (!apiKey) {
26-
// Skip gracefully if no API key is configured
27-
test.skip('CODEBUFF_API_KEY is required for knowledge files e2e')
28-
return
26+
throw new Error('CODEBUFF_API_KEY is required for knowledge files e2e')
2927
}
3028
client = new CodebuffClient({ apiKey: getApiKey() })
3129
})

sdk/e2e/features/project-files.e2e.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ describe('Features: Project Files', () => {
2424
beforeAll(() => {
2525
apiKey = process.env.CODEBUFF_API_KEY ?? null
2626
if (!apiKey) {
27-
test.skip('CODEBUFF_API_KEY is required for project files e2e')
28-
return
27+
throw new Error('CODEBUFF_API_KEY is required for project files e2e')
2928
}
3029
client = new CodebuffClient({ apiKey: getApiKey() })
3130
})

0 commit comments

Comments
 (0)