@@ -2,6 +2,11 @@ const assert = require('assert');
22const vscode = require ( 'vscode' ) ;
33const path = require ( 'path' ) ;
44const fs = require ( 'fs' ) ;
5+ const dotenv = require ( 'dotenv' ) ;
6+
7+ // Load test environment variables
8+ const testEnvPath = path . join ( __dirname , '.test_env' ) ;
9+ dotenv . config ( { path : testEnvPath } ) ;
510
611suite ( 'Roo Cline Extension Test Suite' , ( ) => {
712 vscode . window . showInformationMessage ( 'Starting Roo Cline extension tests.' ) ;
@@ -34,14 +39,11 @@ suite('Roo Cline Extension Test Suite', () => {
3439 }
3540
3641 // Verify API key is set and valid
37- const testEnvPath = path . join ( __dirname , '.test_env' ) ;
38- const envContent = fs . readFileSync ( testEnvPath , 'utf8' ) ;
39- const match = envContent . match ( / O P E N _ R O U T E R _ A P I _ K E Y = ( .+ ) / ) ;
40- if ( ! match ) {
41- done ( new Error ( 'OpenRouter API key should be present in .test_env' ) ) ;
42+ const apiKey = process . env . OPEN_ROUTER_API_KEY ;
43+ if ( ! apiKey ) {
44+ done ( new Error ( 'OPEN_ROUTER_API_KEY environment variable is not set' ) ) ;
4245 return ;
4346 }
44- const apiKey = match [ 1 ] ;
4547 if ( ! apiKey . startsWith ( 'sk-or-v1-' ) ) {
4648 done ( new Error ( 'OpenRouter API key should have correct format' ) ) ;
4749 return ;
@@ -180,14 +182,12 @@ suite('Roo Cline Extension Test Suite', () => {
180182 // Set up API configuration
181183 await provider . updateGlobalState ( 'apiProvider' , 'openrouter' ) ;
182184 await provider . updateGlobalState ( 'openRouterModelId' , 'anthropic/claude-3.5-sonnet' ) ;
183- const testEnvPath = path . join ( __dirname , '.test_env' ) ;
184- const envContent = fs . readFileSync ( testEnvPath , 'utf8' ) ;
185- const match = envContent . match ( / O P E N _ R O U T E R _ A P I _ K E Y = ( .+ ) / ) ;
186- if ( ! match ) {
187- assert . fail ( 'OpenRouter API key should be present in .test_env' ) ;
185+ const apiKey = process . env . OPEN_ROUTER_API_KEY ;
186+ if ( ! apiKey ) {
187+ assert . fail ( 'OPEN_ROUTER_API_KEY environment variable is not set' ) ;
188188 return ;
189189 }
190- await provider . storeSecret ( 'openRouterApiKey' , match [ 1 ] ) ;
190+ await provider . storeSecret ( 'openRouterApiKey' , apiKey ) ;
191191
192192 // Create webview panel with development options
193193 const extensionUri = extension . extensionUri ;
0 commit comments