Skip to content

Add missing test coverage for permissions, deposits, editor access, and spam user edge cases#3197

Draft
cursor[bot] wants to merge 1 commit intomainfrom
cursor/missing-test-coverage-22a6
Draft

Add missing test coverage for permissions, deposits, editor access, and spam user edge cases#3197
cursor[bot] wants to merge 1 commit intomainfrom
cursor/missing-test-coverage-22a6

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Mar 16, 2026

Risky behavior now covered

  • HasDocumentEditingPermission (document editing permission class): Direct unit tests for author/moderator/org-member/stranger access paths, including the note_id branch that gates organization membership checks and the upsert action path. Previously only covered indirectly through API integration tests.

  • Deposit.upsert_pending (Circle deposit status ordering): Direct tests for the status-advance-only logic (INITIATED→CONFIRMED advances, CONFIRMED→INITIATED does not regress, COMPLETED/FAILED at same level, unknown status handling). Previously only tested indirectly via webhook integration tests.

  • Research AI editor access (UserIsEditor | IsModerator composition): Verifies that hub editors (non-moderators) can access expert-finder endpoints after the recent permission change. Previously only moderator access was tested.

  • handle_spam_user_task with nonexistent user: Tests the early-return guard for invalid user IDs, covering the recently added if not user: return path.

Test files added/updated

  • src/researchhub_document/tests/test_permissions.py (new, 10 tests)
  • src/reputation/tests/test_deposit.py (new, 10 tests)
  • src/research_ai/tests/test_editor_access.py (new, 6 tests)
  • src/user/tests/test_tasks.py (updated, 2 new tests)

Why these tests materially reduce regression risk

These tests target security-critical permission logic, financial deposit state machines, and recently changed access control composition — all areas where regressions could cause unauthorized access, data corruption, or financial errors. Each test is deterministic and independent.

Open in Web View Automation 

…nd spam user edge cases

Co-authored-by: Kobe Attias <kobeattias@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.51%. Comparing base (496a262) to head (df4f56a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3197      +/-   ##
==========================================
+ Coverage   78.49%   78.51%   +0.01%     
==========================================
  Files         612      612              
  Lines       34250    34250              
==========================================
+ Hits        26885    26890       +5     
+ Misses       7365     7360       -5     

☔ 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.

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.

1 participant