/** * Simple Mobile Optimization Test Script * * Tests basic mobile functionality without full Playwright setup * Run with: node test-mobile-optimization.js */ const { chromium } = require('playwright'); async function testMobileOptimizations() { console.log('šŸš€ Starting Mobile Optimization Tests...\n'); const browser = await chromium.launch({ headless: false }); try { // Test mobile viewports const viewports = [ { name: 'iPhone SE', width: 320, height: 568 }, { name: 'iPhone 12', width: 375, height: 667 } ]; for (const viewport of viewports) { console.log(`šŸ“± Testing ${viewport.name} (${viewport.width}x${viewport.height})`); const page = await browser.newPage(); await page.setViewportSize(viewport); // Test registration page mobile optimization console.log(' šŸ” Testing registration page...'); await page.goto('https://upskill-staging.measurequick.com/trainer/registration/', { waitUntil: 'networkidle' }); // Check if mobile responsive CSS is loaded const mobileCSS = await page.$('link[href*="hvac-mobile-responsive.css"]'); if (mobileCSS) { console.log(' āœ… Mobile responsive CSS loaded'); } else { console.log(' āŒ Mobile responsive CSS not found'); } // Check form input sizes (should be 44px+ for touch) const inputs = await page.$$('input[type="text"], input[type="email"], select'); if (inputs.length > 0) { const firstInput = inputs[0]; const boundingBox = await firstInput.boundingBox(); if (boundingBox && boundingBox.height >= 44) { console.log(' āœ… Form inputs are touch-friendly'); } else { console.log(' āŒ Form inputs too small for touch'); } } // Take screenshot await page.screenshot({ path: `screenshots/mobile-test-${viewport.name.toLowerCase().replace(' ', '-')}.png`, fullPage: true }); console.log(` šŸ“ø Screenshot saved for ${viewport.name}`); await page.close(); } // Test dashboard table responsiveness console.log('\nšŸ“Š Testing dashboard table responsiveness...'); const page = await browser.newPage(); await page.setViewportSize({ width: 320, height: 568 }); // For staging, use staging URL await page.goto('https://upskill-staging.measurequick.com/trainer/dashboard/', { waitUntil: 'networkidle' }); // Check if events table exists and is responsive const eventsTable = await page.$('.hvac-events-table-wrapper .events-table'); if (eventsTable) { const tableRows = await page.$$('.events-table tbody tr'); if (tableRows.length > 0) { const firstRow = tableRows[0]; const displayStyle = await firstRow.evaluate(el => window.getComputedStyle(el).display ); if (displayStyle === 'block') { console.log(' āœ… Table rows converted to card layout on mobile'); } else { console.log(' āŒ Table rows not converted to card layout'); } } } await page.screenshot({ path: 'screenshots/mobile-dashboard-test.png', fullPage: true }); console.log(' šŸ“ø Dashboard mobile screenshot saved'); await page.close(); } catch (error) { console.error('āŒ Test failed:', error.message); } finally { await browser.close(); } console.log('\n✨ Mobile optimization tests completed!'); console.log('šŸ“ Check screenshots/ directory for visual verification'); } // Run the test testMobileOptimizations();