test(organizations): membership lifecycle HTTP e2e (add/accept/promote/leave/decline)#3860
Conversation
Covers POST /members, the GET /members/search before-:memberId route ordering, the auth-only accept and decline endpoints, promote via the :memberId param middleware, leave, pending owner_add visibility in the members list, and the 422 duplicate-add guard — all through real routes, passport, CASL, and param middleware. Restores the HTTP coverage lost when the invite-lifecycle e2e was removed. refs #3835
|
Warning Review limit reached
More reviews will be available in 7 minutes and 19 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3860 +/- ##
=======================================
Coverage 92.37% 92.37%
=======================================
Files 160 160
Lines 5361 5361
Branches 1723 1723
=======================================
Hits 4952 4952
Misses 328 328
Partials 81 81
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds HTTP-level end-to-end coverage for the organizations “owner-add” membership lifecycle, exercising real Express routes with passport auth, CASL, and param middleware (restoring coverage previously lost for promote/leave flows).
Changes:
- Adds a new e2e suite that covers add-member → pending visibility → accept → promote → leave via real HTTP endpoints.
- Extends coverage to include the decline flow and the duplicate-add (422) guard.
- unique per-run email suffixes (Date.now) eliminate dirty-db re-run flakiness - config set in beforeAll, restored in afterAll; test-2 guards shared state with clear expect() - duplicate-add guard chains .expect(422) so a 500 is no longer swallowed - post-leave / post-decline assertions use identity (no B-row) instead of bare counts - decline DELETE asserts body.message === 'membership invitation declined' refs #3835
Documents cleanupUser's async return and rewrites the misleading --runInBand comment (it schedules files, not test() order). refs #3835
Summary
Restores HTTP-level e2e coverage for the org membership lifecycle (P4 deleted the only HTTP coverage for promote/leave; P5a replaced it with mocked unit tests). New
organizations.memberAdd.e2e.tests.jsexercises the real routes through passport + CASL + param middleware:mine/pending→ B accepts → A promotes B → B leaves → members list back to A.DELETE /membership-requests/:id→ row gone frommine/pendingand the members list.Test plan
npm run test:all -- --testPathPatterns='organizations.memberAdd.e2e'→ 1 suite, 2 tests green. Lint clean. (Test-only — no production code.)Closes #3835