Skip to content

Commit ed46526

Browse files
committed
feat(e2e): add permission-based project dashboard tests
- Add writer permission override option to ApiMockHelper.setupProjectSlugMock() - Add comprehensive tests for users without write permissions - Add writer property to mock project data for permission testing - Restructure tests with permission-based describe blocks - Fix GitHub Actions e2e workflow to use exit codes instead of .last-run.json - Test Quick Actions menu visibility based on permissions - Test empty state buttons (Create Meeting, Add Committee) are hidden for read-only - Test read-only users can still access all view-only functionality - Test responsive design for read-only users 🤖 Generated with [Claude Code](https://claude.ai/code) Signed-off-by: Asitha de Silva <asithade@gmail.com>
1 parent 20e6b82 commit ed46526

File tree

4 files changed

+407
-241
lines changed

4 files changed

+407
-241
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,32 +244,40 @@ jobs:
244244
run: yarn build
245245

246246
- name: Run E2E tests (All browsers)
247+
id: run-tests-all
247248
if: ${{ inputs.browser == 'all' && steps.validate-secrets.outputs.can_run_tests == 'true' }}
248249
working-directory: apps/lfx-pcc
250+
continue-on-error: true
249251
run: |
250252
if [ -n "$TEST_USERNAME" ] && [ -n "$TEST_PASSWORD" ]; then
251253
echo "🔐 Running authenticated E2E tests on all browsers"
252254
echo "🚀 Playwright will automatically start the dev server on localhost:4200"
253255
echo "📋 Using secrets from AWS Secrets Manager"
254256
yarn ${{ inputs.test-command }} --reporter=list
257+
echo "test_exit_code=$?" >> $GITHUB_OUTPUT
255258
else
256259
echo "⚠️ No test credentials provided. Skipping E2E tests."
257260
echo "Set TEST_USERNAME and TEST_PASSWORD secrets to enable E2E tests."
261+
echo "test_exit_code=0" >> $GITHUB_OUTPUT
258262
exit 0
259263
fi
260264
261265
- name: Run E2E tests (Specific browser)
266+
id: run-tests-specific
262267
if: ${{ inputs.browser != 'all' && steps.validate-secrets.outputs.can_run_tests == 'true' }}
263268
working-directory: apps/lfx-pcc
269+
continue-on-error: true
264270
run: |
265271
if [ -n "$TEST_USERNAME" ] && [ -n "$TEST_PASSWORD" ]; then
266272
echo "🔐 Running authenticated E2E tests on ${{ inputs.browser }}"
267273
echo "🚀 Playwright will automatically start the dev server on localhost:4200"
268274
echo "📋 Using secrets from AWS Secrets Manager"
269275
yarn ${{ inputs.test-command }} --project=${{ inputs.browser }} --reporter=list
276+
echo "test_exit_code=$?" >> $GITHUB_OUTPUT
270277
else
271278
echo "⚠️ No test credentials provided. Skipping E2E tests."
272279
echo "Set TEST_USERNAME and TEST_PASSWORD secrets to enable E2E tests."
280+
echo "test_exit_code=0" >> $GITHUB_OUTPUT
273281
exit 0
274282
fi
275283
@@ -299,12 +307,25 @@ jobs:
299307
elif [ -z "$TEST_USERNAME" ] || [ -z "$TEST_PASSWORD" ]; then
300308
echo "⏭️ E2E tests skipped (no test credentials)"
301309
echo "results=skipped" >> $GITHUB_OUTPUT
302-
elif [ -f "test-results/.last-run.json" ]; then
303-
echo "✅ E2E tests completed successfully"
304-
echo "results=success" >> $GITHUB_OUTPUT
305310
else
306-
echo "❌ E2E tests failed"
307-
echo "results=failure" >> $GITHUB_OUTPUT
311+
# Check exit codes from test execution steps
312+
ALL_EXIT_CODE="${{ steps.run-tests-all.outputs.test_exit_code }}"
313+
SPECIFIC_EXIT_CODE="${{ steps.run-tests-specific.outputs.test_exit_code }}"
314+
315+
# Determine which test was run and check its exit code
316+
if [ "${{ inputs.browser }}" == "all" ]; then
317+
EXIT_CODE="$ALL_EXIT_CODE"
318+
else
319+
EXIT_CODE="$SPECIFIC_EXIT_CODE"
320+
fi
321+
322+
if [ "$EXIT_CODE" == "0" ]; then
323+
echo "✅ E2E tests completed successfully"
324+
echo "results=success" >> $GITHUB_OUTPUT
325+
else
326+
echo "❌ E2E tests failed (exit code: $EXIT_CODE)"
327+
echo "results=failure" >> $GITHUB_OUTPUT
328+
fi
308329
fi
309330
310331
- name: Comment test results on PR

apps/lfx-pcc/e2e/fixtures/mock-data/projects.mock.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const mockProjects: Record<string, Project> = {
3333
committees_count: 5,
3434
meetings_count: 23,
3535
mailing_list_count: 8,
36+
writer: true,
3637
},
3738
cncf: {
3839
uid: 'b09f1234-f567-4abc-b890-1234567890bc',
@@ -59,6 +60,7 @@ export const mockProjects: Record<string, Project> = {
5960
committees_count: 12,
6061
meetings_count: 156,
6162
mailing_list_count: 25,
63+
writer: false,
6264
},
6365
kubernetes: {
6466
uid: 'c09f1234-f567-4abc-b890-1234567890cd',
@@ -84,6 +86,7 @@ export const mockProjects: Record<string, Project> = {
8486
committees_count: 8,
8587
meetings_count: 89,
8688
mailing_list_count: 15,
89+
writer: false,
8790
},
8891
};
8992

apps/lfx-pcc/e2e/helpers/api-mock.helper.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ export class ApiMockHelper {
1313
/**
1414
* Setup mock for the project slug endpoint only
1515
* @param page - Playwright page instance
16+
* @param options - Optional configuration for the mock
17+
* @param options.writer - Override the writer permission for the project
1618
*/
17-
static async setupProjectSlugMock(page: Page): Promise<void> {
19+
static async setupProjectSlugMock(page: Page, options?: { writer?: boolean }): Promise<void> {
1820
// Mock individual project by slug endpoint (/api/projects/:slug)
1921
await page.route('**/api/projects/*', async (route) => {
2022
const url = route.request().url();
@@ -44,10 +46,16 @@ export class ApiMockHelper {
4446
return;
4547
}
4648

49+
// Apply writer permission override if provided
50+
let finalProject = project;
51+
if (options?.writer !== undefined) {
52+
finalProject = { ...project, writer: options.writer };
53+
}
54+
4755
await route.fulfill({
4856
status: 200,
4957
contentType: 'application/json',
50-
body: JSON.stringify(project),
58+
body: JSON.stringify(finalProject),
5159
});
5260
});
5361
}

0 commit comments

Comments
 (0)