#!/usr/bin/env node import { chromium } from 'playwright'; const LANDSCAPE_VIEWPORT = { width: 667, height: 375 }; // iPhone SE landscape const IPHONE_12_LANDSCAPE = { width: 844, height: 390 }; // iPhone 12 landscape (async () => { const browser = await chromium.launch({ headless: true }); console.log('๐Ÿงช Testing Landscape Mode: Photo Layout & Button Backdrop\n'); // TEST 1: iPhone SE Landscape console.log('๐Ÿ“ฑ TEST 1: iPhone SE Landscape (667ร—375)\n'); const seContext = await browser.newContext({ viewport: LANDSCAPE_VIEWPORT, userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1', hasTouch: true }); const sePage = await seContext.newPage(); await sePage.goto('http://localhost:1999/?lang=en&view=extended'); await sePage.waitForLoadState('networkidle'); const seLayout = await sePage.evaluate(() => { const headerLeft = document.querySelector('.cv-header-left'); const photo = document.querySelector('.cv-photo'); const backdrop = document.querySelector('.fixed-buttons-backdrop'); const cvName = document.querySelector('.cv-name'); const headerGrid = headerLeft ? window.getComputedStyle(headerLeft).gridTemplateColumns : 'N/A'; const twoColumns = headerGrid.includes(' '); // Has space = multiple columns const photoRect = photo ? photo.getBoundingClientRect() : null; const nameRect = cvName ? cvName.getBoundingClientRect() : null; // Photo should be on the right side (higher x position than name) const photoOnRight = photoRect && nameRect && photoRect.left > nameRect.left; return { viewport: `${window.innerWidth}ร—${window.innerHeight}`, headerGrid: headerGrid, twoColumns: twoColumns, photoWidth: photoRect ? Math.round(photoRect.width) : 0, photoLeft: photoRect ? Math.round(photoRect.left) : 0, nameLeft: nameRect ? Math.round(nameRect.left) : 0, photoOnRight: photoOnRight, nameAlign: cvName ? window.getComputedStyle(cvName).textAlign : 'N/A', backdropVisible: backdrop ? window.getComputedStyle(backdrop).display !== 'none' : false, backdropHeight: backdrop ? window.getComputedStyle(backdrop).height : 'N/A', hasHorizontalScroll: document.body.scrollWidth > window.innerWidth }; }); console.log('iPhone SE Landscape Layout:'); console.log(` โ€ข Viewport: ${seLayout.viewport}`); console.log(` โ€ข Header grid: ${seLayout.headerGrid}`); console.log(` โ€ข Two-column layout: ${seLayout.twoColumns ? 'โœ…' : 'โŒ'}`); console.log(` โ€ข Photo width: ${seLayout.photoWidth}px`); console.log(` โ€ข Photo on right side: ${seLayout.photoOnRight ? 'โœ…' : 'โŒ'} (Photo: ${seLayout.photoLeft}px, Name: ${seLayout.nameLeft}px)`); console.log(` โ€ข Name alignment: ${seLayout.nameAlign}`); console.log(` โ€ข Button backdrop visible: ${seLayout.backdropVisible ? 'โœ…' : 'โŒ'}`); console.log(` โ€ข Backdrop height: ${seLayout.backdropHeight}`); console.log(` โ€ข Has horizontal scroll: ${seLayout.hasHorizontalScroll ? 'โŒ FAIL' : 'โœ…'}\n`); await sePage.screenshot({ path: 'tests/screenshots/landscape-photo-se.png', fullPage: true }); await seContext.close(); // TEST 2: iPhone 12 Landscape console.log('๐Ÿ“ฑ TEST 2: iPhone 12 Landscape (844ร—390)\n'); const iphone12Context = await browser.newContext({ viewport: IPHONE_12_LANDSCAPE, userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1', hasTouch: true }); const iphone12Page = await iphone12Context.newPage(); await iphone12Page.goto('http://localhost:1999/?lang=en&view=extended'); await iphone12Page.waitForLoadState('networkidle'); const iphone12Layout = await iphone12Page.evaluate(() => { const headerLeft = document.querySelector('.cv-header-left'); const photo = document.querySelector('.cv-photo'); const backdrop = document.querySelector('.fixed-buttons-backdrop'); const cvName = document.querySelector('.cv-name'); const headerGrid = headerLeft ? window.getComputedStyle(headerLeft).gridTemplateColumns : 'N/A'; const twoColumns = headerGrid.includes(' '); const photoRect = photo ? photo.getBoundingClientRect() : null; const nameRect = cvName ? cvName.getBoundingClientRect() : null; const photoOnRight = photoRect && nameRect && photoRect.left > nameRect.left; return { viewport: `${window.innerWidth}ร—${window.innerHeight}`, headerGrid: headerGrid, twoColumns: twoColumns, photoWidth: photoRect ? Math.round(photoRect.width) : 0, photoLeft: photoRect ? Math.round(photoRect.left) : 0, nameLeft: nameRect ? Math.round(nameRect.left) : 0, photoOnRight: photoOnRight, nameAlign: cvName ? window.getComputedStyle(cvName).textAlign : 'N/A', backdropVisible: backdrop ? window.getComputedStyle(backdrop).display !== 'none' : false, backdropHeight: backdrop ? window.getComputedStyle(backdrop).height : 'N/A', hasHorizontalScroll: document.body.scrollWidth > window.innerWidth }; }); console.log('iPhone 12 Landscape Layout:'); console.log(` โ€ข Viewport: ${iphone12Layout.viewport}`); console.log(` โ€ข Header grid: ${iphone12Layout.headerGrid}`); console.log(` โ€ข Two-column layout: ${iphone12Layout.twoColumns ? 'โœ…' : 'โŒ'}`); console.log(` โ€ข Photo width: ${iphone12Layout.photoWidth}px`); console.log(` โ€ข Photo on right side: ${iphone12Layout.photoOnRight ? 'โœ…' : 'โŒ'} (Photo: ${iphone12Layout.photoLeft}px, Name: ${iphone12Layout.nameLeft}px)`); console.log(` โ€ข Name alignment: ${iphone12Layout.nameAlign}`); console.log(` โ€ข Button backdrop visible: ${iphone12Layout.backdropVisible ? 'โœ…' : 'โŒ'}`); console.log(` โ€ข Backdrop height: ${iphone12Layout.backdropHeight}`); console.log(` โ€ข Has horizontal scroll: ${iphone12Layout.hasHorizontalScroll ? 'โŒ FAIL' : 'โœ…'}\n`); await iphone12Page.screenshot({ path: 'tests/screenshots/landscape-photo-iphone12.png', fullPage: true }); await iphone12Context.close(); const allPassed = seLayout.twoColumns && seLayout.photoOnRight && seLayout.backdropVisible && !seLayout.hasHorizontalScroll && iphone12Layout.twoColumns && iphone12Layout.photoOnRight && iphone12Layout.backdropVisible && !iphone12Layout.hasHorizontalScroll; console.log(`${allPassed ? 'โœ…' : 'โŒ'} Tests ${allPassed ? 'PASSED' : 'FAILED'}\n`); await browser.close(); process.exit(allPassed ? 0 : 1); })();