@@ -15,11 +15,9 @@ import {
1515 activateExtension ,
1616 waitForLSPInitialization ,
1717 verifyVSCodeStability ,
18- filterCriticalErrors ,
19- reportTestResults ,
18+ validateAllErrorsInAllowList ,
19+ validateAllNetworkErrorsInAllowList ,
2020 verifyApexFileContentLoaded ,
21- logStep ,
22- logSuccess ,
2321} from '../utils/test-helpers' ;
2422
2523import { setupTestWorkspace } from '../utils/setup' ;
@@ -28,10 +26,9 @@ import {
2826 findAndActivateOutlineView ,
2927 validateApexSymbolsInOutline ,
3028 captureOutlineViewScreenshot ,
31- EXPECTED_APEX_SYMBOLS ,
3229} from '../utils/outline-helpers' ;
3330
34- import { ASSERTION_THRESHOLDS , SELECTORS } from '../utils/constants' ;
31+ import { SELECTORS , EXPECTED_APEX_SYMBOLS } from '../utils/constants' ;
3532
3633/**
3734 * Core E2E tests for Apex Language Server Extension.
@@ -65,31 +62,49 @@ test.describe('Apex Extension Core Functionality', () => {
6562
6663 // Set up monitoring using utilities
6764 const consoleErrors = setupConsoleMonitoring ( page ) ;
68- const networkFailures = setupNetworkMonitoring ( page ) ;
65+ const networkErrors = setupNetworkMonitoring ( page ) ;
6966
7067 // Execute test steps using helper functions
7168 await startVSCodeWeb ( page ) ;
7269 const fileCount = await verifyWorkspaceFiles ( page ) ;
7370 await activateExtension ( page ) ;
7471 await waitForLSPInitialization ( page ) ;
7572
76- // Filter and analyze errors
77- const criticalErrors = filterCriticalErrors ( consoleErrors ) ;
73+ // Validate all errors are in allowList (strict validation)
74+ const errorValidation = validateAllErrorsInAllowList ( consoleErrors ) ;
7875
7976 // Report findings
80- if ( criticalErrors . length > 0 ) {
81- console . log (
82- '⚠️ Critical console errors found:' ,
83- criticalErrors . map ( ( e ) => `${ e . text } (${ e . url } )` ) ,
84- ) ;
77+ console . log ( '📊 Console error validation:' ) ;
78+ console . log ( ` - Total errors: ${ errorValidation . totalErrors } ` ) ;
79+ console . log ( ` - Allowed errors: ${ errorValidation . allowedErrors } ` ) ;
80+ console . log (
81+ ` - Non-allowed errors: ${ errorValidation . nonAllowedErrors . length } ` ,
82+ ) ;
83+
84+ if ( ! errorValidation . allErrorsAllowed ) {
85+ console . log ( '❌ NON-ALLOWED console errors found:' ) ;
86+ errorValidation . nonAllowedErrors . forEach ( ( error , index ) => {
87+ console . log (
88+ ` ${ index + 1 } . "${ error . text } " (URL: ${ error . url || 'no URL' } )` ,
89+ ) ;
90+ } ) ;
8591 } else {
86- console . log ( '✅ No critical console errors' ) ;
92+ console . log ( '✅ All console errors are in allowList ' ) ;
8793 }
8894
89- if ( networkFailures . length > 0 ) {
90- console . log ( '⚠️ Worker network failures:' , networkFailures ) ;
95+ // Validate all network errors are in allowList (strict validation)
96+ const networkValidation =
97+ validateAllNetworkErrorsInAllowList ( networkErrors ) ;
98+
99+ if ( ! networkValidation . allErrorsAllowed ) {
100+ console . log ( '❌ NON-ALLOWED network errors found:' ) ;
101+ networkValidation . nonAllowedErrors . forEach ( ( error , index ) => {
102+ console . log (
103+ ` ${ index + 1 } . HTTP ${ error . status } ${ error . url } (${ error . description } )` ,
104+ ) ;
105+ } ) ;
91106 } else {
92- console . log ( '✅ No worker loading failures ' ) ;
107+ console . log ( '✅ All network errors are in allowList ' ) ;
93108 }
94109
95110 // Verify extension in extensions list
@@ -107,21 +122,14 @@ test.describe('Apex Extension Core Functionality', () => {
107122 // Final stability verification
108123 await verifyVSCodeStability ( page ) ;
109124
110- // Assert success criteria using constants
111- expect ( criticalErrors . length ) . toBeLessThan (
112- ASSERTION_THRESHOLDS . MAX_CRITICAL_ERRORS ,
113- ) ;
114- expect ( networkFailures . length ) . toBeLessThan (
115- ASSERTION_THRESHOLDS . MAX_NETWORK_FAILURES ,
116- ) ;
117- expect ( fileCount ) . toBeGreaterThan ( ASSERTION_THRESHOLDS . MIN_FILE_COUNT ) ;
125+ // Assert success criteria - STRICT validation: all errors must be in allowList
126+ expect ( errorValidation . allErrorsAllowed ) . toBe ( true ) ;
127+ expect ( networkValidation . allErrorsAllowed ) . toBe ( true ) ;
128+ expect ( fileCount ) . toBeGreaterThan ( 0 ) ; // find at least one Apex file
118129
119130 // Report final results
120- reportTestResults (
121- 'Core functionality' ,
122- fileCount ,
123- criticalErrors . length ,
124- networkFailures . length ,
131+ console . log (
132+ `🎉 Core functionality test PASSED - ${ fileCount } Apex files loaded, all errors validated` ,
125133 ) ;
126134 } ) ;
127135
@@ -166,10 +174,18 @@ test.describe('Apex Extension Core Functionality', () => {
166174 await findAndActivateOutlineView ( page ) ;
167175
168176 // Validate that specific Apex symbols are populated in the outline
169- const symbolValidation = await validateApexSymbolsInOutline ( page ) ;
177+ const symbolValidation = await validateApexSymbolsInOutline (
178+ page ,
179+ EXPECTED_APEX_SYMBOLS ,
180+ ) ;
181+
182+ // Assert exact matches instead of loose counting
183+ expect ( symbolValidation . classFound ) . toBe ( true ) ;
184+ expect ( symbolValidation . allExpectedMethodsFound ) . toBe ( true ) ;
185+ expect ( symbolValidation . exactMatch ) . toBe ( true ) ;
170186
171187 // Additionally check for complex symbols that may be present in the comprehensive class
172- logStep ( ' Validating comprehensive symbol hierarchy' , '🏗️ ') ;
188+ console . log ( '🏗️ Validating comprehensive symbol hierarchy... ') ;
173189
174190 // Expected additional symbols in ApexClassExample.cls (beyond the basic ones)
175191 const additionalSymbols = [
@@ -201,13 +217,13 @@ test.describe('Apex Extension Core Functionality', () => {
201217 additionalSymbolsFound ++ ;
202218 foundAdditionalSymbols . push ( symbol ) ;
203219 symbolFound = true ;
204- logSuccess ( ` Found additional symbol: ${ symbol } `) ;
220+ console . log ( `✅ Found additional symbol: ${ symbol } `) ;
205221 break ;
206222 }
207223 }
208224
209225 if ( ! symbolFound ) {
210- logStep ( ` Additional symbol not found: ${ symbol } `, '⚪' ) ;
226+ console . log ( `⚪ Additional symbol not found: ${ symbol } `) ;
211227 }
212228 }
213229
@@ -217,53 +233,57 @@ test.describe('Apex Extension Core Functionality', () => {
217233 ) ;
218234 const totalItems = await outlineItems . count ( ) ;
219235
220- // Filter and analyze errors
221- const criticalErrors = filterCriticalErrors ( consoleErrors ) ;
236+ // Validate all errors are in allowList (strict validation)
237+ const errorValidation = validateAllErrorsInAllowList ( consoleErrors ) ;
222238
223- if ( criticalErrors . length > 0 ) {
224- console . log (
225- '⚠️ Critical console errors found:' ,
226- criticalErrors . map ( ( e ) => `${ e . text } (${ e . url } )` ) ,
227- ) ;
239+ // Report findings
240+ console . log ( '📊 Outline test - Console error validation:' ) ;
241+ console . log ( ` - Total errors: ${ errorValidation . totalErrors } ` ) ;
242+ console . log ( ` - Allowed errors: ${ errorValidation . allowedErrors } ` ) ;
243+ console . log (
244+ ` - Non-allowed errors: ${ errorValidation . nonAllowedErrors . length } ` ,
245+ ) ;
246+
247+ if ( ! errorValidation . allErrorsAllowed ) {
248+ console . log ( '❌ NON-ALLOWED console errors found:' ) ;
249+ errorValidation . nonAllowedErrors . forEach ( ( error , index ) => {
250+ console . log (
251+ ` ${ index + 1 } . "${ error . text } " (URL: ${ error . url || 'no URL' } )` ,
252+ ) ;
253+ } ) ;
228254 } else {
229- console . log ( '✅ No critical console errors' ) ;
255+ console . log ( '✅ All console errors are in allowList ' ) ;
230256 }
231257
232258 // Capture screenshot for debugging
233259 await captureOutlineViewScreenshot ( page , 'comprehensive-outline-test.png' ) ;
234260
235- // Assert comprehensive success criteria
236- expect ( criticalErrors . length ) . toBeLessThan (
237- ASSERTION_THRESHOLDS . MAX_CRITICAL_ERRORS ,
238- ) ;
239- expect ( symbolValidation . classFound ) . toBe ( true ) ;
240- expect ( symbolValidation . methodsFound . length ) . toBeGreaterThanOrEqual (
241- EXPECTED_APEX_SYMBOLS . methods . length ,
242- ) ;
243- expect ( symbolValidation . isValidStructure ) . toBe ( true ) ;
244- expect ( symbolValidation . totalSymbolsDetected ) . toBeGreaterThan ( 0 ) ;
261+ // Assert comprehensive success criteria - STRICT validation with exact matching
262+ expect ( errorValidation . allErrorsAllowed ) . toBe ( true ) ;
263+ expect ( symbolValidation . exactMatch ) . toBe ( true ) ;
264+ expect ( symbolValidation . missingMethods ) . toHaveLength ( 0 ) ;
245265 expect ( totalItems ) . toBeGreaterThan ( 0 ) ;
246266
247- // Verify specific methods are found
248- for ( const method of EXPECTED_APEX_SYMBOLS . methods ) {
249- expect ( symbolValidation . methodsFound ) . toContain ( method . name ) ;
250- }
267+ // Verify all specific methods are found (exact matching)
268+ expect ( symbolValidation . exactMethodsFound ) . toEqual (
269+ expect . arrayContaining ( EXPECTED_APEX_SYMBOLS . methods . map ( ( m ) => m . name ) ) ,
270+ ) ;
251271
252272 // Report comprehensive results combining both basic and advanced symbol detection
253273 console . log ( '🎉 Comprehensive outline view test COMPLETED' ) ;
254274 console . log ( ' - File: ✅ ApexClassExample.cls opened and loaded' ) ;
255275 console . log ( ' - Extension: ✅ Language features activated' ) ;
256276 console . log ( ' - Outline: ✅ Outline view loaded and accessible' ) ;
257277
258- // Basic symbols (required)
278+ // Basic symbols (required) - exact matching
259279 console . log ( ' - Basic symbols: ✅ All expected symbols found' ) ;
260280 console . log (
261- ` • Class: ${ symbolValidation . classFound ? '✅' : '❌' } ApexClassExample ` ,
281+ ` • Class: ${ symbolValidation . classFound ? '✅' : '❌' } ${ EXPECTED_APEX_SYMBOLS . className } ` ,
262282 ) ;
263283 console . log (
264- ` • Methods: ${ symbolValidation . methodsFound . length } /${
284+ ` • Methods: ${ symbolValidation . exactMethodsFound . length } /${
265285 EXPECTED_APEX_SYMBOLS . methods . length
266- } (${ symbolValidation . methodsFound . join ( ', ' ) } )`,
286+ } (${ symbolValidation . exactMethodsFound . join ( ', ' ) } )`,
267287 ) ;
268288
269289 // Additional symbols (nice to have)
@@ -276,9 +296,7 @@ test.describe('Apex Extension Core Functionality', () => {
276296
277297 console . log ( ` - Total outline elements: ${ totalItems } ` ) ;
278298 console . log (
279- ` - Errors: ✅ ${ criticalErrors . length } critical errors (threshold: ${
280- ASSERTION_THRESHOLDS . MAX_CRITICAL_ERRORS
281- } )`,
299+ ` - Errors: ✅ ${ errorValidation . nonAllowedErrors . length } non-allowed errors (strict validation: must be 0)` ,
282300 ) ;
283301 console . log (
284302 ' ✨ This test validates comprehensive LSP symbol parsing and outline population' ,
0 commit comments