import { test, expect, _electron as electron } from '@playwright/test'; test.describe('Electron Application', () => { test.describe.configure({ mode: 'serial' }); let electronApp: any; let window: any; test.beforeAll(async () => { electronApp = await electron.launch({ args: ['out/main/index.js', '--user-data-dir=C:/Users/encep/AppData/Local/Temp/playwright-d3ro-test-1786110374422-312'], env: { ...process.env, NODE_ENV: 'test', }, }); let found = false; for (const w of electronApp.windows()) { await w.waitForLoadState('domcontentloaded'); const t = await w.title(); console.log('Window title:', t); if (t === 'D3RO Voice' || t === 'd3ro-voice') { window = w; found = true; break; } } if (!found) { window = await electronApp.waitForEvent('window', { predicate: async (page: any) => { await page.waitForLoadState('domcontentloaded'); const t = await page.title(); console.log('New window title:', t); return t === 'D3RO Voice' || t === 'd3ro-voice'; } }); } }); test.afterAll(async () => { if (electronApp) { await electronApp.close(); } }); test('should display Onboarding Modal on first run', async () => { // Wait for the modal to be visible const isModalVisible = await window.locator('text="D3RO Voice 시작하기"').isVisible(); expect(isModalVisible).toBeTruthy(); const emailInput = window.locator('input[type="email"]'); const passwordInput = window.locator('input[type="password"]'); await expect(emailInput).toBeVisible(); await expect(passwordInput).toBeVisible(); }); test('should show error when login fails', async () => { const emailInput = window.locator('input[type="email"]'); const passwordInput = window.locator('input[type="password"]'); const submitBtn = window.locator('button:has-text("로그인 완료")'); await emailInput.fill('fake@example.com'); await passwordInput.fill('wrongpassword'); await submitBtn.click(); // In a real e2e test, we either expect success or error depending on backend. // For now, we wait for an error message or success phase. const errorMsg = window.locator('text="인증에 실패하였습니다"'); if (await errorMsg.isVisible()) { expect(await errorMsg.isVisible()).toBeTruthy(); } }); });