|
| 1 | +import { test, expect } from './fixtures'; |
| 2 | + |
| 3 | +test('Code tab shows Monaco editor with generated code', async ({ window }) => { |
| 4 | + // Wait for the app to fully render |
| 5 | + await window.waitForSelector('.panel-tabs', { timeout: 15000 }); |
| 6 | + |
| 7 | + // Click the Code tab |
| 8 | + const codeTab = window.locator('button.panel-tab').filter({ hasText: 'Code' }); |
| 9 | + await expect(codeTab).toBeVisible(); |
| 10 | + await codeTab.click(); |
| 11 | + |
| 12 | + // Verify the IDE preview panel appears |
| 13 | + const idePreview = window.locator('.ide-preview'); |
| 14 | + await expect(idePreview).toBeVisible(); |
| 15 | + |
| 16 | + // Verify tab bar with App.tsx default active |
| 17 | + const activeTab = window.locator('.ide-tab[data-active="true"]'); |
| 18 | + await expect(activeTab).toBeVisible(); |
| 19 | + await expect(activeTab).toContainText('App.tsx'); |
| 20 | + |
| 21 | + // Verify action buttons exist (copy, word wrap) |
| 22 | + const actionBar = window.locator('.ide-action-bar'); |
| 23 | + await expect(actionBar).toBeVisible(); |
| 24 | + |
| 25 | + // Wait for Monaco editor to load (can be slow in Electron builds) |
| 26 | + const editor = window.locator('.ide-editor .monaco-editor'); |
| 27 | + await expect(editor).toBeVisible({ timeout: 30000 }); |
| 28 | + |
| 29 | + // Verify status bar is visible with language info |
| 30 | + const statusBar = window.locator('.ide-status-bar'); |
| 31 | + await expect(statusBar).toBeVisible(); |
| 32 | + await expect(statusBar).toContainText('TypeScript'); |
| 33 | + await expect(statusBar).toContainText('line'); |
| 34 | + |
| 35 | + // Take a screenshot of the code preview |
| 36 | + await window.screenshot({ path: 'test-results/code-preview.png', fullPage: false }); |
| 37 | +}); |
| 38 | + |
| 39 | +test('Code tab file selector via tab bar works', async ({ window }) => { |
| 40 | + await window.waitForSelector('.panel-tabs', { timeout: 15000 }); |
| 41 | + |
| 42 | + // Switch to Code tab |
| 43 | + await window.locator('button.panel-tab').filter({ hasText: 'Code' }).click(); |
| 44 | + await expect(window.locator('.ide-preview')).toBeVisible(); |
| 45 | + |
| 46 | + // Wait for Monaco to load |
| 47 | + await expect(window.locator('.ide-editor .monaco-editor')).toBeVisible({ timeout: 30000 }); |
| 48 | + |
| 49 | + // Click the design-spec.ts tab |
| 50 | + const specTab = window.locator('.ide-tab').filter({ hasText: 'design-spec.ts' }); |
| 51 | + await specTab.click(); |
| 52 | + |
| 53 | + // Verify it's now active |
| 54 | + await expect(specTab).toHaveAttribute('data-active', 'true'); |
| 55 | + |
| 56 | + // Verify the status bar updated to TypeScript |
| 57 | + await expect(window.locator('.ide-status-bar')).toContainText('TypeScript'); |
| 58 | +}); |
0 commit comments