diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be469bab..5424f242 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,3 +62,50 @@ jobs: - name: Test run: dotnet test --no-build + + e2e: + runs-on: ubuntu-latest + needs: lint + timeout-minutes: 15 + steps: + - uses: actions/checkout@v6 + + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: '10.0.x' + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: '22' + cache: 'npm' + + - name: Download Tailwind CSS + run: bash tools/download-tailwind.sh + + - name: Restore .NET + run: dotnet restore + + - name: Build .NET + run: dotnet build --no-restore + + - name: Install npm dependencies + run: npm ci + + - name: Build frontend + run: npm run build + + - name: Install Playwright browsers + run: npx -w tests/e2e playwright install --with-deps + + - name: Run smoke tests + run: npm run test:smoke -w tests/e2e + + - name: Upload Playwright report + uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: tests/e2e/playwright-report/ + retention-days: 14 diff --git a/tests/e2e/playwright.config.ts b/tests/e2e/playwright.config.ts index 64f1ca75..2bf066cc 100644 --- a/tests/e2e/playwright.config.ts +++ b/tests/e2e/playwright.config.ts @@ -1,14 +1,17 @@ import { defineConfig, devices } from '@playwright/test'; +const isCI = !!process.env.CI; +const baseURL = isCI ? 'http://localhost:5000' : 'https://localhost:5001'; + export default defineConfig({ testDir: './tests', fullyParallel: true, - forbidOnly: !!process.env.CI, - retries: process.env.CI ? 2 : 0, - workers: process.env.CI ? 1 : undefined, - reporter: [['html'], ...(process.env.CI ? [['github' as const]] : [])], + forbidOnly: isCI, + retries: isCI ? 2 : 0, + workers: isCI ? 1 : undefined, + reporter: [['html'], ...(isCI ? [['github' as const]] : [])], use: { - baseURL: 'https://localhost:5001', + baseURL, trace: 'on-first-retry', ignoreHTTPSErrors: true, screenshot: 'only-on-failure', @@ -23,30 +26,18 @@ export default defineConfig({ use: { ...devices['Desktop Chrome'] }, dependencies: ['setup'], }, - ...(process.env.CI - ? [ - { - name: 'firefox', - use: { ...devices['Desktop Firefox'] }, - dependencies: ['setup'], - }, - { - name: 'webkit', - use: { ...devices['Desktop Safari'] }, - dependencies: ['setup'], - }, - ] - : []), ], webServer: { - command: 'dotnet run --project ../../template/SimpleModule.Host', - url: 'https://localhost:5001/health/live', + command: isCI + ? 'dotnet run --project ../../template/SimpleModule.Host --launch-profile http' + : 'dotnet run --project ../../template/SimpleModule.Host', + url: `${baseURL}/health/live`, reuseExistingServer: true, ignoreHTTPSErrors: true, - timeout: 60_000, + timeout: 120_000, env: { ...process.env, - ASPNETCORE_URLS: 'https://localhost:5001', + ASPNETCORE_URLS: baseURL, Database__DefaultConnection: 'Data Source=e2e-test.db', }, },