diff --git a/.github/workflows/ui-v2.yml b/.github/workflows/ui-v2.yml new file mode 100644 index 00000000..804e9987 --- /dev/null +++ b/.github/workflows/ui-v2.yml @@ -0,0 +1,78 @@ +name: UI v2 CI + +on: + push: + paths: + - 'ui-v2/**' + branches: + - main + pull_request: + paths: + - 'ui-v2/**' + branches: + - main + workflow_dispatch: + +jobs: + ui-v2-checks: + name: Lint and Test UI v2 + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + cache: 'npm' + cache-dependency-path: ui-v2/package-lock.json + + - name: Install Dependencies + working-directory: ui-v2 + run: npm ci + + - name: Run All Checks + working-directory: ui-v2 + run: npm run check-all + + - name: Run Unit Tests + working-directory: ui-v2 + run: npm test + + - name: Install Playwright Browsers + working-directory: ui-v2 + run: npx playwright install --with-deps chromium + +# - name: Configure Electron Sandbox +# working-directory: ui-v2 +# run: | +# sudo chown root:root node_modules/electron/dist/chrome-sandbox +# sudo chmod 4755 node_modules/electron/dist/chrome-sandbox + + - name: Run E2E Tests + working-directory: ui-v2 + env: + HEADLESS: true + NODE_OPTIONS: "--loader ts-node/esm --max-old-space-size=4096" + run: | + # Increase system limits + sudo sysctl -w vm.max_map_count=262144 + sudo sysctl -w fs.file-max=65535 + ulimit -n 65535 + + # Run tests with xvfb + xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e:web:headless + + # todo: fix electron tests not running in GH workflow + # xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e:electron:headless + + - name: Upload Test Results + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-results + path: | + ui-v2/playwright-report/ + ui-v2/test-results/ + retention-days: 30 \ No newline at end of file diff --git a/ui-v2/.gitignore b/ui-v2/.gitignore index 9b64bede..08a816a3 100644 --- a/ui-v2/.gitignore +++ b/ui-v2/.gitignore @@ -25,3 +25,8 @@ out/ # Generated JavaScript files in source electron/**/*.js !electron/**/*.config.js + +# Playwright +test-results/ +playwright-report/ +playwright/.cache/ diff --git a/ui-v2/.stylelintrc.json b/ui-v2/.stylelintrc.json index 6f67e52b..8ab0fc41 100644 --- a/ui-v2/.stylelintrc.json +++ b/ui-v2/.stylelintrc.json @@ -1,20 +1,12 @@ { - "extends": [ - "stylelint-config-standard" - ], + "extends": ["stylelint-config-standard"], "rules": { "at-rule-no-unknown": [ true, { - "ignoreAtRules": [ - "tailwind", - "apply", - "variants", - "responsive", - "screen" - ] + "ignoreAtRules": ["tailwind", "apply", "variants", "responsive", "screen"] } ], "no-descending-specificity": null } -} \ No newline at end of file +} diff --git a/ui-v2/README.md b/ui-v2/README.md index e6211836..d632789c 100644 --- a/ui-v2/README.md +++ b/ui-v2/README.md @@ -1,4 +1,5 @@ # codename goose ui v2 + Your on-machine AI agent, automating tasks seamlessly. ## Development @@ -50,6 +51,18 @@ npm run test:ui # Generate test coverage npm run test:coverage +# End-to-End Testing +npm run test:e2e # Run all e2e tests headlessly +npm run test:e2e:ui # Run e2e tests with UI mode for both web and electron + +npm run test:e2e:web # Run web e2e tests with browser visible +npm run test:e2e:web:headless # Run web e2e tests headlessly +npm run test:e2e:web:ui # Run web e2e tests with Playwright UI mode + +npm run test:e2e:electron # Run electron e2e tests with window visible +npm run test:e2e:electron:headless # Run electron e2e tests headlessly +npm run test:e2e:electron:ui # Run electron e2e tests with Playwright UI mode + # Type checking npm run typecheck # Check all TypeScript files npm run tsc:web # Check web TypeScript files @@ -85,6 +98,11 @@ npm run check-all │ │ ├── IPlatformService.ts │ │ └── index.ts │ ├── test/ # Test setup and configurations +│ │ ├── e2e/ # End-to-end test files +│ │ │ ├── electron/ # Electron-specific e2e tests +│ │ │ │ └── electron.spec.ts +│ │ │ └── web/ # Web-specific e2e tests +│ │ │ └── web.spec.ts │ │ ├── setup.ts │ │ └── types.d.ts │ ├── App.tsx @@ -92,6 +110,7 @@ npm run check-all │ └── web.tsx # Web entry ├── electron.html # Electron HTML template ├── index.html # Web HTML template +├── playwright.config.ts # Playwright e2e test configuration ├── vite.config.ts # Vite config for web ├── vite.main.config.ts # Vite config for electron main ├── vite.preload.config.ts # Vite config for preload script @@ -118,6 +137,7 @@ export interface IPlatformService { ``` This is implemented through two concrete classes: + - `WebPlatformService`: Implements functionality for web browsers using Web APIs - `ElectronPlatformService`: Implements functionality for Electron using IPC @@ -130,6 +150,7 @@ The application uses a dependency injection pattern for platform services: 3. **Unified Access**: Components access platform features through a single `platformService` instance Example usage in components: + ```typescript import { platformService } from '@platform'; @@ -142,6 +163,7 @@ await platformService.copyToClipboard(text); For Electron-specific functionality, the architecture includes: 1. **Preload Script**: Safely exposes Electron APIs to the renderer process + ```typescript // Type definitions for Electron APIs declare global { @@ -154,6 +176,7 @@ declare global { ``` 2. **IPC Communication**: Typed handlers for main process communication + ```typescript // Electron implementation export class ElectronPlatformService implements IPlatformService { @@ -168,7 +191,7 @@ export class ElectronPlatformService implements IPlatformService { The project uses a sophisticated build system with multiple configurations: 1. **Web Build**: Vite-based build for web deployment -2. **Electron Build**: +2. **Electron Build**: - Main Process: Separate Vite config for Electron main process - Renderer Process: Specialized config for Electron renderer - Preload Scripts: Dedicated build configuration for preload scripts diff --git a/ui-v2/electron.html b/ui-v2/electron.html index e35d93d0..22a26532 100644 --- a/ui-v2/electron.html +++ b/ui-v2/electron.html @@ -1,14 +1,17 @@ - +
- - + +