Skip to content

Commit e75ffd5

Browse files
ci: enhance E2E testing with badge generation and update README
1 parent 69e53b5 commit e75ffd5

4 files changed

Lines changed: 36 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,22 @@ jobs:
214214
E2E_USER_PASSWORD: E2eUser!Passw0rd
215215
E2E_ADMIN_EMAIL: [email protected]
216216
E2E_ADMIN_PASSWORD: E2eAdmin!Passw0rd
217-
run: npm run test:e2e
217+
PLAYWRIGHT_JSON_OUTPUT_FILE: e2e-results.json
218+
run: npm run test:e2e -- --reporter=list,json
219+
220+
- name: Generate badge data
221+
working-directory: frontend
222+
run: |
223+
PASSED=$(jq '.stats.expected' e2e-results.json)
224+
mkdir -p badges
225+
printf '{"schemaVersion":1,"label":"e2e tests","message":"%s passing","color":"brightgreen"}' "$PASSED" > badges/e2e-tests.json
226+
227+
- name: Upload badge data
228+
uses: actions/upload-artifact@v7
229+
with:
230+
name: badges-e2e
231+
path: frontend/badges/
232+
retention-days: 1
218233

219234
- name: Upload failure artifacts
220235
if: failure()
@@ -268,9 +283,9 @@ jobs:
268283
269284
badges:
270285
name: Update badge data
271-
needs: [backend, frontend]
286+
needs: [backend, frontend, e2e]
272287
# Only refresh badge data on green pushes to the default branch.
273-
if: github.event_name == 'push' && needs.backend.result == 'success' && needs.frontend.result == 'success'
288+
if: github.event_name == 'push' && needs.backend.result == 'success' && needs.frontend.result == 'success' && needs.e2e.result == 'success'
274289
runs-on: ubuntu-latest
275290
permissions:
276291
contents: write
@@ -288,6 +303,11 @@ jobs:
288303
name: badges-frontend
289304
path: docs/badges
290305

306+
- uses: actions/download-artifact@v8
307+
with:
308+
name: badges-e2e
309+
path: docs/badges
310+
291311
- name: Commit badge data
292312
run: |
293313
# Author the commit as the user who triggered the push (resolved to

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![CI](https://github.com/mustafasercansak/zerotrust/actions/workflows/ci.yml/badge.svg)](https://github.com/mustafasercansak/zerotrust/actions/workflows/ci.yml)
44
[![Backend Tests](https://img.shields.io/endpoint?url=https://mustafasercansak.github.io/zerotrust/badges/backend-tests.json)](https://github.com/mustafasercansak/zerotrust/actions/workflows/ci.yml)
55
[![Frontend Tests](https://img.shields.io/endpoint?url=https://mustafasercansak.github.io/zerotrust/badges/frontend-tests.json)](https://github.com/mustafasercansak/zerotrust/actions/workflows/ci.yml)
6+
[![E2E Tests](https://img.shields.io/endpoint?url=https://mustafasercansak.github.io/zerotrust/badges/e2e-tests.json)](https://github.com/mustafasercansak/zerotrust/actions/workflows/ci.yml)
67
[![Backend Coverage](https://img.shields.io/endpoint?url=https://mustafasercansak.github.io/zerotrust/badges/backend-coverage.json)](https://github.com/mustafasercansak/zerotrust/actions/workflows/ci.yml)
78
[![Frontend Coverage](https://img.shields.io/endpoint?url=https://mustafasercansak.github.io/zerotrust/badges/frontend-coverage.json)](https://github.com/mustafasercansak/zerotrust/actions/workflows/ci.yml)
89
[![Go Version](https://img.shields.io/github/go-mod/go-version/mustafasercansak/zerotrust?filename=backend/go.mod)](backend/go.mod)

docs/badges/e2e-tests.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"schemaVersion":1,"label":"e2e tests","message":"97 passing","color":"brightgreen"}

frontend/e2e/auth-flow.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,23 @@ test.describe("Admin flow", () => {
9898
});
9999

100100
test("users page lists at least one user", async ({ page }) => {
101+
// Wait for the data to actually arrive before asserting on grid rows —
102+
// index-based row checks race the fetch on slow runners (CI).
103+
const usersLoaded = page.waitForResponse(
104+
(r) => r.url().includes("/api/v1/admin/users") && r.status() === 200,
105+
);
101106
await page.goto("/dashboard/users");
107+
await usersLoaded;
108+
// DataGrid row 0 is the header; row 1 is the first data row.
102109
await expect(page.getByRole("row").nth(1)).toBeVisible({ timeout: 8_000 });
103110
});
104111

105112
test("audit log page loads events", async ({ page }) => {
113+
const auditLoaded = page.waitForResponse(
114+
(r) => r.url().includes("/api/v1/admin/audit?") && r.status() === 200,
115+
);
106116
await page.goto("/dashboard/audit");
117+
await auditLoaded;
107118
await expect(page.getByRole("row").nth(1)).toBeVisible({ timeout: 8_000 });
108119
});
109120

0 commit comments

Comments
 (0)