Skip to content

test(e2e): cover the user delete check end to end - #2028

Open
AmanGIT07 wants to merge 1 commit into
feat/user-delete-checkfrom
test/user-delete-check
Open

AmanGIT07 wants to merge 1 commit into
feat/user-delete-checkfrom
test/user-delete-check

Conversation

@AmanGIT07

Copy link
Copy Markdown
Contributor

Stacked on #2027. Merge #2022 and #2027 first.

Summary

End-to-end tests for the user delete check in #2027. The admin user delete is refused while anything blocks it, and nothing changes. It deletes the orgs where the user is the only member. After a failed step, the next try continues from where the last one stopped.

Changes

  • test/e2e/regression/api_test.go: TestUserDeleteWithOrgs, five cases:
    • The user is the only owner of an org with another member, and alone in an org whose offline billing account is at -30 tokens. The delete is refused with two violations, SOLE_OWNER_WITH_MEMBERS and NEGATIVE_TOKEN_BALANCE. The user, the orgs, the balance and the user's membership stay as they were. Once that org has a second owner and the usage is refunded, the delete goes through: the orgs where the user was alone are deleted, and the shared org stays.
    • A disabled member still counts, so the only owner of that org is refused.
    • Orgs where the user is the only member are deleted with the user: an enabled one, a disabled one, and one whose only other member is a service user.
    • A disk in an org where the user is the only member refuses the delete with RESOURCES_EXIST, and the user's other, empty org is not deleted. Once the disk is gone, the delete goes through.
    • A trigger fails one write at a time: the project delete inside an org that goes with the user, the user's removal from another org, and the user row. Each try returns an error and stops at that step. The next try continues from there, and the last one deletes the user.
  • test/e2e/regression/billing_test.go: TestUserDeleteRefusedWhileAnOrgHasAPaidSubscription. A paid subscription in an org where the user is the only member refuses the delete with ACTIVE_SUBSCRIPTION. The user, the org and the subscription stay.
  • signUpUser and requireDeleteRefused are shared by both suites.

Technical Details

  • The users sign up and create their own orgs, so they are the only members. An org created by the admin would have the admin as an owner too.
  • The billing suite runs stripe-mock, which answers every invoice list with the same draft invoice. The delete reads invoices from the provider, so it also reports that invoice as UNPAID_INVOICE. The test only checks that ACTIVE_SUBSCRIPTION is among the violations. An unpaid invoice cannot be set up locally for the delete.
  • The triggers work like the one in TestConsentInsertFailureRollsBackTheUser: fixed names and emails in the function bodies, no SQL built from strings, and a deferred cleanup that drops them even when the test fails. The trigger on users matches both a delete and a soft delete, so it keeps working after feat(store): user delete keeps the row #2023.
  • project.Service.DeleteModel removes a project's relations before its row. After the injected failure on the row, the API answers permission denied for that project, even to an admin, until a retry finishes the delete. The test checks the project row in the database instead.

Test Plan

  • Each case fails when the rule it covers is broken: the delete ignoring blockers, skipping the blockers of orgs that go with the user, a negative balance or a paid subscription not blocking, a disabled member not counting, a service user counting, a disabled org skipped, the orgs where the user is alone kept, and the delete carrying on after a failed org delete or a failed removal from an org.
  • go test ./test/e2e/... passes.
  • make lint reports no issues.

The admin user delete is refused with one violation per blocker across the user's orgs, including a negative token balance and a paid subscription, and nothing changes until the blockers are cleared. Orgs where the user is the only member are deleted with the user, including a disabled org and one whose only other member is a service user. A failure injected at the org delete, the removal from another org and the user row stops the delete, and each retry continues from where the last one stopped.
@vercel

vercel Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
frontier Ready Ready Preview Oct 26, 2026 5:01pm UTC

@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 40364592779

Coverage remained the same at 55.877%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 42060
Covered Lines: 23502
Line Coverage: 55.88%
Coverage Strength: 19.47 hits per line

💛 - Coveralls

This branch was successfully deployed

1 active deployment
Preview — e75f6172 Deployed Oct 26, 2026 by vercel[bot]
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.

2 participants