@@ -153,7 +153,6 @@ suite("Roo Code Extension Test Suite", () => {
153
153
154
154
const timeout = 120000 // Increase timeout for CI
155
155
const interval = 2000 // Increase interval to reduce CPU usage
156
- const apiConfigTimeout = 300000 // 5 minutes timeout for API configuration
157
156
158
157
console . log ( "Starting prompt and response test..." )
159
158
@@ -196,6 +195,7 @@ suite("Roo Code Extension Test Suite", () => {
196
195
const extensionUri = extension . extensionUri
197
196
const panel = vscode . window . createWebviewPanel ( "roo-cline.SidebarProvider" , "Roo Code" , vscode . ViewColumn . One , {
198
197
enableScripts : true ,
198
+ enableFindWidget : false ,
199
199
enableCommandUris : true ,
200
200
retainContextWhenHidden : true ,
201
201
localResourceRoots : [ extensionUri ] ,
@@ -213,22 +213,24 @@ suite("Roo Code Extension Test Suite", () => {
213
213
console . log ( "Initializing provider with panel..." )
214
214
await provider . resolveWebviewView ( panel )
215
215
216
+ // Wait for provider to be fully initialized
217
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) )
218
+
216
219
// Set up message tracking with improved error handling
217
- let webviewReady = false
218
- let messagesReceived = false
220
+ let webviewState = null
219
221
const originalPostMessage = await provider . postMessageToWebview . bind ( provider )
220
222
221
223
// @ts -ignore
222
224
provider . postMessageToWebview = async function ( message ) {
223
225
try {
224
- console . log ( "Posting message:" , JSON . stringify ( message ) )
226
+ console . log ( "Posting message type :" , message . type )
225
227
if ( message . type === "state" ) {
226
- webviewReady = true
227
- console . log ( "Webview state received" )
228
- if ( message . state ?. codeMessages ?. length > 0 ) {
229
- messagesReceived = true
230
- console . log ( "Messages in state:" , message . state . codeMessages )
231
- }
228
+ webviewState = message . state
229
+ console . log ( "Webview state received:" , {
230
+ hasApiConfig : ! ! message . state ?. apiConfiguration ,
231
+ provider : message . state ?. apiConfiguration ?. apiProvider ,
232
+ modelId : message . state ?. apiConfiguration ?. openRouterModelId ,
233
+ } )
232
234
}
233
235
await originalPostMessage ( message )
234
236
} catch ( error ) {
@@ -237,83 +239,57 @@ suite("Roo Code Extension Test Suite", () => {
237
239
}
238
240
}
239
241
240
- // Wait for API configuration
241
- console . log ( "Waiting for API configuration..." )
242
- let startTime = Date . now ( )
243
- let apiConfigured = false
244
-
245
- // First verify the API key is stored
246
- while ( Date . now ( ) - startTime < apiConfigTimeout ) {
247
- try {
248
- const state = await provider . getState ( )
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 )
270
- }
271
- await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) )
272
- }
273
-
274
- if ( ! apiConfigured ) {
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
- )
282
- }
242
+ // Send webviewDidLaunch to initialize chat
243
+ console . log ( "Sending webviewDidLaunch..." )
244
+ await provider . postMessageToWebview ( { type : "webviewDidLaunch" } )
245
+ console . log ( "Sent webviewDidLaunch" )
283
246
284
247
// Wait for webview to launch and receive initial state
285
248
console . log ( "Waiting for webview initialization..." )
286
- startTime = Date . now ( )
249
+ let startTime = Date . now ( )
250
+ let webviewReady = false
251
+
287
252
while ( Date . now ( ) - startTime < 300000 ) {
288
253
// 5 minutes timeout for CI
289
- console . log ( "Webview ready:" , webviewReady )
290
- if ( webviewReady ) {
254
+ const state = await provider . getState ( )
255
+ console . log ( "Current provider state:" , {
256
+ hasApiConfig : ! ! state . apiConfiguration ,
257
+ provider : state . apiConfiguration ?. apiProvider ,
258
+ modelId : state . apiConfiguration ?. openRouterModelId ,
259
+ } )
260
+
261
+ if (
262
+ state . apiConfiguration ?. apiProvider === "openrouter" &&
263
+ state . apiConfiguration ?. openRouterModelId === "anthropic/claude-3.5-sonnet"
264
+ ) {
265
+ webviewReady = true
291
266
console . log ( "Webview successfully initialized" )
292
- // Wait additional time for webview to fully initialize
293
- await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) )
294
267
break
295
268
}
269
+
296
270
if ( Date . now ( ) - startTime > 60000 && ! webviewReady ) {
297
- console . log ( "Webview status check at 1 minute mark" )
271
+ console . log ( "Webview status check at 1 minute mark:" , {
272
+ panelVisible : panel . visible ,
273
+ panelActive : panel . active ,
274
+ hasWebviewState : ! ! webviewState ,
275
+ } )
298
276
}
299
277
await new Promise ( ( resolve ) => setTimeout ( resolve , interval ) )
300
278
}
301
279
302
280
if ( ! webviewReady ) {
303
- throw new Error ( "Timeout waiting for webview initialization" )
281
+ const state = await provider . getState ( )
282
+ console . error ( "Webview initialization failed. Debug info:" , {
283
+ hasWebviewState : ! ! webviewState ,
284
+ // @ts -ignore
285
+ webviewStateApiConfig : webviewState ?. apiConfiguration ,
286
+ providerState : state ,
287
+ panelVisible : panel . visible ,
288
+ panelActive : panel . active ,
289
+ } )
290
+ throw new Error ( "Timeout waiting for webview initialization. Check logs for details." )
304
291
}
305
292
306
- // Send webviewDidLaunch to initialize chat
307
- console . log ( "Sending webviewDidLaunch..." )
308
- await provider . postMessageToWebview ( { type : "webviewDidLaunch" } )
309
- console . log ( "Sent webviewDidLaunch" )
310
-
311
- // Wait for webview to fully initialize
312
- await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) )
313
-
314
- // Restore original postMessage
315
- provider . postMessageToWebview = originalPostMessage
316
-
317
293
// Wait for OpenRouter models to be fully loaded
318
294
console . log ( "Waiting for OpenRouter models..." )
319
295
startTime = Date . now ( )
0 commit comments