Skip to content

Commit 11032f5

Browse files
committed
Fail loudly on SDK auth errors in e2e tests
1 parent 4c003aa commit 11032f5

14 files changed

+60
-50
lines changed

sdk/e2e/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe('E2E: My Test', () => {
122122
handleEvent: collector.handleEvent,
123123
})
124124

125-
if (isAuthError(result.output)) return
125+
assertNoAuthError(result.output)
126126

127127
expect(result.output.type).not.toBe('error')
128128
}, DEFAULT_TIMEOUT)

sdk/e2e/custom-agents/api-integration-agent.e2e.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CodebuffClient, getCustomToolDefinition } from '../../src'
1111
import {
1212
EventCollector,
1313
getApiKey,
14-
isAuthError,
14+
assertNoAuthError,
1515
ensureBackendConnection,
1616
DEFAULT_TIMEOUT,
1717
} from '../utils'
@@ -114,7 +114,7 @@ Summarize the response data clearly.`,
114114
handleEvent: collector.handleEvent,
115115
})
116116

117-
if (isAuthError(result.output)) return
117+
assertNoAuthError(result.output)
118118

119119
expect(result.output.type).not.toBe('error')
120120

@@ -140,7 +140,7 @@ Summarize the response data clearly.`,
140140
handleEvent: collector.handleEvent,
141141
})
142142

143-
if (isAuthError(result.output)) return
143+
assertNoAuthError(result.output)
144144

145145
// Should complete without crashing
146146
expect(collector.hasEventType('finish')).toBe(true)

sdk/e2e/custom-agents/database-query-agent.e2e.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CodebuffClient, getCustomToolDefinition } from '../../src'
1111
import {
1212
EventCollector,
1313
getApiKey,
14-
isAuthError,
14+
assertNoAuthError,
1515
ensureBackendConnection,
1616
MOCK_DATABASE,
1717
DEFAULT_TIMEOUT,
@@ -85,7 +85,7 @@ Always format query results in a readable way.`,
8585
handleEvent: collector.handleEvent,
8686
})
8787

88-
if (isAuthError(result.output)) return
88+
assertNoAuthError(result.output)
8989

9090
expect(result.output.type).not.toBe('error')
9191

@@ -116,7 +116,7 @@ Always format query results in a readable way.`,
116116
handleEvent: collector.handleEvent,
117117
})
118118

119-
if (isAuthError(result.output)) return
119+
assertNoAuthError(result.output)
120120

121121
expect(result.output.type).not.toBe('error')
122122
expect(collector.hasEventType('finish')).toBe(true)

sdk/e2e/custom-agents/weather-agent.e2e.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CodebuffClient, getCustomToolDefinition } from '../../src'
1111
import {
1212
EventCollector,
1313
getApiKey,
14-
isAuthError,
14+
assertNoAuthError,
1515
ensureBackendConnection,
1616
MOCK_WEATHER_DATA,
1717
DEFAULT_TIMEOUT,
@@ -77,7 +77,7 @@ Always report the temperature and conditions clearly.`,
7777
handleEvent: collector.handleEvent,
7878
})
7979

80-
if (isAuthError(result.output)) return
80+
assertNoAuthError(result.output)
8181

8282
expect(result.output.type).not.toBe('error')
8383

@@ -113,7 +113,7 @@ Always report the temperature and conditions clearly.`,
113113
handleEvent: collector.handleEvent,
114114
})
115115

116-
if (isAuthError(result.output)) return
116+
assertNoAuthError(result.output)
117117

118118
expect(result.output.type).not.toBe('error')
119119
expect(collector.hasEventType('finish')).toBe(true)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { CodebuffClient } from '../../src/client'
1010
import {
1111
EventCollector,
1212
getApiKey,
13-
isAuthError,
13+
assertNoAuthError,
1414
ensureBackendConnection,
1515
DEFAULT_AGENT,
1616
DEFAULT_TIMEOUT,
@@ -48,7 +48,7 @@ describe('Features: Knowledge Files', () => {
4848
handleEvent: collector.handleEvent,
4949
})
5050

51-
if (isAuthError(result.output)) return
51+
assertNoAuthError(result.output)
5252

5353
expect(result.output.type).not.toBe('error')
5454
const responseText = collector.getFullText().toUpperCase()
@@ -78,7 +78,7 @@ describe('Features: Knowledge Files', () => {
7878
handleEvent: collector.handleEvent,
7979
})
8080

81-
if (isAuthError(result.output)) return
81+
assertNoAuthError(result.output)
8282

8383
expect(result.output.type).not.toBe('error')
8484
const responseText = collector.getFullText().toLowerCase()

sdk/e2e/features/max-agent-steps.e2e.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { CodebuffClient } from '../../src/client'
1010
import {
1111
EventCollector,
1212
getApiKey,
13-
isAuthError,
13+
assertNoAuthError,
1414
ensureBackendConnection,
1515
DEFAULT_AGENT,
1616
DEFAULT_TIMEOUT,
@@ -40,7 +40,7 @@ describe('Features: Max Agent Steps', () => {
4040
handleEvent: collector.handleEvent,
4141
})
4242

43-
if (isAuthError(result.output)) return
43+
assertNoAuthError(result.output)
4444

4545
expect(result.output.type).not.toBe('error')
4646
expect(collector.hasEventType('finish')).toBe(true)
@@ -61,7 +61,7 @@ describe('Features: Max Agent Steps', () => {
6161
handleEvent: collector.handleEvent,
6262
})
6363

64-
if (isAuthError(result.output)) return
64+
assertNoAuthError(result.output)
6565

6666
// Should still complete for simple prompts
6767
expect(collector.hasEventType('start')).toBe(true)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { CodebuffClient } from '../../src/client'
1010
import {
1111
EventCollector,
1212
getApiKey,
13-
isAuthError,
13+
assertNoAuthError,
1414
ensureBackendConnection,
1515
SAMPLE_PROJECT_FILES,
1616
DEFAULT_AGENT,
@@ -47,7 +47,7 @@ describe('Features: Project Files', () => {
4747
handleEvent: collector.handleEvent,
4848
})
4949

50-
if (isAuthError(result.output)) return
50+
assertNoAuthError(result.output)
5151

5252
expect(result.output.type).not.toBe('error')
5353
const responseText = collector.getFullText().toLowerCase()
@@ -74,7 +74,7 @@ describe('Features: Project Files', () => {
7474
handleEvent: collector.handleEvent,
7575
})
7676

77-
if (isAuthError(result.output)) return
77+
assertNoAuthError(result.output)
7878

7979
expect(result.output.type).not.toBe('error')
8080
const responseText = collector.getFullText().toLowerCase()

sdk/e2e/integration/event-ordering.integration.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CodebuffClient } from '../../src/client'
1111
import {
1212
EventCollector,
1313
getApiKey,
14-
isAuthError,
14+
assertNoAuthError,
1515
ensureBackendConnection,
1616
DEFAULT_AGENT,
1717
DEFAULT_TIMEOUT,
@@ -40,7 +40,7 @@ describe('Integration: Event Ordering', () => {
4040
handleEvent: collector.handleEvent,
4141
})
4242

43-
if (isAuthError(result.output)) return
43+
assertNoAuthError(result.output)
4444

4545
const startIndex = collector.events.findIndex((e) => e.type === 'start')
4646
expect(startIndex).toBe(0)
@@ -60,7 +60,7 @@ describe('Integration: Event Ordering', () => {
6060
handleEvent: collector.handleEvent,
6161
})
6262

63-
if (isAuthError(result.output)) return
63+
assertNoAuthError(result.output)
6464

6565
const finishIndex = collector.events.findIndex((e) => e.type === 'finish')
6666
const lastTextIndex = collector.events
@@ -89,7 +89,7 @@ describe('Integration: Event Ordering', () => {
8989
cwd: process.cwd(),
9090
})
9191

92-
if (isAuthError(result.output)) return
92+
assertNoAuthError(result.output)
9393

9494
const toolCalls = collector.getEventsByType('tool_call')
9595
const toolResults = collector.getEventsByType('tool_result')
@@ -120,7 +120,7 @@ describe('Integration: Event Ordering', () => {
120120
handleEvent: collector.handleEvent,
121121
})
122122

123-
if (isAuthError(result.output)) return
123+
assertNoAuthError(result.output)
124124

125125
// Use collector's verifyEventOrder method
126126
const hasCorrectOrder = collector.verifyEventOrder(['start', 'finish'])
@@ -141,7 +141,7 @@ describe('Integration: Event Ordering', () => {
141141
handleEvent: collector.handleEvent,
142142
})
143143

144-
if (isAuthError(result.output)) return
144+
assertNoAuthError(result.output)
145145

146146
// Find the last finish event
147147
const finishEvents = collector.getEventsByType('finish')
@@ -170,15 +170,15 @@ describe('Integration: Event Ordering', () => {
170170
handleEvent: collector1.handleEvent,
171171
})
172172

173-
if (isAuthError(result1.output)) return
173+
assertNoAuthError(result1.output)
174174

175175
const result2 = await client.run({
176176
agent: DEFAULT_AGENT,
177177
prompt: 'Say "second"',
178178
handleEvent: collector2.handleEvent,
179179
})
180180

181-
if (isAuthError(result2.output)) return
181+
assertNoAuthError(result2.output)
182182

183183
// Both should have correct ordering
184184
expect(collector1.verifyEventOrder(['start', 'finish'])).toBe(true)

sdk/e2e/integration/event-types.integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { describe, test, expect, beforeAll, beforeEach } from 'bun:test'
88

99
import { CodebuffClient } from '../../src/client'
10-
import { EventCollector, getApiKey, isAuthError, ensureBackendConnection, DEFAULT_AGENT } from '../utils'
10+
import { EventCollector, getApiKey, assertNoAuthError, ensureBackendConnection, DEFAULT_AGENT } from '../utils'
1111

1212
describe('Integration: Event Types (smoke)', () => {
1313
let client: CodebuffClient

sdk/e2e/integration/stream-chunks.integration.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { CodebuffClient } from '../../src/client'
1313
import {
1414
EventCollector,
1515
getApiKey,
16-
isAuthError,
16+
assertNoAuthError,
1717
ensureBackendConnection,
1818
DEFAULT_AGENT,
1919
DEFAULT_TIMEOUT,
@@ -43,7 +43,7 @@ describe('Integration: Stream Chunks', () => {
4343
handleStreamChunk: collector.handleStreamChunk,
4444
})
4545

46-
if (isAuthError(result.output)) return
46+
assertNoAuthError(result.output)
4747

4848
// Should receive string chunks
4949
const stringChunks = collector.streamChunks.filter(
@@ -78,7 +78,7 @@ describe('Integration: Stream Chunks', () => {
7878
handleStreamChunk: customChunkHandler,
7979
})
8080

81-
if (isAuthError(result.output)) return
81+
assertNoAuthError(result.output)
8282

8383
// Should have multiple chunks
8484
expect(chunkTimestamps.length).toBeGreaterThan(1)
@@ -106,7 +106,7 @@ describe('Integration: Stream Chunks', () => {
106106
handleStreamChunk: collector.handleStreamChunk,
107107
})
108108

109-
if (isAuthError(result.output)) return
109+
assertNoAuthError(result.output)
110110

111111
const eventText = collector.getFullText()
112112
const streamText = collector.getFullStreamText()
@@ -135,7 +135,7 @@ describe('Integration: Stream Chunks', () => {
135135
handleStreamChunk: collector.handleStreamChunk,
136136
})
137137

138-
if (isAuthError(result.output)) return
138+
assertNoAuthError(result.output)
139139

140140
// Should still have start event at minimum
141141
expect(collector.hasEventType('start')).toBe(true)
@@ -156,7 +156,7 @@ describe('Integration: Stream Chunks', () => {
156156
handleStreamChunk: collector.handleStreamChunk,
157157
})
158158

159-
if (isAuthError(result.output)) return
159+
assertNoAuthError(result.output)
160160

161161
// Should have received multiple chunks for a longer response
162162
expect(collector.streamChunks.length).toBeGreaterThan(0)
@@ -181,7 +181,7 @@ describe('Integration: Stream Chunks', () => {
181181
handleStreamChunk: collector.handleStreamChunk,
182182
})
183183

184-
if (isAuthError(result.output)) return
184+
assertNoAuthError(result.output)
185185

186186
const fullText = collector.getFullStreamText()
187187

0 commit comments

Comments
 (0)