Skip to content

Commit 27971cd

Browse files
committed
test fixes again
1 parent 3b4b94f commit 27971cd

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

src/test/extension.test.ts

+33-15
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ suite("Roo Code Extension Test Suite", () => {
216216
// Set up message tracking with improved error handling
217217
let webviewReady = false
218218
let messagesReceived = false
219-
let apiConfigured = false
220219
const originalPostMessage = await provider.postMessageToWebview.bind(provider)
221220

222221
// @ts-ignore
@@ -230,10 +229,6 @@ suite("Roo Code Extension Test Suite", () => {
230229
messagesReceived = true
231230
console.log("Messages in state:", message.state.codeMessages)
232231
}
233-
if (message.state?.apiConfiguration?.openRouterApiKey) {
234-
apiConfigured = true
235-
console.log("API configuration completed")
236-
}
237232
}
238233
await originalPostMessage(message)
239234
} catch (error) {
@@ -245,22 +240,45 @@ suite("Roo Code Extension Test Suite", () => {
245240
// Wait for API configuration
246241
console.log("Waiting for API configuration...")
247242
let startTime = Date.now()
243+
let apiConfigured = false
244+
245+
// First verify the API key is stored
248246
while (Date.now() - startTime < apiConfigTimeout) {
249-
if (apiConfigured) {
250-
console.log("API configuration successfully completed")
251-
break
252-
}
253-
if (Date.now() - startTime > 60000 && !apiConfigured) {
247+
try {
254248
const state = await provider.getState()
255-
console.log("API configuration status check at 1 minute mark:", state)
249+
const storedKey = await provider.context.secrets.get("openRouterApiKey")
250+
251+
if (
252+
storedKey &&
253+
state.apiConfiguration.apiProvider === "openrouter" &&
254+
state.apiConfiguration.openRouterModelId === "anthropic/claude-3.5-sonnet"
255+
) {
256+
console.log("API configuration verified")
257+
apiConfigured = true
258+
break
259+
}
260+
261+
if (Date.now() - startTime > 60000) {
262+
console.log("API configuration status check at 1 minute mark:", {
263+
hasStoredKey: !!storedKey,
264+
provider: state.apiConfiguration.apiProvider,
265+
modelId: state.apiConfiguration.openRouterModelId,
266+
})
267+
}
268+
} catch (error) {
269+
console.error("Error checking API configuration:", error)
256270
}
257-
await new Promise((resolve) => setTimeout(resolve, 5000)) // Longer interval for API config check
271+
await new Promise((resolve) => setTimeout(resolve, 5000))
258272
}
259273

260274
if (!apiConfigured) {
261-
const finalState = await provider.getState()
262-
console.error("Final state before timeout:", finalState)
263-
throw new Error("Timeout waiting for API configuration")
275+
const state = await provider.getState()
276+
const storedKey = await provider.context.secrets.get("openRouterApiKey")
277+
throw new Error(
278+
`API configuration timeout. Provider: ${state.apiConfiguration.apiProvider}, ` +
279+
`Model: ${state.apiConfiguration.openRouterModelId}, ` +
280+
`Has stored key: ${!!storedKey}`,
281+
)
264282
}
265283

266284
// Wait for webview to launch and receive initial state

0 commit comments

Comments
 (0)