Skip to content
Closed
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
7 changes: 7 additions & 0 deletions docs/design/testing-gaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ pds-core callback, full OAuth flow).
- Consider exporting `buildSocialProviders` for direct unit testing.
- The OTP email wiring is best verified by integration or e2e tests
that trigger a real OTP flow.
- `extractOtp` in `e2e/support/mailpit.ts` uses heuristic regex patterns
rather than `OTP_LENGTH` / `OTP_CHARSET` env vars. This is slightly flaky
by nature — the robust alternative would be keeping those env vars in sync
between the deployed service and `e2e/.env`, but that requires manual
coordination on every config change and is error-prone across environments
(e.g. Railway vs local). The heuristic is preferred since the email
templates are in-repo and their structure is stable.

### 4. `auth-service/src/context.ts` and `index.ts` (0%)

Expand Down
6 changes: 6 additions & 0 deletions e2e/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ E2E_MAILPIT_URL=https://mailpit.example.com
E2E_MAILPIT_USER=admin
E2E_MAILPIT_PASS=

# ── Internal API ──────────────────────────────────────────────────────────────
# Required for internal-api.feature scenarios. Leave empty to skip them.
# Must match EPDS_INTERNAL_SECRET on the pds-core service.
# Copy from the root .env file — it mirrors the Railway environment.
E2E_EPDS_INTERNAL_SECRET=

# ── Optional ──────────────────────────────────────────────────────────────────

# Set to 'true' to run headless (no visible browser window). Default: false.
Expand Down
17 changes: 12 additions & 5 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,18 @@ the verification code without a real mail server.

### How the suite uses Mailpit

- **Before each scenario** — the `Before` hook calls
`DELETE /api/v1/messages` to wipe the inbox, ensuring a clean slate.
- **Email steps** — poll `GET /api/v1/search?query=to:<email>` every 500 ms
until the OTP email arrives (up to 15 seconds), then fetch the plain-text
view at `/view/<id>.txt` and extract the code with a regex.
- **Scenario hygiene** — the global setup clears any leftover inbox state at
suite start, and per-scenario cleanup deletes messages for the scenario's
test recipient to avoid cross-scenario bleed.
- **OTP retrieval** — before triggering OTP send for a recipient, tests clear
`to:<email>` via Mailpit search delete. After submit, they poll
`GET /api/v1/search?query=to:<email>` every 500 ms until an OTP email
arrives.
- **Why clear before send** — this prevents stale OTP reuse when multiple OTP
emails are sent to the same recipient in one scenario (for example composed
setup + login, secondary-session login, retries, and resend flows).
- **Code extraction** — once an email is found, tests fetch
`/view/<id>.txt` and extract the OTP with a regex.
- **Auth** — requests use HTTP Basic auth (`E2E_MAILPIT_USER` /
`E2E_MAILPIT_PASS`) encoded as an `Authorization: Basic ...` header.

Expand Down
9 changes: 7 additions & 2 deletions e2e/cucumber.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
export default {
paths: ['features/passwordless-authentication.feature'],
paths: [
'features/passwordless-authentication.feature',
'features/automatic-account-creation.feature',
'features/consent-screen.feature',
'features/account-settings.feature',
],
Comment on lines +2 to +7
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if internal-api.feature exists in the features directory
fd -t f 'internal-api.feature' features/

Repository: hypercerts-org/ePDS

Length of output: 92


Add internal-api.feature to the paths array.

The file features/internal-api.feature exists in the repository but is not listed in the paths array. If this feature file was added in this PR and is ready for testing, include it here.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@e2e/cucumber.mjs` around lines 2 - 7, The paths array in e2e/cucumber.mjs is
missing the new feature file; update the paths array (the paths variable/entry
list) to include 'features/internal-api.feature' alongside the existing entries
so Cucumber will run that feature (i.e., add 'features/internal-api.feature' to
the paths array declaration).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as @aspiers mentioned in one of the comments above maybe it shouldnt be tested. also i added it since it was in the initial list of feature files but maybe better to not have it since it isnt really e2e

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

import: ['e2e/step-definitions/**/*.ts', 'e2e/support/**/*.ts'],
format: ['pretty', 'html:reports/e2e.html'],
tags: 'not @manual',
tags: 'not @manual and not @docker-only and not @pending',
strict: true,
}
Loading
Loading