@@ -216,7 +216,6 @@ suite("Roo Code Extension Test Suite", () => {
216
216
// Set up message tracking with improved error handling
217
217
let webviewReady = false
218
218
let messagesReceived = false
219
- let apiConfigured = false
220
219
const originalPostMessage = await provider . postMessageToWebview . bind ( provider )
221
220
222
221
// @ts -ignore
@@ -230,10 +229,6 @@ suite("Roo Code Extension Test Suite", () => {
230
229
messagesReceived = true
231
230
console . log ( "Messages in state:" , message . state . codeMessages )
232
231
}
233
- if ( message . state ?. apiConfiguration ?. openRouterApiKey ) {
234
- apiConfigured = true
235
- console . log ( "API configuration completed" )
236
- }
237
232
}
238
233
await originalPostMessage ( message )
239
234
} catch ( error ) {
@@ -245,22 +240,45 @@ suite("Roo Code Extension Test Suite", () => {
245
240
// Wait for API configuration
246
241
console . log ( "Waiting for API configuration..." )
247
242
let startTime = Date . now ( )
243
+ let apiConfigured = false
244
+
245
+ // First verify the API key is stored
248
246
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 {
254
248
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 )
256
270
}
257
- await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) ) // Longer interval for API config check
271
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) )
258
272
}
259
273
260
274
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
+ )
264
282
}
265
283
266
284
// Wait for webview to launch and receive initial state
0 commit comments