feat: expand Playwright E2E coverage (#155)
* feat: comprehensive Playwright E2E test rewrite Rewrite all E2E tests with correct CSS selectors, add new spec files, and implement robust auth handling to work within backend rate limits. Changes: - Rewrite fixtures/index.ts with JWT-based /auth/me mock to avoid 10 req/min rate limit on /auth/me during test runs - Rewrite auth.setup.ts with offline JWT validity check to reuse existing auth state across runs (saves login rate-limit budget) - Rewrite auth.spec.ts (6 tests) - login page, fields, submit, redirect guard, invalid credentials, login/register toggle - Rewrite dashboard.spec.ts (8 tests) - header, nav tabs, navigation, overview/schedules sections, days selector, redirect - Rewrite medications.spec.ts (8 tests) - form fields, stock inventory, package type toggle, intake schedule, save/cancel, unsaved changes guard - Rewrite settings.spec.ts (12 tests) - language, notification matrix, thresholds, calculation mode, toggle switch, export/import, user menu navigation - Create planner.spec.ts (9 tests) - form, date inputs, calculate, reset, checkbox, submit, tab state, eyebrow heading - Create schedule.spec.ts (12 tests) - timeline, days selector, past/future toggles, day blocks, today highlight, collapse/expand, overview table, share button - Update playwright.config.ts: remove mobile projects, enable webServer section for CI - Add .github/workflows/e2e.yml CI workflow for Playwright tests Total: 57 E2E tests across 6 spec files, all passing consistently across 5+ consecutive runs without backend restart. Closes #154 * feat: add comprehensive E2E data tests with medication CRUD, dashboard, planner, schedule Add 48 new Playwright E2E tests covering real medication data scenarios: - medication-crud: 14 tests for create/edit/delete/list via UI form - dashboard-data: 13 tests for overview table, timeline, dose tracking - planner-data: 9 tests for demand calculator with results/status chips - schedule-data: 11 tests for timeline, collapse/expand, dose mark/undo Infrastructure improvements: - Add API helpers (createMedicationViaAPI, deleteMedicationViaAPI, deleteAllMedicationsViaAPI) with retry logic for rate-limit resilience - Configure chromium-data project for serial execution with retry:1 - Add /auth/me mock to avoid rate-limit exhaustion on auth endpoint - Increase navigateTo reliability with networkidle waits - Increase auth token validity threshold from 2 to 10 minutes - Make backend rate limit configurable via RATE_LIMIT_MAX env var - Set RATE_LIMIT_MAX=300 in dev docker-compose for E2E test support Total suite: 57 empty-state + 48 data tests = 105 tests (chromium) * test: add E2E tests for medication editing, stock status, and share schedule - medication-edit.spec.ts: 10 tests covering generic name, notes, taken-by add/remove, expiry date, refill, intake schedule editing, adding intake rows, reminder toggle, and package type changes - stock-status.spec.ts: 12 tests verifying dashboard shows correct status chips (High/Normal/Warning/Danger) for different stock levels, overview table, reorder card, detail modal, and planner integration - share-schedule.spec.ts: 10 tests for taken-by badges, share button, share dialog, link generation, shared schedule page navigation, dose tracking on shared page, and notes display - fixtures/index.ts: add createShareTokenViaAPI, updateSettingsViaAPI helpers; expand createMedicationViaAPI with takenBy, notes, expiryDate - playwright.config.ts: update testMatch/testIgnore for new test files - docker-compose.dev.yml: increase RATE_LIMIT_MAX to 1000 for E2E tests * docs: refine release-manager instructions for CLI safety and commit-linked release notes * fix: resolve PR155 CI failures for frontend lint and e2e proxy * fix: stabilize auth-related e2e checks in CI
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
- **Tests are mandatory**: Every new feature and every bug fix MUST have corresponding tests. When modifying existing features, update or add tests accordingly. If old tests become obsolete due to code changes, remove or update them.
|
||||
- **Fix bugs, don't test around them**: If you discover incorrect behavior in the code while writing tests, ALWAYS fix the buggy code first, then write tests that verify the correct behavior. NEVER write tests that mimic or assert broken behavior. The user's time is finite and irreplaceable — every bug left unfixed wastes it.
|
||||
- **Keep README.md up to date**: After implementing code changes, check whether the `README.md` needs to be updated (e.g., new features, changed ENV variables, new commands, changed architecture, new endpoints, updated screenshots). If changes are relevant to the README, **ask the user for confirmation** before updating it. Do NOT silently update the README — always present the proposed README changes and wait for approval. Examples of README-relevant changes: new ENV variables, new API endpoints, new UI features, changed setup/install steps, new dependencies, changed Docker configuration.
|
||||
- **Track work in GitHub Project**: All features, bugs, and tasks MUST be tracked in the [GitHub Project board](https://github.com/users/DanielVolz/projects/1). Before starting work, ensure a corresponding issue exists. Use the `enhancement`, `bug`, or `triage` labels so the issue is automatically added to the board. Update the issue status as work progresses (Triage → Backlog → Ready → In progress → Done).
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
@@ -51,6 +52,17 @@ cd backend && npm test # Run all tests
|
||||
cd backend && npm run test:coverage # Run with coverage report
|
||||
```
|
||||
|
||||
## GitHub CLI Safety (Non-Interactive Only)
|
||||
|
||||
- Never use `gh` commands that can open an interactive pager and block execution (requiring `q`).
|
||||
- Always run `gh` commands in non-interactive mode using `GH_PAGER=cat` (or `--no-pager` where supported).
|
||||
- Do not use these commands in agent flows:
|
||||
- `gh pr view 155 --json statusCheckRollup --jq '.statusCheckRollup[] | {name:.name,conclusion:.conclusion,detailsUrl:.detailsUrl,workflowName:.workflowName}'`
|
||||
- `SHA=$(gh pr view 155 --json headRefOid --jq .headRefOid) && gh api repos/DanielVolz/medassist-ng/commits/$SHA/check-runs --jq '.check_runs[] | {name,conclusion,details_url,html_url,app:.app.name}'`
|
||||
- Use safe variants instead:
|
||||
- `GH_PAGER=cat gh pr view <PR_NUMBER> --json statusCheckRollup --jq '<jq-filter>'`
|
||||
- `GH_PAGER=cat gh api repos/<owner>/<repo>/commits/<sha>/check-runs --jq '<jq-filter>'`
|
||||
|
||||
## Testing (MANDATORY)
|
||||
|
||||
> ⚠️ **IMPORTANT**: Every new feature MUST be covered by tests!
|
||||
@@ -187,6 +199,7 @@ gh pr merge --squash --delete-branch
|
||||
| `.github/workflows/docker-build.yml` | Push to main, Tags | Build and push Docker images (+ create GitHub release on tags) |
|
||||
| `.github/workflows/update-test-badges.yml` | After successful docker-build | Update test count badges in README |
|
||||
| `.github/workflows/codeql.yml` | Push to main, PRs, Weekly | Security analysis |
|
||||
| `.github/workflows/add-to-project.yml` | Issues opened/labeled | Auto-add issues with `enhancement`, `bug`, or `triage` labels to GitHub Project |
|
||||
|
||||
## Key Patterns
|
||||
|
||||
@@ -464,3 +477,52 @@ If a breaking change is unavoidable:
|
||||
| Docker prod | `docker-compose.yml` |
|
||||
| Docker dev | `docker-compose.dev.yml` |
|
||||
| Env template | `.env.example` |
|
||||
| Project setup | `docs/PROJECT_SETUP.md` |
|
||||
|
||||
## GitHub Project Management
|
||||
|
||||
All work is tracked in the [GitHub Project board](https://github.com/users/DanielVolz/projects/1) (Project ID: `PVT_kwHOADH82s4BO2OT`).
|
||||
|
||||
### Board Columns (Status)
|
||||
| Column | Color | Description |
|
||||
|--------|-------|-------------|
|
||||
| Triage | Purple | New issues needing review |
|
||||
| Backlog | Green | Accepted, not yet started |
|
||||
| Ready | Blue | Ready to be picked up |
|
||||
| In progress | Yellow | Currently being worked on |
|
||||
| Done | Orange | Completed |
|
||||
|
||||
### Custom Fields
|
||||
| Field | Options | Usage |
|
||||
|-------|---------|-------|
|
||||
| **Type** | Bug (red), Feature (green), Chore (gray), Documentation (blue) | Categorize the work |
|
||||
| **Priority** | High (red), Medium (orange), Low (yellow) | Set urgency |
|
||||
| **Size** | XS, S, M, L, XL | Estimate effort |
|
||||
|
||||
### Agent Workflow for Issues
|
||||
|
||||
1. **Before starting work**: Check the Project board for existing issues. If the task has no issue yet, create one:
|
||||
```bash
|
||||
gh issue create --title "feat: description" --label enhancement
|
||||
```
|
||||
Issues with `enhancement`, `bug`, or `triage` labels are **automatically added** to the Project board.
|
||||
|
||||
2. **When starting work**: Move the issue to "In progress":
|
||||
```bash
|
||||
# List items to find the item ID
|
||||
gh project item-list 1 --owner DanielVolz
|
||||
# Update status (use GraphQL for field updates)
|
||||
```
|
||||
|
||||
3. **When work is done locally**: Leave in "In progress" and tell the user to invoke `@release-manager`.
|
||||
|
||||
4. **After merge**: The issue moves to "Done" (via `closes #N` in PR body or manually).
|
||||
|
||||
### Issue Labels
|
||||
| Label | Applied by | Purpose |
|
||||
|-------|-----------|--------|
|
||||
| `enhancement` | Feature request template | New features |
|
||||
| `bug` | Bug report template | Bug fixes |
|
||||
| `triage` | Both templates | Needs review |
|
||||
|
||||
All three labels trigger the `add-to-project.yml` workflow, which automatically adds the issue to the Project board.
|
||||
|
||||
Reference in New Issue
Block a user