Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/actions/setup-playwright/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright The Linux Foundation and each contributor to LFX.
# SPDX-License-Identifier: MIT

name: Setup Playwright
description: Install Playwright and cache browser dependencies
inputs:
browser:
description: 'Browser to test (chromium, firefox, mobile-chrome, or all)'
required: false
default: 'all'
runs:
using: "composite"
steps:
# Run npm ci and get Playwright version
- name: 🏗 Prepare Playwright env
shell: bash
run: |
PLAYWRIGHT_VERSION=$(npm ls --json @playwright/test | jq --raw-output '.dependencies["@playwright/test"].version')
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
# Cache browser binaries, cache key is based on Playwright version and OS
- name: 🧰 Cache Playwright browser binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: "~/.cache/ms-playwright"
key: "${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}"
restore-keys: |
${{ runner.os }}-playwright-
# Install browser binaries & OS dependencies if cache missed
- name: 🏗 Install Playwright browser binaries & OS dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash
run: |
if [ "${{ inputs.browser }}" == "all" ]; then
npm exec -- playwright install --with-deps
else
npm exec -- playwright install --with-deps ${{ inputs.browser }}
fi
# Install only the OS dependencies if cache hit
- name: 🏗 Install Playwright OS dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
shell: bash
run: |
if [ "${{ inputs.browser }}" == "all" ]; then
npm exec -- playwright install-deps
else
npm exec -- playwright install-deps ${{ inputs.browser }}
fi
11 changes: 8 additions & 3 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,11 @@ jobs:
echo "TEST_PASSWORD=${{ secrets.TEST_PASSWORD }}" >> $GITHUB_ENV
echo "✅ TEST_USERNAME and TEST_PASSWORD secrets set as masked environment variables"

- name: Install Playwright browsers
- name: Setup Playwright with caching
if: steps.validate-secrets.outputs.can_run_tests == 'true'
working-directory: apps/lfx-pcc
run: npx playwright install --with-deps
uses: ./.github/actions/setup-playwright
with:
browser: ${{ inputs.browser }}

- name: Create Playwright auth directory
if: steps.validate-secrets.outputs.can_run_tests == 'true'
Expand All @@ -244,17 +245,21 @@ jobs:
run: yarn build

- name: Run E2E tests (All browsers)
id: run-tests-all
if: ${{ inputs.browser == 'all' && steps.validate-secrets.outputs.can_run_tests == 'true' }}
working-directory: apps/lfx-pcc
continue-on-error: true
run: |
if [ -n "$TEST_USERNAME" ] && [ -n "$TEST_PASSWORD" ]; then
echo "🔐 Running authenticated E2E tests on all browsers"
echo "🚀 Playwright will automatically start the dev server on localhost:4200"
echo "📋 Using secrets from AWS Secrets Manager"
yarn ${{ inputs.test-command }} --reporter=list
echo "test_exit_code=$?" >> $GITHUB_OUTPUT
else
echo "⚠️ No test credentials provided. Skipping E2E tests."
echo "Set TEST_USERNAME and TEST_PASSWORD secrets to enable E2E tests."
echo "test_exit_code=0" >> $GITHUB_OUTPUT
exit 0
fi

Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"supabase",
"timegrid",
"Turborepo",
"Uids",
"viewports"
],
"scss.lint.unknownAtRules": "ignore",
Expand Down
3 changes: 3 additions & 0 deletions apps/lfx-pcc/e2e/fixtures/mock-data/projects.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const mockProjects: Record<string, Project> = {
committees_count: 5,
meetings_count: 23,
mailing_list_count: 8,
writer: true,
},
cncf: {
uid: 'b09f1234-f567-4abc-b890-1234567890bc',
Expand All @@ -59,6 +60,7 @@ export const mockProjects: Record<string, Project> = {
committees_count: 12,
meetings_count: 156,
mailing_list_count: 25,
writer: false,
},
kubernetes: {
uid: 'c09f1234-f567-4abc-b890-1234567890cd',
Expand All @@ -84,6 +86,7 @@ export const mockProjects: Record<string, Project> = {
committees_count: 8,
meetings_count: 89,
mailing_list_count: 15,
writer: false,
},
};

Expand Down
12 changes: 10 additions & 2 deletions apps/lfx-pcc/e2e/helpers/api-mock.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export class ApiMockHelper {
/**
* Setup mock for the project slug endpoint only
* @param page - Playwright page instance
* @param options - Optional configuration for the mock
* @param options.writer - Override the writer permission for the project
*/
static async setupProjectSlugMock(page: Page): Promise<void> {
static async setupProjectSlugMock(page: Page, options?: { writer?: boolean }): Promise<void> {
// Mock individual project by slug endpoint (/api/projects/:slug)
await page.route('**/api/projects/*', async (route) => {
const url = route.request().url();
Expand Down Expand Up @@ -44,10 +46,16 @@ export class ApiMockHelper {
return;
}

// Apply writer permission override if provided
let finalProject = project;
if (options?.writer !== undefined) {
finalProject = { ...project, writer: options.writer };
}

await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(project),
body: JSON.stringify(finalProject),
});
});
}
Expand Down
Loading