diff --git a/verify-vite-fix.mjs b/verify-vite-fix.mjs new file mode 100644 index 0000000..8153391 --- /dev/null +++ b/verify-vite-fix.mjs @@ -0,0 +1,220 @@ +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); +});