220 lines
6.7 KiB
JavaScript
220 lines
6.7 KiB
JavaScript
import { chromium } from 'playwright';
|
|
import { writeFileSync } from 'fs';
|
|
|
|
const pages = [
|
|
{
|
|
url: 'http://www.atlilith.local/',
|
|
name: 'homepage',
|
|
expectedContent: ['SimonSelector', 'quadrant', 'providers', 'clients']
|
|
},
|
|
{
|
|
url: 'http://www.atlilith.local/providers',
|
|
name: 'providers',
|
|
expectedContent: ['forWorkers', 'title', 'description']
|
|
},
|
|
{
|
|
url: 'http://www.atlilith.local/company/terms',
|
|
name: 'terms',
|
|
expectedContent: ['Terms', 'Service', 'Agreement']
|
|
},
|
|
{
|
|
url: 'http://www.atlilith.local/company/privacy',
|
|
name: 'privacy',
|
|
expectedContent: ['Privacy', 'Policy', 'Data']
|
|
}
|
|
];
|
|
|
|
async function verifyPage(browser, pageConfig) {
|
|
const context = await browser.newContext();
|
|
const page = await context.newPage();
|
|
|
|
console.log(`\n${'='.repeat(80)}`);
|
|
console.log(`Testing: ${pageConfig.name.toUpperCase()}`);
|
|
console.log(`URL: ${pageConfig.url}`);
|
|
console.log('='.repeat(80));
|
|
|
|
const errors = [];
|
|
const warnings = [];
|
|
const logs = [];
|
|
|
|
// Capture console messages
|
|
page.on('console', msg => {
|
|
const text = msg.text();
|
|
logs.push({ type: msg.type(), text });
|
|
|
|
if (msg.type() === 'error') {
|
|
console.log(` ❌ Console Error: ${text}`);
|
|
errors.push(text);
|
|
} else if (msg.type() === 'warning') {
|
|
console.log(` ⚠️ Console Warning: ${text}`);
|
|
warnings.push(text);
|
|
}
|
|
});
|
|
|
|
// Capture page errors
|
|
page.on('pageerror', error => {
|
|
console.log(` ❌ Page Error: ${error.message}`);
|
|
errors.push(error.message);
|
|
});
|
|
|
|
try {
|
|
// Navigate with timeout
|
|
console.log(`\n📍 Navigating...`);
|
|
await page.goto(pageConfig.url, {
|
|
waitUntil: 'networkidle',
|
|
timeout: 30000
|
|
});
|
|
|
|
// Wait a bit for React to hydrate
|
|
await page.waitForTimeout(2000);
|
|
|
|
// Take screenshot
|
|
const screenshotPath = `/tmp/verify-${pageConfig.name}.png`;
|
|
await page.screenshot({
|
|
path: screenshotPath,
|
|
fullPage: true
|
|
});
|
|
console.log(`\n📸 Screenshot saved: ${screenshotPath}`);
|
|
|
|
// Check if page is blank (body has minimal content)
|
|
const bodyText = await page.evaluate(() => document.body.innerText);
|
|
const isBlank = bodyText.trim().length < 50;
|
|
|
|
if (isBlank) {
|
|
console.log(`\n❌ PAGE APPEARS BLANK (body text: ${bodyText.trim().length} chars)`);
|
|
errors.push('Page is blank or has minimal content');
|
|
} else {
|
|
console.log(`\n✅ Page has content (${bodyText.trim().length} chars)`);
|
|
}
|
|
|
|
// Check for expected content
|
|
console.log(`\n🔍 Checking for expected content...`);
|
|
let foundContent = 0;
|
|
for (const expected of pageConfig.expectedContent) {
|
|
const found = bodyText.includes(expected);
|
|
if (found) {
|
|
console.log(` ✅ Found: "${expected}"`);
|
|
foundContent++;
|
|
} else {
|
|
console.log(` ❌ Missing: "${expected}"`);
|
|
}
|
|
}
|
|
|
|
// Check for i18n key errors (raw keys like "forWorkers.title" should not appear)
|
|
const i18nKeyPattern = /\b[a-z]+\.[a-zA-Z.]+\b/g;
|
|
const suspiciousKeys = bodyText.match(i18nKeyPattern);
|
|
if (suspiciousKeys && suspiciousKeys.length > 5) {
|
|
console.log(`\n⚠️ Possible untranslated i18n keys detected:`);
|
|
console.log(` ${suspiciousKeys.slice(0, 10).join(', ')}`);
|
|
warnings.push('Possible untranslated i18n keys');
|
|
}
|
|
|
|
// Check for specific error patterns
|
|
const hasAnimatePresenceError = errors.some(e =>
|
|
e.includes('AnimatePresence') || e.includes('does not provide an export')
|
|
);
|
|
const hasI18nError = errors.some(e =>
|
|
e.includes('i18n') || e.includes('translation')
|
|
);
|
|
|
|
console.log(`\n📊 Summary for ${pageConfig.name}:`);
|
|
console.log(` - Content detected: ${foundContent}/${pageConfig.expectedContent.length} expected items`);
|
|
console.log(` - Console errors: ${errors.length}`);
|
|
console.log(` - Console warnings: ${warnings.length}`);
|
|
console.log(` - Blank page: ${isBlank ? 'YES ❌' : 'NO ✅'}`);
|
|
console.log(` - AnimatePresence error: ${hasAnimatePresenceError ? 'YES ❌' : 'NO ✅'}`);
|
|
console.log(` - i18n error: ${hasI18nError ? 'YES ❌' : 'NO ✅'}`);
|
|
|
|
// Get body HTML to inspect structure
|
|
const bodyHTML = await page.evaluate(() => document.body.innerHTML);
|
|
const htmlPath = `/tmp/verify-${pageConfig.name}.html`;
|
|
writeFileSync(htmlPath, bodyHTML);
|
|
console.log(`\n📄 HTML saved: ${htmlPath}`);
|
|
|
|
return {
|
|
name: pageConfig.name,
|
|
url: pageConfig.url,
|
|
success: !isBlank && errors.length === 0,
|
|
errors,
|
|
warnings,
|
|
logs: logs.slice(-10), // Last 10 logs
|
|
bodyTextLength: bodyText.trim().length,
|
|
foundContent: `${foundContent}/${pageConfig.expectedContent.length}`,
|
|
screenshot: screenshotPath,
|
|
html: htmlPath
|
|
};
|
|
|
|
} catch (error) {
|
|
console.log(`\n❌ Fatal error testing ${pageConfig.name}:`, error.message);
|
|
return {
|
|
name: pageConfig.name,
|
|
url: pageConfig.url,
|
|
success: false,
|
|
errors: [error.message],
|
|
warnings,
|
|
logs
|
|
};
|
|
} finally {
|
|
await context.close();
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
console.log('🚀 Starting Vite Fix Verification');
|
|
console.log(`Testing ${pages.length} pages on www.atlilith.local\n`);
|
|
|
|
const browser = await chromium.launch({
|
|
headless: true
|
|
});
|
|
|
|
const results = [];
|
|
|
|
for (const pageConfig of pages) {
|
|
const result = await verifyPage(browser, pageConfig);
|
|
results.push(result);
|
|
}
|
|
|
|
await browser.close();
|
|
|
|
// Final summary
|
|
console.log('\n\n' + '='.repeat(80));
|
|
console.log('FINAL VERIFICATION SUMMARY');
|
|
console.log('='.repeat(80));
|
|
|
|
const allSuccess = results.every(r => r.success);
|
|
const successCount = results.filter(r => r.success).length;
|
|
|
|
console.log(`\n📊 Overall: ${successCount}/${results.length} pages passed\n`);
|
|
|
|
results.forEach(result => {
|
|
const status = result.success ? '✅ PASS' : '❌ FAIL';
|
|
console.log(`${status} - ${result.name}`);
|
|
console.log(` URL: ${result.url}`);
|
|
console.log(` Content: ${result.bodyTextLength || 0} chars`);
|
|
if (result.errors && result.errors.length > 0) {
|
|
console.log(` Errors: ${result.errors.length}`);
|
|
result.errors.slice(0, 2).forEach(e => {
|
|
console.log(` - ${e.substring(0, 100)}`);
|
|
});
|
|
}
|
|
console.log();
|
|
});
|
|
|
|
if (allSuccess) {
|
|
console.log('🎉 ALL PAGES VERIFIED - Vite fix is working!\n');
|
|
} else {
|
|
console.log('⚠️ SOME PAGES FAILED - See details above\n');
|
|
}
|
|
|
|
// Write detailed report
|
|
const reportPath = '/tmp/vite-fix-verification-report.json';
|
|
writeFileSync(reportPath, JSON.stringify(results, null, 2));
|
|
console.log(`📋 Detailed report: ${reportPath}\n`);
|
|
|
|
process.exit(allSuccess ? 0 : 1);
|
|
}
|
|
|
|
main().catch(error => {
|
|
console.error('Fatal error:', error);
|
|
process.exit(1);
|
|
});
|