-
Notifications
You must be signed in to change notification settings - Fork 0
test(e2e): run e2e against production build #283
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the E2E testing setup to run against production builds and makes the authentication flow and rate limiting more robust and test-friendly.
Changes:
- Hardened the login E2E test to wait for the sign-in button and for navigation away from
/signin, aligning it with the shared login fixture behavior. - Introduced a configurable Better Auth rate-limit override for sign-in endpoints and wired it into the auth configuration, with environment defaults and E2E-specific values.
- Reworked Playwright config, package scripts, the dev OIDC provider, documentation, and the E2E GitHub Actions workflow so E2E tests run against a production build with a dedicated test model and consistent auth/env behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/e2e/login.spec.ts |
Makes the login flow test more robust by waiting for the OIDC/Okta button to appear and for navigation away from /signin before asserting the catalog URL. |
src/lib/auth/constants.ts |
Adds a BETTER_AUTH_RATE_LIMIT constant derived from the environment to control Better Auth rate limiting, documented specifically for E2E usage. |
src/lib/auth/auth.ts |
Plumbs BETTER_AUTH_RATE_LIMIT into the Better Auth configuration via rateLimit.customRules for /sign-in/*, relaxing rate limits when the env var is set. |
playwright.config.mts |
Switches the test web server to pnpm start:e2e (production build), updates OIDC/auth env variables, and sets E2E model-related env vars for Playwright-driven runs. |
package.json |
Updates test:e2e* scripts to set auth-related env vars, build the app, and then run Playwright; adds a start:e2e helper that starts OIDC, mock API, and the production Next server. |
dev-auth/oidc-provider.mjs |
Prevents dotenv from overriding existing env vars, expands TTL configuration for tokens and interactions, and removes an unused variable in the interaction middleware. |
CLAUDE.md |
Updates documentation to state that E2E tests run against a production build, adjusts the E2E commands, and documents the Better Auth rate-limit override used in tests. |
.github/workflows/e2e.yml |
Adjusts CI E2E env vars to match the new auth/model configuration, adds an explicit production build step before tests, and relies on pnpm test:e2e for running Playwright. |
|
@claude can you please deep review this branch? |
|
Claude finished @kantord's task in 2m 10s —— View job Deep Review of PR #283 ✅SummaryThis PR successfully addresses E2E test flakiness by running tests against production builds and making Better Auth rate limiting configurable. The implementation is well-thought-out, follows project conventions, and includes proper documentation updates. 🎯 Architectural Assessment✅ Strengths
🎨 Code QualityTypeScript Strict Mode: ✅ No 🔍 Detailed Review by File
|
| Category | Rating | Notes |
|---|---|---|
| Correctness | 🟢 Excellent | Solves the problem effectively |
| Code Quality | 🟢 Excellent | Clean, well-documented, type-safe |
| Architecture | 🟢 Excellent | Configurable, maintainable approach |
| Testing | 🟢 Excellent | Comprehensive, reliable |
| Documentation | 🟢 Excellent | Clear, thorough updates |
| Security | 🟢 Excellent | No concerns identified |
| Maintainability | 🟡 Good | Minor duplication issues |
🎯 Recommendations Summary
🔴 High Priority (Before Merge)
- Fix duplicate builds in CI workflow - Currently building twice with different env vars
🟡 Medium Priority (Consider Before Merge)
- Remove login flow duplication -
login.spec.tsduplicates code fromfixtures.ts - Centralize E2E env vars - Consider using
.env.e2efile instead of hardcoding in multiple places
🟦 Low Priority (Nice to Have)
- Add rate limit override logging - Help developers know when override is active
- Align env var names - Job-level
OIDC_PROVIDER_IDis unused due to script override
✅ Approval Recommendation
Status: ✅ Approve with suggestions
This PR successfully solves the E2E flakiness issue and improves test reliability. The implementation is solid, follows project conventions, and includes excellent documentation.
The identified issues are minor and could be addressed in a follow-up PR if desired. The duplicate build issue in CI is the only one I'd consider addressing before merge, as it wastes CI time and could cause confusion.
Great work on the root cause analysis and implementation! 🎉
Summary
Problem
E2E tests were failing intermittently with authentication timeouts. The root cause was Better Auth's default rate limit of 3 sign-in requests
per 10 seconds, enforced based on IP.
Solution
Added a configurable
BETTER_AUTH_RATE_LIMITenvironment variable that overrides the default rate limit for sign-in paths. For E2E tests, thisis set to
100to prevent rate limit errors while keeping rate limiting enabled in production.https://stacklok.slack.com/archives/C072SGY78TS/p1769508282379179