import * as fs from 'fs'; import * as path from 'path'; import { test, expect, _electron as electron } from '@playwright/test'; const SCREENSHOT_DIR = 'C:/Users/encep/.gemini/antigravity-cli/brain/3ab7ae82-5634-41d5-93a7-3c12c22503e2/screenshots'; test.describe('Launch Readiness E2E & Visual Verification', () => { test.describe.configure({ mode: 'serial' }); let electronApp: any; let window: any; test.beforeAll(async () => { if (!fs.existsSync(SCREENSHOT_DIR)) { fs.mkdirSync(SCREENSHOT_DIR, { recursive: true }); } electronApp = await electron.launch({ args: [ 'out/main/index.js', '--disable-gpu', '--no-sandbox', '--user-data-dir=C:/Users/encep/AppData/Local/Temp/playwright-d3ro-launch-test-' + Date.now(), ], env: { ...process.env, NODE_ENV: 'test', }, }); // Poll for main window (excluding popup windows) for (let i = 0; i < 40; i++) { for (const w of electronApp.windows()) { try { const url = w.url(); if (url && url.includes('index.html') && !url.includes('popups/')) { window = w; break; } } catch { // ignore } } if (window) break; await new Promise((r) => setTimeout(r, 500)); } if (!window) { window = electronApp.windows()[0] || await electronApp.firstWindow(); } await window.waitForLoadState('domcontentloaded'); // Bypass onboarding via IPC config set await window.evaluate(async () => { if (window.electronAPI && window.electronAPI.config) { await window.electronAPI.config.set({ key: 'onboardingCompleted', value: true }); await window.electronAPI.config.set({ key: 'appUsageMode', value: 'online' }); } }); await window.waitForTimeout(500); await window.reload(); await window.waitForLoadState('domcontentloaded'); await window.waitForTimeout(1500); }); test.afterAll(async () => { if (electronApp) { await electronApp.close(); } }); test('01. Should render desktop app with Free Tier AdBanner and Support button', async () => { // Check if sidebar has Customer Support button const supportBtn = window.locator('text=/^(Customer Support|고객지원)$/').first(); await expect(supportBtn).toBeVisible({ timeout: 10000 }); // Check if Free Tier AdBanner is visible const adBanner = window.locator('text=/Cursor AI/').first(); await expect(adBanner).toBeVisible({ timeout: 10000 }); // Take screenshot of main window with AdBanner and sidebar await window.screenshot({ path: path.join(SCREENSHOT_DIR, '01_desktop_main_with_adbanner.png') }); }); test('02. Should open SupportModal and interact with AI Customer Assistant', async () => { // Click Customer Support in sidebar await window.locator('text=/^(Customer Support|고객지원)$/').first().click(); await window.waitForTimeout(500); // Verify modal header is visible await expect(window.locator('text=/D3RO Voice Customer Assistance/').first()).toBeVisible(); // Click quick prompt "🎤 마이크 인식 오류" const micPrompt = window.locator('text=/마이크 인식/').first(); if (await micPrompt.isVisible()) { await micPrompt.click(); await window.waitForTimeout(800); } // Capture screenshot of SupportModal with AI chat await window.screenshot({ path: path.join(SCREENSHOT_DIR, '02_support_modal_ai_chat.png') }); // Switch to 7-Day Refund Tab (tab 3) const refundTab = window.locator('text=/7일 자동 환불/').first(); await refundTab.click(); await window.waitForTimeout(500); // Click "환불 자격 자동 조회하기" const checkRefundBtn = window.locator('button:has-text("환불 자격 자동 조회하기")').first(); if (await checkRefundBtn.isVisible()) { await checkRefundBtn.click(); await window.waitForTimeout(1000); } // Capture screenshot of refund eligibility result await window.screenshot({ path: path.join(SCREENSHOT_DIR, '03_support_modal_refund_check.png') }); // Close Support Modal await window.keyboard.press('Escape'); await window.waitForTimeout(500); }); test('03. Should open CheckoutModal and display Toss Payments / Stripe options', async () => { // Trigger checkout via "Remove ads with Pro" link in AdBanner const removeAdsLink = window.locator('text=/Remove ads with Pro/').first(); if (await removeAdsLink.isVisible()) { await removeAdsLink.click(); await window.waitForTimeout(600); // Verify Checkout Modal is visible await expect(window.locator('text=/D3RO Voice Secure Checkout/').first()).toBeVisible(); // Capture screenshot of CheckoutModal await window.screenshot({ path: path.join(SCREENSHOT_DIR, '04_checkout_modal_toss_stripe.png') }); // Close modal await window.keyboard.press('Escape'); await window.waitForTimeout(400); } }); });