/** * Browser Compatibility E2E Tests for Slidev * * Tests Slidev presentation rendering and control across browsers: * - Chrome (Chromium) * - Firefox * - Safari (WebKit) * - Edge * * Validates: * - Presentation renders correctly * - Realtime control commands work * - No browser-specific console errors * - Performance is consistent * - CSS/layout is correct */ import { test, expect, devices } from '@playwright/test'; import { setupTestSession, waitForGitHubPages, waitForSlidevLoad, sendControlCommand, captureScreenshot, cleanupTestDecks, } from './helpers'; // Shared test deck for all browser tests let sharedDeckId: string; let sharedDeckUrl: string; test.describe.configure({ mode: 'serial' }); // Run tests serially to share setup test.describe('Browser Compatibility - Setup', () => { test('should generate test deck for browser tests', async () => { console.log('Generating shared test deck for browser compatibility tests...'); const result = await setupTestSession({ data: { COMPANY_NAME: 'Browser Compatibility Test', INDUSTRY: 'Cross-Browser Testing', PRESENTATION_TITLE: 'Multi-Browser Test Deck', }, }); sharedDeckId = result.deckId; sharedDeckUrl = result.deckUrl; console.log(`Test deck generated: ${sharedDeckId}`); console.log(`Deck URL: ${sharedDeckUrl}`); // Wait for GitHub Pages to be ready await waitForGitHubPages(sharedDeckUrl); console.log('GitHub Pages published and ready'); }); }); test.describe('Browser Compatibility - Chromium', () => { test.use({ ...devices['Desktop Chrome'] }); test('should render correctly in Chromium', async ({ page }) => { console.log('Testing Chromium compatibility...'); const consoleErrors: string[] = []; page.on('console', (msg) => { if (msg.type() === 'error') { consoleErrors.push(msg.text()); } }); try { await page.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); // Verify Slidev container const slideshow = page.locator('#slideshow'); await expect(slideshow).toBeVisible(); // Verify slides are rendered const slides = page.locator('.slidev-page'); await expect(slides.first()).toBeVisible(); // Take a screenshot for visual verification await page.screenshot({ path: 'test-results/screenshots/chromium-render.png', fullPage: false, }); console.log('✓ Chromium: Rendering OK'); // Check for console errors if (consoleErrors.length > 0) { console.warn('Chromium console errors:', consoleErrors); } console.log(`✓ Chromium: ${consoleErrors.length} console errors`); } catch (error) { await captureScreenshot(page, 'chromium-failure'); throw error; } }); test('should handle control commands in Chromium', async ({ page }) => { console.log('Testing Chromium control commands...'); await page.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); try { // Test next command await sendControlCommand(sharedDeckId, 'next'); await page.waitForTimeout(1000); // Test prev command await sendControlCommand(sharedDeckId, 'prev'); await page.waitForTimeout(1000); console.log('✓ Chromium: Control commands work'); } catch (error) { await captureScreenshot(page, 'chromium-control-failure'); throw error; } }); }); test.describe('Browser Compatibility - Firefox', () => { test.use({ ...devices['Desktop Firefox'] }); test('should render correctly in Firefox', async ({ page }) => { console.log('Testing Firefox compatibility...'); const consoleErrors: string[] = []; page.on('console', (msg) => { if (msg.type() === 'error') { consoleErrors.push(msg.text()); } }); try { await page.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); // Verify Slidev container const slideshow = page.locator('#slideshow'); await expect(slideshow).toBeVisible(); // Verify slides are rendered const slides = page.locator('.slidev-page'); await expect(slides.first()).toBeVisible(); // Take a screenshot await page.screenshot({ path: 'test-results/screenshots/firefox-render.png', fullPage: false, }); console.log('✓ Firefox: Rendering OK'); // Check for console errors if (consoleErrors.length > 0) { console.warn('Firefox console errors:', consoleErrors); } console.log(`✓ Firefox: ${consoleErrors.length} console errors`); } catch (error) { await captureScreenshot(page, 'firefox-failure'); throw error; } }); test('should handle control commands in Firefox', async ({ page }) => { console.log('Testing Firefox control commands...'); await page.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); try { // Test next command await sendControlCommand(sharedDeckId, 'next'); await page.waitForTimeout(1000); // Test prev command await sendControlCommand(sharedDeckId, 'prev'); await page.waitForTimeout(1000); console.log('✓ Firefox: Control commands work'); } catch (error) { await captureScreenshot(page, 'firefox-control-failure'); throw error; } }); }); test.describe('Browser Compatibility - WebKit (Safari)', () => { test.use({ ...devices['Desktop Safari'] }); test('should render correctly in Safari', async ({ page }) => { console.log('Testing Safari compatibility...'); const consoleErrors: string[] = []; page.on('console', (msg) => { if (msg.type() === 'error') { consoleErrors.push(msg.text()); } }); try { await page.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); // Verify Slidev container const slideshow = page.locator('#slideshow'); await expect(slideshow).toBeVisible(); // Verify slides are rendered const slides = page.locator('.slidev-page'); await expect(slides.first()).toBeVisible(); // Take a screenshot await page.screenshot({ path: 'test-results/screenshots/safari-render.png', fullPage: false, }); console.log('✓ Safari: Rendering OK'); // Check for console errors if (consoleErrors.length > 0) { console.warn('Safari console errors:', consoleErrors); } console.log(`✓ Safari: ${consoleErrors.length} console errors`); } catch (error) { await captureScreenshot(page, 'safari-failure'); throw error; } }); test('should handle control commands in Safari', async ({ page }) => { console.log('Testing Safari control commands...'); await page.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); try { // Test next command await sendControlCommand(sharedDeckId, 'next'); await page.waitForTimeout(1000); // Test prev command await sendControlCommand(sharedDeckId, 'prev'); await page.waitForTimeout(1000); console.log('✓ Safari: Control commands work'); } catch (error) { await captureScreenshot(page, 'safari-control-failure'); throw error; } }); }); test.describe('Browser Compatibility - Edge', () => { test.use({ ...devices['Desktop Edge'], channel: 'msedge' }); test('should render correctly in Edge', async ({ page }) => { console.log('Testing Edge compatibility...'); const consoleErrors: string[] = []; page.on('console', (msg) => { if (msg.type() === 'error') { consoleErrors.push(msg.text()); } }); try { await page.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); // Verify Slidev container const slideshow = page.locator('#slideshow'); await expect(slideshow).toBeVisible(); // Verify slides are rendered const slides = page.locator('.slidev-page'); await expect(slides.first()).toBeVisible(); // Take a screenshot await page.screenshot({ path: 'test-results/screenshots/edge-render.png', fullPage: false, }); console.log('✓ Edge: Rendering OK'); // Check for console errors if (consoleErrors.length > 0) { console.warn('Edge console errors:', consoleErrors); } console.log(`✓ Edge: ${consoleErrors.length} console errors`); } catch (error) { await captureScreenshot(page, 'edge-failure'); throw error; } }); test('should handle control commands in Edge', async ({ page }) => { console.log('Testing Edge control commands...'); await page.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); try { // Test next command await sendControlCommand(sharedDeckId, 'next'); await page.waitForTimeout(1000); // Test prev command await sendControlCommand(sharedDeckId, 'prev'); await page.waitForTimeout(1000); console.log('✓ Edge: Control commands work'); } catch (error) { await captureScreenshot(page, 'edge-control-failure'); throw error; } }); }); test.describe('Browser Compatibility - Performance', () => { test('should have consistent performance across browsers', async ({ browserName, page }) => { console.log(`Testing performance in ${browserName}...`); const startTime = Date.now(); await page.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); const loadTime = Date.now() - startTime; console.log(`${browserName} load time: ${loadTime}ms`); // Page should load within 10 seconds from GitHub Pages expect(loadTime).toBeLessThan(10000); // Measure control command latency const controlStart = Date.now(); await sendControlCommand(sharedDeckId, 'next'); await page.waitForTimeout(500); const controlTime = Date.now() - controlStart; console.log(`${browserName} control latency: ${controlTime}ms`); expect(controlTime).toBeLessThan(2000); console.log(`✓ ${browserName}: Performance acceptable`); }); }); test.describe('Browser Compatibility - CSS and Layout', () => { test('should have correct layout in different browsers', async ({ browserName, page }) => { console.log(`Testing layout in ${browserName}...`); await page.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); try { // Check slideshow dimensions const slideshow = page.locator('#slideshow'); const box = await slideshow.boundingBox(); expect(box).toBeTruthy(); expect(box!.width).toBeGreaterThan(0); expect(box!.height).toBeGreaterThan(0); console.log(`${browserName} slideshow dimensions: ${box!.width}x${box!.height}`); // Check for slide visibility const slide = page.locator('.slidev-page').first(); await expect(slide).toBeVisible(); const slideBox = await slide.boundingBox(); expect(slideBox).toBeTruthy(); expect(slideBox!.width).toBeGreaterThan(0); expect(slideBox!.height).toBeGreaterThan(0); console.log(`✓ ${browserName}: Layout OK`); } catch (error) { await captureScreenshot(page, `${browserName}-layout-failure`); throw error; } }); }); test.describe('Browser Compatibility - Realtime Synchronization', () => { test('should synchronize across multiple browsers', async ({ browser }) => { console.log('Testing cross-browser synchronization...'); // Open deck in two different browser contexts const context1 = await browser.newContext(); const context2 = await browser.newContext(); const page1 = await context1.newPage(); const page2 = await context2.newPage(); try { // Load deck in both pages await page1.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await page2.goto(sharedDeckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page1); await waitForSlidevLoad(page2); console.log('Both contexts loaded'); // Send control command await sendControlCommand(sharedDeckId, 'next'); await page1.waitForTimeout(1500); await page2.waitForTimeout(1500); // Both should remain functional (we can't easily verify they're on the same slide // without deeper integration, but we can verify they're still responsive) const slide1 = page1.locator('.slidev-page').first(); const slide2 = page2.locator('.slidev-page').first(); await expect(slide1).toBeVisible(); await expect(slide2).toBeVisible(); console.log('✓ Multi-browser synchronization functional'); } finally { await context1.close(); await context2.close(); } }); }); test.describe('Browser Compatibility - Cleanup', () => { test('should cleanup test deck', async () => { console.log('Cleaning up browser compatibility test deck...'); if (sharedDeckId) { await cleanupTestDecks([sharedDeckId]); console.log('✓ Cleanup complete'); } }); }); test.describe('Browser Compatibility - Mobile Viewports', () => { test('should render in mobile Chrome viewport', async ({ page }) => { console.log('Testing mobile Chrome viewport...'); await page.setViewportSize({ width: 375, height: 667 }); // iPhone SE const result = await setupTestSession({ data: { COMPANY_NAME: 'Mobile Test' }, }); await waitForGitHubPages(result.deckUrl); try { await page.goto(result.deckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); const slideshow = page.locator('#slideshow'); await expect(slideshow).toBeVisible(); await page.screenshot({ path: 'test-results/screenshots/mobile-chrome.png', }); console.log('✓ Mobile Chrome: Rendering OK'); await cleanupTestDecks([result.deckId]); } catch (error) { await captureScreenshot(page, 'mobile-chrome-failure'); await cleanupTestDecks([result.deckId]); throw error; } }); test('should render in mobile Safari viewport', async ({ page }) => { console.log('Testing mobile Safari viewport...'); await page.setViewportSize({ width: 390, height: 844 }); // iPhone 12 const result = await setupTestSession({ data: { COMPANY_NAME: 'Mobile Safari Test' }, }); await waitForGitHubPages(result.deckUrl); try { await page.goto(result.deckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); const slideshow = page.locator('#slideshow'); await expect(slideshow).toBeVisible(); await page.screenshot({ path: 'test-results/screenshots/mobile-safari.png', }); console.log('✓ Mobile Safari: Rendering OK'); await cleanupTestDecks([result.deckId]); } catch (error) { await captureScreenshot(page, 'mobile-safari-failure'); await cleanupTestDecks([result.deckId]); throw error; } }); });