upskill-event-manager/wordpress-dev/tests/e2e/critical-error-investigation.test.ts
bengizmo 43e0bb10f5 Fix PHP compatibility issues causing dashboard 500 errors
- Removed PHP 7.4+ type declarations (private int, return types) that were causing fatal errors
- Fixed constructor parameter and property declarations for older PHP versions
- Created minimal dashboard data class as emergency fallback
- Root cause: Server running older PHP version incompatible with modern type declarations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-22 20:25:31 -03:00

73 lines
No EOL
3.1 KiB
TypeScript

import { test, expect } from '@playwright/test';
test('Critical Error Investigation', async ({ page }) => {
console.log('=== Investigating Critical Error ===');
// Test main pages
const pagesToTest = [
'https://upskill-staging.measurequick.com/',
'https://upskill-staging.measurequick.com/community-login/',
'https://upskill-staging.measurequick.com/hvac-dashboard/',
'https://upskill-staging.measurequick.com/certificate-reports/',
'https://upskill-staging.measurequick.com/wp-admin/'
];
for (const url of pagesToTest) {
console.log(`\nTesting: ${url}`);
try {
await page.goto(url, { waitUntil: 'load', timeout: 10000 });
await page.waitForLoadState('networkidle', { timeout: 5000 });
const title = await page.title();
console.log(` Title: ${title}`);
console.log(` Final URL: ${page.url()}`);
// Check for critical error
const hasCriticalError = await page.locator('text=critical error').count() > 0;
const hasWordPressFatalError = await page.locator('text=There has been a critical error').count() > 0;
const hasPhpError = await page.locator('text=Fatal error').count() > 0;
const hasParseError = await page.locator('text=Parse error').count() > 0;
if (hasCriticalError || hasWordPressFatalError || hasPhpError || hasParseError) {
console.log(' ❌ CRITICAL ERROR DETECTED');
// Get error details
const errorText = await page.locator('body').textContent();
const lines = errorText?.split('\n').slice(0, 10) || [];
console.log(' Error content (first 10 lines):');
lines.forEach((line, i) => {
if (line.trim()) console.log(` ${i + 1}: ${line.trim()}`);
});
// Take screenshot
await page.screenshot({
path: `critical-error-${url.replace(/[^a-zA-Z0-9]/g, '-')}.png`,
fullPage: true
});
} else {
console.log(' ✅ No critical error detected');
}
// Check for other indicators
const bodyText = await page.locator('body').textContent() || '';
if (bodyText.includes('500')) {
console.log(' ⚠️ 500 error detected');
}
if (bodyText.includes('syntax error')) {
console.log(' ⚠️ Syntax error detected');
}
if (bodyText.includes('class not found')) {
console.log(' ⚠️ Class not found error detected');
}
} catch (error) {
console.log(` ❌ Failed to load: ${error}`);
await page.screenshot({
path: `failed-load-${url.replace(/[^a-zA-Z0-9]/g, '-')}.png`
});
}
}
console.log('\n=== Investigation Complete ===');
});