Skip to content

Commit 2717088

Browse files
author
Kyle Walker
committed
fix: pr feedback 2
1 parent 5b2e9af commit 2717088

File tree

10 files changed

+366
-390
lines changed

10 files changed

+366
-390
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,50 +28,32 @@ jobs:
2828

2929
- name: Build all packages and extension
3030
run: |
31-
echo "🔧 Building all packages..."
3231
npm run compile
3332
npm run bundle
34-
echo "🔧 Building VS Code extension..."
35-
cd packages/apex-lsp-vscode-extension
36-
npm run build
37-
echo "✅ Build completed"
38-
ls -la dist/
33+
npm run build -w packages/apex-lsp-vscode-extension
3934
4035
- name: Verify extension build
4136
run: |
42-
echo "🔍 Verifying extension build artifacts..."
43-
cd packages/apex-lsp-vscode-extension
44-
if [ ! -f "dist/package.json" ]; then
37+
if [ ! -f "packages/apex-lsp-vscode-extension/dist/package.json" ]; then
4538
echo "❌ package.json not found in dist"
4639
exit 1
4740
fi
48-
if [ ! -f "dist/extension.js" ]; then
41+
if [ ! -f "packages/apex-lsp-vscode-extension/dist/extension.js" ]; then
4942
echo "❌ extension.js not found in dist"
5043
exit 1
5144
fi
52-
if [ ! -f "dist/extension.web.js" ]; then
45+
if [ ! -f "packages/apex-lsp-vscode-extension/dist/extension.web.js" ]; then
5346
echo "❌ extension.web.js not found in dist"
5447
exit 1
5548
fi
56-
echo "✅ All required extension files present"
5749
5850
- name: Install Playwright browsers
5951
run: npx playwright install --with-deps chromium
6052

6153
- name: Run E2E tests
62-
run: |
63-
echo "🧪 Starting e2e tests..."
64-
echo "Environment variables:"
65-
echo " CI: $CI"
66-
echo " RUNNER_TEMP: $RUNNER_TEMP"
67-
echo " TMPDIR: $TMPDIR"
68-
echo " PWD: $PWD"
69-
echo "Test workspace path: $RUNNER_TEMP/apex-e2e-workspace"
70-
echo "Running Playwright tests with proper CI configuration..."
71-
cd e2e-tests && npx playwright test
54+
run: npm run test -w e2e-tests
7255
env:
7356
CI: true
74-
DEBUG: pw:webserver
7557

7658
- name: Upload test results and artifacts
7759
if: always()
@@ -83,17 +65,3 @@ jobs:
8365
e2e-tests/test-results/
8466
retention-days: 30
8567
if-no-files-found: warn
86-
87-
- name: Debug artifact directories
88-
if: always()
89-
run: |
90-
echo "🔍 Debugging artifact directories..."
91-
echo "Current working directory: $(pwd)"
92-
echo "e2e-tests directory contents:"
93-
ls -la e2e-tests/ || echo "e2e-tests directory not found"
94-
echo "playwright-report directory:"
95-
ls -la e2e-tests/playwright-report/ || echo "playwright-report directory not found"
96-
echo "test-results directory:"
97-
ls -la e2e-tests/test-results/ || echo "test-results directory not found"
98-
echo "Searching for any Playwright artifacts..."
99-
find . -name "*.png" -o -name "*.webm" -o -name "*.html" | head -20

e2e-tests/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "e2e-tests",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "End-to-end tests for Apex Language Server Extension",
6+
"scripts": {
7+
"test": "playwright test",
8+
"test:debug": "playwright test --debug --headed",
9+
"test:visual": "DEBUG_MODE=1 playwright test --headed",
10+
"server": "node test-server.js"
11+
},
12+
"devDependencies": {
13+
"@playwright/test": "^1.55.0",
14+
"@types/node": "^20.11.30",
15+
"typescript": "^5.8.2"
16+
}
17+
}

e2e-tests/tests/apex-extension-core.spec.ts

Lines changed: 82 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2523
import { 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',

e2e-tests/tsconfig.json

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2020",
4-
"lib": ["ES2020", "DOM"],
5-
"module": "CommonJS",
6-
"moduleResolution": "node",
3+
"target": "ES2023",
4+
"lib": ["ES2023", "DOM"],
5+
"module": "nodenext",
6+
"moduleResolution": "nodenext",
77
"esModuleInterop": true,
88
"allowSyntheticDefaultImports": true,
99
"strict": true,
@@ -15,11 +15,6 @@
1515
"rootDir": ".",
1616
"types": ["node", "@playwright/test"]
1717
},
18-
"include": [
19-
"**/*.ts"
20-
],
21-
"exclude": [
22-
"node_modules",
23-
"dist"
24-
]
25-
}
18+
"include": ["**/*.ts"],
19+
"exclude": ["node_modules", "dist"]
20+
}

0 commit comments

Comments
 (0)