11/**
22 * Test console warnings and errors using AutoBot's Browser VM
3- * This script uses AutoBot's dedicated Browser VM (172.16.168.25:3000) for browser automation
3+ * This script uses AutoBot's dedicated Browser VM for browser automation
44 * instead of installing Playwright locally on Kali Linux (which is incompatible)
5+ *
6+ * Environment variables:
7+ * AUTOBOT_BROWSER_HOST - Browser VM hostname (default: 127.0.0.1)
8+ * AUTOBOT_BROWSER_PORT - Browser VM port (default: 3000)
9+ * AUTOBOT_FRONTEND_URL - Frontend base URL (default: http://127.0.0.1:5173)
510 */
611
712const http = require ( 'http' ) ;
813const https = require ( 'https' ) ;
914const querystring = require ( 'querystring' ) ;
1015
16+ // Configuration from environment variables with safe localhost defaults
17+ const BROWSER_VM_HOST = process . env . AUTOBOT_BROWSER_HOST || '127.0.0.1' ;
18+ const BROWSER_VM_PORT = parseInt ( process . env . AUTOBOT_BROWSER_PORT || '3000' , 10 ) ;
19+ const FRONTEND_URL = process . env . AUTOBOT_FRONTEND_URL || 'http://127.0.0.1:5173' ;
20+
1121class BrowserVMClient {
12- constructor ( browserVMHost = '172.16.168.25' , browserVMPort = 3000 ) {
22+ constructor ( browserVMHost = BROWSER_VM_HOST , browserVMPort = BROWSER_VM_PORT ) {
1323 this . browserVMHost = browserVMHost ;
1424 this . browserVMPort = browserVMPort ;
1525 this . baseUrl = `http://${ browserVMHost } :${ browserVMPort } ` ;
@@ -69,16 +79,16 @@ class BrowserVMClient {
6979 */
7080 async startBrowserSession ( ) {
7181 try {
72- console . log ( '🌐 Starting browser session on Browser VM...' ) ;
82+ console . log ( 'Starting browser session on Browser VM...' ) ;
7383 const response = await this . sendRequest ( '/api/browser/start' , 'POST' , {
7484 headless : false ,
7585 viewport : { width : 1920 , height : 1080 }
7686 } ) ;
7787
78- console . log ( '✅ Browser session started:' , response ) ;
88+ console . log ( 'Browser session started:' , response ) ;
7989 return response . sessionId ;
8090 } catch ( error ) {
81- console . error ( '❌ Failed to start browser session:' , error . message ) ;
91+ console . error ( 'Failed to start browser session:' , error . message ) ;
8292 throw error ;
8393 }
8494 }
@@ -88,7 +98,7 @@ class BrowserVMClient {
8898 */
8999 async navigateAndCaptureConsole ( sessionId , url ) {
90100 try {
91- console . log ( `🔍 Navigating to ${ url } and capturing console messages...` ) ;
101+ console . log ( `Navigating to ${ url } and capturing console messages...` ) ;
92102
93103 // Navigate to the URL
94104 await this . sendRequest ( '/api/browser/navigate' , 'POST' , {
@@ -108,7 +118,7 @@ class BrowserVMClient {
108118
109119 return consoleMessages ;
110120 } catch ( error ) {
111- console . error ( '❌ Failed to navigate and capture console:' , error . message ) ;
121+ console . error ( 'Failed to navigate and capture console:' , error . message ) ;
112122 throw error ;
113123 }
114124 }
@@ -119,9 +129,9 @@ class BrowserVMClient {
119129 async closeBrowserSession ( sessionId ) {
120130 try {
121131 await this . sendRequest ( '/api/browser/close' , 'POST' , { sessionId } ) ;
122- console . log ( '✅ Browser session closed' ) ;
132+ console . log ( 'Browser session closed' ) ;
123133 } catch ( error ) {
124- console . error ( '⚠️ Failed to close browser session:' , error . message ) ;
134+ console . error ( 'Failed to close browser session:' , error . message ) ;
125135 }
126136 }
127137}
@@ -135,18 +145,18 @@ async function testChatViewConsole() {
135145 sessionId = await browserClient . startBrowserSession ( ) ;
136146
137147 // Test chat view console
138- const chatUrl = 'http://172.16.168.21:5173/ chat' ;
139- console . log ( `🔍 Testing chat view console at: ${ chatUrl } ` ) ;
148+ const chatUrl = ` ${ FRONTEND_URL } / chat` ;
149+ console . log ( `Testing chat view console at: ${ chatUrl } ` ) ;
140150
141151 const consoleMessages = await browserClient . navigateAndCaptureConsole ( sessionId , chatUrl ) ;
142152
143153 // Analyze results
144154 console . log ( '\n=== CONSOLE ANALYSIS RESULTS ===' ) ;
145155 if ( ! consoleMessages || ! consoleMessages . messages || consoleMessages . messages . length === 0 ) {
146- console . log ( '✅ No console warnings or errors detected in chat view!' ) ;
147- console . log ( '🎉 Console warnings and errors have been successfully eliminated!' ) ;
156+ console . log ( 'No console warnings or errors detected in chat view!' ) ;
157+ console . log ( 'Console warnings and errors have been successfully eliminated!' ) ;
148158 } else {
149- console . log ( `❌ Found ${ consoleMessages . messages . length } console issues:` ) ;
159+ console . log ( `Found ${ consoleMessages . messages . length } console issues:` ) ;
150160 consoleMessages . messages . forEach ( ( msg , index ) => {
151161 console . log ( `\n${ index + 1 } . [${ msg . type . toUpperCase ( ) } ] ${ msg . text } ` ) ;
152162 if ( msg . location && msg . location . url ) {
@@ -167,30 +177,30 @@ async function testChatViewConsole() {
167177 const fs = require ( 'fs' ) ;
168178 const resultsPath = '/tmp/console_test_results.json' ;
169179 fs . writeFileSync ( resultsPath , JSON . stringify ( results , null , 2 ) ) ;
170- console . log ( `\n💾 Results saved to: ${ resultsPath } ` ) ;
180+ console . log ( `\nResults saved to: ${ resultsPath } ` ) ;
171181
172182 return results ;
173183
174184 } catch ( error ) {
175- console . error ( '❌ Browser VM automation failed:' , error ) ;
185+ console . error ( 'Browser VM automation failed:' , error ) ;
176186
177187 // Fallback: Try simple HTTP check
178- console . log ( '\n🔄 Falling back to simple HTTP check...' ) ;
188+ console . log ( '\nFalling back to simple HTTP check...' ) ;
179189 try {
180190 const http = require ( 'http' ) ;
181- const testReq = http . get ( 'http://172.16.168.21:5173/' , ( res ) => {
182- console . log ( `✅ Frontend is accessible (HTTP ${ res . statusCode } )` ) ;
183- console . log ( '💡 Frontend and backend are now properly connected' ) ;
184- console . log ( '🎯 Previous console warnings were likely due to backend module import failures' ) ;
185- console . log ( '✅ Backend is now running with correct Python path, eliminating import errors' ) ;
191+ const testReq = http . get ( ` ${ FRONTEND_URL } /` , ( res ) => {
192+ console . log ( `Frontend is accessible (HTTP ${ res . statusCode } )` ) ;
193+ console . log ( 'Frontend and backend are now properly connected' ) ;
194+ console . log ( 'Previous console warnings were likely due to backend module import failures' ) ;
195+ console . log ( 'Backend is now running with correct Python path, eliminating import errors' ) ;
186196 } ) ;
187197
188198 testReq . on ( 'error' , ( err ) => {
189- console . error ( '❌ Frontend accessibility test failed:' , err . message ) ;
199+ console . error ( 'Frontend accessibility test failed:' , err . message ) ;
190200 } ) ;
191201
192202 } catch ( fallbackError ) {
193- console . error ( '❌ Fallback test also failed:' , fallbackError . message ) ;
203+ console . error ( 'Fallback test also failed:' , fallbackError . message ) ;
194204 }
195205
196206 } finally {
@@ -202,11 +212,12 @@ async function testChatViewConsole() {
202212}
203213
204214// Run the test
205- console . log ( '🚀 Starting console test using AutoBot Browser VM...' ) ;
206- console . log ( '📋 This uses the dedicated Browser VM (172.16.168.25:3000) instead of local Playwright' ) ;
207- console . log ( '🔧 Following CLAUDE.md guidelines for Kali Linux compatibility\n' ) ;
215+ console . log ( 'Starting console test using AutoBot Browser VM...' ) ;
216+ console . log ( `Browser VM: ${ BROWSER_VM_HOST } :${ BROWSER_VM_PORT } ` ) ;
217+ console . log ( `Frontend URL: ${ FRONTEND_URL } ` ) ;
218+ console . log ( 'Following CLAUDE.md guidelines for Kali Linux compatibility\n' ) ;
208219
209220testChatViewConsole ( ) . catch ( error => {
210- console . error ( '💥 Test execution failed:' , error ) ;
221+ console . error ( 'Test execution failed:' , error ) ;
211222 process . exit ( 1 ) ;
212223} ) ;
0 commit comments