-
Notifications
You must be signed in to change notification settings - Fork 11
Add Playwright E2E test suite with CI integration #843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bc5d645
Add Playwright E2E test suite with CI integration
krusche 1ca2a1a
Fix Keycloak startup in CI by using docker run instead of service con…
krusche 4ff62ee
fix package-lock.json
krusche e1757ce
Regenerate package-lock.json to fix npm ci in CI
krusche a9824f1
Fix E2E workflow tests: UserMultiSelect selection and test resilience
krusche 267192d
Address PR review comments and reduce test flakiness
krusche 4801268
Address additional PR review comments: remove unused param, scope che…
krusche f06d484
Update DEVELOPMENT.md with new E2E workflow test coverage
krusche ad01fc0
add more e2e tests
krusche 49a279e
reduce flakiness of e2e tests
krusche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| name: E2E Tests | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| e2e: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
|
|
||
| services: | ||
| postgres: | ||
| image: postgres:18.2-alpine | ||
| env: | ||
| POSTGRES_USER: thesis-management-postgres | ||
| POSTGRES_PASSWORD: thesis-management-postgres | ||
| POSTGRES_DB: thesis-management | ||
| ports: | ||
| - 5144:5432 | ||
| options: >- | ||
| --health-cmd "pg_isready -d thesis-management -U thesis-management-postgres" | ||
| --health-interval 5s | ||
| --health-timeout 5s | ||
| --health-retries 10 | ||
|
|
||
| keycloak: | ||
| image: quay.io/keycloak/keycloak:26.4 | ||
| env: | ||
| KC_BOOTSTRAP_ADMIN_USERNAME: admin | ||
| KC_BOOTSTRAP_ADMIN_PASSWORD: admin | ||
| ports: | ||
| - 8081:8080 | ||
| # Note: realm import is handled via the entrypoint below | ||
| options: >- | ||
| --health-cmd "exec 3<>/dev/tcp/127.0.0.1/8080; echo -e 'GET /health/ready HTTP/1.1\r\nHost: localhost\r\n\r\n' >&3; head -1 <&3 | grep -q '200'" | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 30 | ||
| --health-start-period 60s | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ github.head_ref || github.ref }} | ||
| fetch-depth: 1 | ||
|
|
||
| # Import Keycloak realm (service containers can't mount volumes, so we use the REST API) | ||
| - name: Wait for Keycloak to be ready | ||
| run: | | ||
| echo "Waiting for Keycloak..." | ||
| for i in $(seq 1 60); do | ||
| if curl -sf http://localhost:8081/health/ready > /dev/null 2>&1; then | ||
| echo "Keycloak is ready" | ||
| break | ||
| fi | ||
| sleep 2 | ||
| done | ||
|
|
||
| - name: Import Keycloak realm | ||
| run: | | ||
| # Get admin token | ||
| TOKEN=$(curl -sf -X POST "http://localhost:8081/realms/master/protocol/openid-connect/token" \ | ||
| -H "Content-Type: application/x-www-form-urlencoded" \ | ||
| -d "username=admin&password=admin&grant_type=password&client_id=admin-cli" | jq -r '.access_token') | ||
|
|
||
| # Import realm | ||
| curl -sf -X POST "http://localhost:8081/admin/realms" \ | ||
| -H "Authorization: Bearer $TOKEN" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d @keycloak/thesis-management-realm.json | ||
|
|
||
| echo "Realm imported successfully" | ||
|
|
||
| # Set up Java for server | ||
| - name: Set up JDK 25 | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| java-version: '25' | ||
| distribution: 'zulu' | ||
| cache: 'gradle' | ||
|
|
||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x ./server/gradlew | ||
|
|
||
| # Start server in background with dev profile | ||
| - name: Start server | ||
| working-directory: ./server | ||
| run: ./gradlew bootRun --args='--spring.profiles.active=dev' & | ||
| env: | ||
| SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5144/thesis-management | ||
| SPRING_DATASOURCE_USERNAME: thesis-management-postgres | ||
| SPRING_DATASOURCE_PASSWORD: thesis-management-postgres | ||
| KEYCLOAK_HOST: http://localhost:8081 | ||
| KEYCLOAK_REALM_NAME: thesis-management | ||
| KEYCLOAK_CLIENT_ID: thesis-management-app | ||
| KEYCLOAK_SERVICE_CLIENT_ID: thesis-management-service-client | ||
| KEYCLOAK_SERVICE_CLIENT_SECRET: "" | ||
| CLIENT_HOST: http://localhost:3000 | ||
|
|
||
| # Set up Node.js for client | ||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '24' | ||
| cache: 'npm' | ||
| cache-dependency-path: client/package-lock.json | ||
|
|
||
| - name: Install client dependencies | ||
| working-directory: ./client | ||
| run: npm ci | ||
|
|
||
| - name: Install Playwright browsers | ||
| working-directory: ./client | ||
| run: npx playwright install --with-deps chromium | ||
|
|
||
| # Start client dev server in background | ||
| - name: Start client dev server | ||
| working-directory: ./client | ||
| run: npx webpack serve --env NODE_ENV=development & | ||
| env: | ||
| SERVER_HOST: http://localhost:8080 | ||
| KEYCLOAK_HOST: http://localhost:8081 | ||
| KEYCLOAK_REALM_NAME: thesis-management | ||
| KEYCLOAK_CLIENT_ID: thesis-management-app | ||
|
|
||
| # Wait for both services to be ready | ||
| - name: Wait for server to be ready | ||
| run: | | ||
| echo "Waiting for Spring Boot server..." | ||
| for i in $(seq 1 120); do | ||
| if curl -sf http://localhost:8080/api/actuator/health > /dev/null 2>&1; then | ||
| echo "Server is ready" | ||
| break | ||
| fi | ||
| if [ $i -eq 120 ]; then | ||
| echo "Server failed to start" | ||
| exit 1 | ||
| fi | ||
| sleep 2 | ||
| done | ||
|
|
||
| - name: Wait for client to be ready | ||
| run: | | ||
| echo "Waiting for client dev server..." | ||
| for i in $(seq 1 60); do | ||
| if curl -sf http://localhost:3000 > /dev/null 2>&1; then | ||
| echo "Client is ready" | ||
| break | ||
| fi | ||
| if [ $i -eq 60 ]; then | ||
| echo "Client failed to start" | ||
| exit 1 | ||
| fi | ||
| sleep 2 | ||
| done | ||
krusche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Run E2E tests | ||
| - name: Run Playwright tests | ||
| working-directory: ./client | ||
| run: npx playwright test | ||
| env: | ||
| CI: "1" | ||
| CLIENT_URL: http://localhost:3000 | ||
| KEYCLOAK_HOST: http://localhost:8081 | ||
| KEYCLOAK_REALM_NAME: thesis-management | ||
| KEYCLOAK_CLIENT_ID: thesis-management-app | ||
|
|
||
| - name: Upload Playwright report | ||
| uses: actions/upload-artifact@v6 | ||
| if: ${{ !cancelled() }} | ||
| with: | ||
| name: playwright-report | ||
| path: client/playwright-report/ | ||
| retention-days: 14 | ||
|
|
||
| - name: Upload test results | ||
| uses: actions/upload-artifact@v6 | ||
| if: ${{ !cancelled() }} | ||
| with: | ||
| name: playwright-results | ||
| path: client/test-results/ | ||
| retention-days: 14 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,10 @@ | |
|
|
||
| # testing | ||
| /coverage | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /blob-report/ | ||
| /e2e/.auth/ | ||
|
|
||
| # production | ||
| /build | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { test, expect } from '@playwright/test' | ||
| import { authStatePath, navigateTo } from './helpers' | ||
|
|
||
| test.describe('Applications - Student', () => { | ||
| test('submit application page shows stepper form', async ({ page }) => { | ||
| await navigateTo(page, '/submit-application') | ||
|
|
||
| await expect(page).toHaveURL(/\/submit-application/) | ||
| // The multi-step stepper form should be visible | ||
| await expect(page.locator('.mantine-Stepper-root')).toBeVisible({ timeout: 15_000 }) | ||
| }) | ||
|
|
||
| test('submit application with pre-selected topic', async ({ page }) => { | ||
| // Navigate with topic pre-selected (CI Pipeline Optimization) | ||
| await navigateTo(page, '/submit-application/00000000-0000-4000-b000-000000000002') | ||
|
|
||
| await expect(page).toHaveURL(/\/submit-application\/00000000/) | ||
| }) | ||
|
|
||
| test('dashboard shows student applications section', async ({ page }) => { | ||
| await navigateTo(page, '/dashboard') | ||
|
|
||
| await expect(page.getByRole('heading', { name: /dashboard/i })).toBeVisible({ timeout: 15_000 }) | ||
| // Student should see My Applications section | ||
| await expect(page.getByRole('heading', { name: /my applications/i })).toBeVisible() | ||
| }) | ||
| }) | ||
|
|
||
| test.describe('Applications - Advisor review', () => { | ||
| test.use({ storageState: authStatePath('advisor') }) | ||
|
|
||
| test('review page loads with application sidebar', async ({ page }) => { | ||
| await navigateTo(page, '/applications') | ||
|
|
||
| await expect(page).toHaveURL(/\/applications/) | ||
| // The page should have the sidebar with applications or an empty state | ||
| await expect(page.locator('body')).toContainText(/.+/) | ||
| }) | ||
krusche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }) | ||
|
|
||
| test.describe('Applications - Supervisor review', () => { | ||
| test.use({ storageState: authStatePath('supervisor') }) | ||
|
|
||
| test('review page is accessible', async ({ page }) => { | ||
| await navigateTo(page, '/applications') | ||
|
|
||
| await expect(page).toHaveURL(/\/applications/) | ||
| }) | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { test as setup, expect } from '@playwright/test' | ||
|
|
||
| const TEST_USERS = [ | ||
| { name: 'student', username: 'student', password: 'student' }, | ||
| { name: 'advisor', username: 'advisor', password: 'advisor' }, | ||
| { name: 'supervisor', username: 'supervisor', password: 'supervisor' }, | ||
| { name: 'admin', username: 'admin', password: 'admin' }, | ||
| ] as const | ||
|
|
||
| for (const user of TEST_USERS) { | ||
| setup(`authenticate as ${user.name}`, async ({ page }) => { | ||
| // Navigate to a protected route to trigger Keycloak login redirect | ||
| await page.goto('/dashboard') | ||
|
|
||
| // Wait for Keycloak login page to load | ||
| await expect(page.locator('#kc-login')).toBeVisible({ timeout: 30_000 }) | ||
|
|
||
| // Fill in credentials on the Keycloak login form | ||
| await page.locator('#username').fill(user.username) | ||
| await page.locator('#password').fill(user.password) | ||
| await page.locator('#kc-login').click() | ||
|
|
||
| // Wait for redirect back to the app and the dashboard to load | ||
| await expect(page).toHaveURL(/localhost:3000/, { timeout: 30_000 }) | ||
|
|
||
| // Wait for the app to fully initialize with the auth tokens | ||
| await page.waitForFunction(() => { | ||
| const tokens = localStorage.getItem('authentication_tokens') | ||
| if (!tokens) return false | ||
| const parsed = JSON.parse(tokens) | ||
| return !!parsed.access_token && !!parsed.refresh_token | ||
| }, { timeout: 15_000 }) | ||
krusche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Save the authenticated state (localStorage + cookies including Keycloak session) | ||
| await page.context().storageState({ path: `e2e/.auth/${user.name}.json` }) | ||
| }) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.