Skip to content

fix(auth): clean up stale test users before signup in integration tests#3441

Merged
PierreBrisorgueil merged 2 commits intomasterfrom
fix/auth-integration-cleanup-3437
Apr 9, 2026
Merged

fix(auth): clean up stale test users before signup in integration tests#3441
PierreBrisorgueil merged 2 commits intomasterfrom
fix/auth-integration-cleanup-3437

Conversation

@PierreBrisorgueil
Copy link
Copy Markdown
Contributor

Summary

  • Auth integration tests used hardcoded emails without database cleanup before each run
  • On shared MongoDB instances (ARC self-hosted runners), stale data from previous CI runs caused cascading test failures (signup returns 422 instead of 200)
  • Added pre-signup purgeUser cleanup in all beforeAll/beforeEach hooks across the four auth integration test files

Files changed

  • modules/auth/tests/auth.integration.tests.js — Registration, Password reset, Security, Email verification, Account lockout sections
  • modules/auth/tests/auth.abilities.integration.tests.js — beforeAll cleanup
  • modules/auth/tests/auth.authorization.integration.tests.js — beforeAll cleanup
  • modules/auth/tests/auth.signup.organization.integration.tests.js — per-test cleanup via purgeUser helper (also cleans org/membership data)

Test plan

  • All 92 auth integration tests pass locally (50 + 9 + 27 + 6)
  • All 492 unit tests pass
  • Lint passes with no errors
  • CI green on shared MongoDB runner

Closes #3437

Auth integration tests used hardcoded emails without cleaning the
database before each run. On shared MongoDB instances (e.g. ARC
self-hosted runners), stale data from previous CI runs caused
cascading test failures.

Add pre-signup cleanup in all beforeAll/beforeEach hooks across
the four auth integration test files to purge any leftover users
by email before attempting signup.

Closes #3437
Copilot AI review requested due to automatic review settings April 9, 2026 05:51
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

Warning

Rate limit exceeded

@PierreBrisorgueil has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 39 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 12 minutes and 39 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 014ebe12-51b9-4a17-ae2d-0e6d473c4cc4

📥 Commits

Reviewing files that changed from the base of the PR and between b4e2da9 and 4f04285.

📒 Files selected for processing (4)
  • modules/auth/tests/auth.abilities.integration.tests.js
  • modules/auth/tests/auth.authorization.integration.tests.js
  • modules/auth/tests/auth.integration.tests.js
  • modules/auth/tests/auth.signup.organization.integration.tests.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/auth-integration-cleanup-3437

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.51%. Comparing base (b4e2da9) to head (4f04285).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3441   +/-   ##
=======================================
  Coverage   85.51%   85.51%           
=======================================
  Files         113      113           
  Lines        2879     2879           
  Branches      795      795           
=======================================
  Hits         2462     2462           
  Misses        331      331           
  Partials       86       86           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes auth integration test flakiness on shared MongoDB runners by proactively removing stale users before signups that use hardcoded emails.

Changes:

  • Added pre-signup cleanup (via UserService.getBrut + UserService.remove) in beforeAll/beforeEach hooks across auth integration test suites.
  • Introduced a purgeUser(email) helper in the signup-organization integration tests and called it before creating users with fixed emails.
  • Applied the cleanup pattern to authorization and abilities integration tests to prevent cascading failures from prior CI runs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
modules/auth/tests/auth.integration.tests.js Purges known hardcoded test users before registration/password reset/security/verification/lockout setup.
modules/auth/tests/auth.abilities.integration.tests.js Purges abilities test users before creating them in beforeAll.
modules/auth/tests/auth.authorization.integration.tests.js Purges authorization test users before creating them in beforeAll.
modules/auth/tests/auth.signup.organization.integration.tests.js Adds purgeUser helper and uses it to remove stale org-signup users prior to signup requests.

@PierreBrisorgueil PierreBrisorgueil merged commit 77b6994 into master Apr 9, 2026
5 checks passed
@PierreBrisorgueil PierreBrisorgueil deleted the fix/auth-integration-cleanup-3437 branch April 9, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auth integration tests fail on shared MongoDB (no database cleanup)

2 participants