/** * Happy Path E2E Test for Slidev Flow * * Tests the complete flow: * 1. Generate deck via API * 2. Wait for GitHub Pages to publish * 3. Load deck in browser * 4. Send control commands (next, prev, goto) * 5. Verify slides respond to commands * 6. Validate performance benchmarks * 7. Verify placeholder replacement */ import { test, expect } from '@playwright/test'; import { setupTestSession, waitForGitHubPages, waitForSlidevLoad, sendControlCommand, captureScreenshot, verifyPlaceholders, isValidGitHubPagesUrl, measureDeckGeneration, cleanupTestDecks, } from './helpers'; test.describe('Slidev Happy Path Flow', () => { let deckId: string; let deckUrl: string; let sessionId: string; test.beforeAll(async () => { console.log('=== Starting Happy Path E2E Test ==='); }); test.afterAll(async () => { // Cleanup test decks if (deckId) { await cleanupTestDecks([deckId]); } console.log('=== Happy Path E2E Test Complete ==='); }); test('should generate deck and publish to GitHub Pages', async () => { console.log('Step 1: Generating deck...'); const result = await setupTestSession({ data: { COMPANY_NAME: 'E2E Test Company', INDUSTRY: 'Technology', PRESENTATION_TITLE: 'Happy Path Test Deck', CUSTOMER_NAME: 'Test Customer', }, }); deckId = result.deckId; deckUrl = result.deckUrl; sessionId = result.sessionId; // Validate deck URL format expect(isValidGitHubPagesUrl(deckUrl)).toBe(true); console.log(`✓ Deck generated: ${deckId}`); console.log(`✓ Deck URL: ${deckUrl}`); }); test('should wait for GitHub Pages to publish', async () => { console.log('Step 2: Waiting for GitHub Pages publish...'); const startTime = Date.now(); await waitForGitHubPages(deckUrl, 120000, 5000); const publishTime = Date.now() - startTime; console.log(`✓ GitHub Pages published in ${publishTime}ms`); // Validate publish time is within acceptable range // Target: < 90s, but allow up to 120s for CI/network variability expect(publishTime).toBeLessThan(120000); }); test('should load deck in browser', async ({ page }) => { console.log('Step 3: Loading deck in browser...'); try { await page.goto(deckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); // Verify page title const title = await page.title(); expect(title).toBeTruthy(); console.log(`✓ Page loaded with title: ${title}`); // Verify Slidev container is present const slideshowContainer = page.locator('#slideshow'); await expect(slideshowContainer).toBeVisible(); console.log('✓ Slidev container visible'); } catch (error) { await captureScreenshot(page, 'deck-load-failure'); throw error; } }); test('should verify placeholder replacement', async ({ page }) => { console.log('Step 4: Verifying placeholder replacement...'); await page.goto(deckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); try { await verifyPlaceholders(page, { COMPANY_NAME: 'E2E Test Company', INDUSTRY: 'Technology', PRESENTATION_TITLE: 'Happy Path Test Deck', }); console.log('✓ All placeholders replaced correctly'); } catch (error) { await captureScreenshot(page, 'placeholder-verification-failure'); throw error; } }); test('should navigate slides with control commands', async ({ page }) => { console.log('Step 5: Testing control commands...'); await page.goto(deckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); try { // Test 'next' command console.log('Testing "next" command...'); const startTime = Date.now(); await sendControlCommand(deckId, 'next'); // Wait for slide to change (Realtime should trigger within 500ms) await page.waitForTimeout(1000); const nextLatency = Date.now() - startTime; console.log(`✓ "next" command executed in ${nextLatency}ms`); expect(nextLatency).toBeLessThan(2000); // Allow 2s for network + Realtime // Test 'prev' command console.log('Testing "prev" command...'); const prevStart = Date.now(); await sendControlCommand(deckId, 'prev'); await page.waitForTimeout(1000); const prevLatency = Date.now() - prevStart; console.log(`✓ "prev" command executed in ${prevLatency}ms`); expect(prevLatency).toBeLessThan(2000); // Test 'goto' command console.log('Testing "goto" command...'); const gotoStart = Date.now(); await sendControlCommand(deckId, 'goto', '3'); await page.waitForTimeout(1000); const gotoLatency = Date.now() - gotoStart; console.log(`✓ "goto" command executed in ${gotoLatency}ms`); expect(gotoLatency).toBeLessThan(2000); } catch (error) { await captureScreenshot(page, 'control-command-failure'); throw error; } }); test('should validate performance benchmarks', async () => { console.log('Step 6: Validating performance benchmarks...'); const metrics = await measureDeckGeneration({ data: { COMPANY_NAME: 'Performance Test Company', INDUSTRY: 'E2E Testing', PRESENTATION_TITLE: 'Performance Benchmark Deck', }, }); console.log('Performance Metrics:'); console.log(`- Build Time: ${metrics.buildTime}ms`); console.log(`- GitHub Pages Publish Time: ${metrics.githubPagesPublishTime}ms`); console.log(`- Total Generation Time: ${metrics.totalGenerationTime}ms`); // Validate benchmarks // Target: < 90s total, but allow 120s for CI variability expect(metrics.totalGenerationTime).toBeLessThan(120000); console.log('✓ Performance benchmarks met'); // Cleanup the performance test deck const perfDeckId = metrics.deckUrl.split('/').slice(-2)[0]; await cleanupTestDecks([perfDeckId]); }); test('should have no console errors', async ({ page }) => { console.log('Step 7: Checking for console errors...'); const consoleErrors: string[] = []; page.on('console', (msg) => { if (msg.type() === 'error') { consoleErrors.push(msg.text()); } }); await page.goto(deckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); // Allow a moment for any errors to surface await page.waitForTimeout(3000); if (consoleErrors.length > 0) { console.warn('Console errors detected:', consoleErrors); await captureScreenshot(page, 'console-errors'); } // For MVP, we'll log errors but not fail the test // In production, you might want to fail on specific error types console.log(`Console errors: ${consoleErrors.length}`); if (consoleErrors.length === 0) { console.log('✓ No console errors detected'); } }); test('should validate HTTPS certificate', async ({ page }) => { console.log('Step 8: Validating HTTPS certificate...'); await page.goto(deckUrl, { waitUntil: 'networkidle', timeout: 60000 }); // GitHub Pages should always have valid HTTPS const securityDetails = await page.evaluate(() => { return { protocol: window.location.protocol, host: window.location.host, }; }); expect(securityDetails.protocol).toBe('https:'); console.log('✓ HTTPS certificate valid (GitHub Pages)'); }); test('should handle rapid control commands', async ({ page }) => { console.log('Step 9: Testing rapid control commands...'); await page.goto(deckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); try { // Send multiple commands in quick succession const commands = ['next', 'next', 'prev', 'next'] as const; for (const command of commands) { await sendControlCommand(deckId, command); await page.waitForTimeout(300); // Small delay between commands } // Wait for all commands to process await page.waitForTimeout(2000); console.log('✓ Rapid control commands handled successfully'); } catch (error) { await captureScreenshot(page, 'rapid-commands-failure'); throw error; } }); test('should maintain state across page reload', async ({ page }) => { console.log('Step 10: Testing state persistence...'); await page.goto(deckUrl, { waitUntil: 'networkidle', timeout: 60000 }); await waitForSlidevLoad(page); // Navigate to slide 3 await sendControlCommand(deckId, 'goto', '3'); await page.waitForTimeout(1000); // Reload the page await page.reload({ waitUntil: 'networkidle' }); await waitForSlidevLoad(page); // Deck should remain functional after reload await sendControlCommand(deckId, 'next'); await page.waitForTimeout(1000); console.log('✓ Deck remains functional after reload'); }); }); test.describe('Slidev Flow - Edge Cases', () => { test('should handle missing optional fields gracefully', async () => { console.log('Testing generation with minimal data...'); const result = await setupTestSession({ data: { COMPANY_NAME: 'Minimal Test Company', }, }); expect(result.deckId).toBeTruthy(); expect(result.deckUrl).toBeTruthy(); expect(isValidGitHubPagesUrl(result.deckUrl)).toBe(true); console.log('✓ Deck generated with minimal data'); // Cleanup await cleanupTestDecks([result.deckId]); }); test('should handle special characters in data', async () => { console.log('Testing generation with special characters...'); const result = await setupTestSession({ data: { COMPANY_NAME: 'Test & Company™', INDUSTRY: 'Tech ', PRESENTATION_TITLE: 'Special "Chars" Test', }, }); expect(result.deckId).toBeTruthy(); expect(result.deckUrl).toBeTruthy(); console.log('✓ Deck generated with special characters'); // Cleanup await cleanupTestDecks([result.deckId]); }); });