Skip to content

test: add integration tests for User Groups, Editorial Comments, Notifications, and Calendar modules#799

Merged
GaryJones merged 4 commits intodevelopfrom
add/user-groups-tests
Nov 26, 2025
Merged

test: add integration tests for User Groups, Editorial Comments, Notifications, and Calendar modules#799
GaryJones merged 4 commits intodevelopfrom
add/user-groups-tests

Conversation

@GaryJones
Copy link
Contributor

Summary

Adds comprehensive integration tests for four previously untested or minimally tested modules, increasing test coverage from 59 to 142 tests (a 140% increase).

New Test Files

Module Tests Key Coverage Areas
User Groups 21 CRUD operations, user membership, data integrity
Editorial Comments 15 Comment creation, threading, HTML sanitization, permissions
Notifications 25 Subscription management, follow/unfollow, permission checks
Calendar 22 Date calculations, week boundaries, modify permissions

Test Details

User Groups (UserGroupsTest.php)

  • Create, read, update, delete usergroups
  • Add/remove users from groups
  • Get usergroups for a specific user
  • Validation (name required, unique user IDs, slug prefixing)

Editorial Comments (EditorialCommentsTest.php)

  • Insert and retrieve editorial comments
  • Separation from regular WordPress comments
  • Threaded/nested comment support
  • HTML content sanitization (allowed vs stripped tags)
  • Notification list meta storage

Notifications (NotificationsSubscriptionTest.php)

  • user_can_be_notified() permission checks for all roles
  • Follow/unfollow posts by user ID, login, or object
  • Usergroup subscription integration
  • User deletion cleanup from following taxonomy
  • Custom filter hook for notification permissions

Calendar (CalendarModuleTest.php)

  • get_beginning_of_week() / get_ending_of_week() calculations
  • Various start-of-week options (Sunday, Monday, Saturday)
  • Week boundaries across month and year transitions
  • current_user_can_modify_post() permission checks

Known Limitation

AJAX handlers in these modules use die() instead of wp_die(), which prevents proper test isolation. This will be addressed in a follow-up PR to enable AJAX handler testing.

Test plan

  • All 142 tests pass locally
  • CI passes

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings November 25, 2025 20:00
Copy link

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

This PR adds comprehensive integration test coverage for four previously untested or minimally tested modules (User Groups, Editorial Comments, Notifications, and Calendar), increasing total test count from 59 to 142 tests. The tests validate CRUD operations, permission checks, data integrity, HTML sanitization, date calculations, and subscription management across these modules.

Key Changes:

  • Added 21 tests for User Groups covering CRUD, membership, validation, and slug prefixing
  • Added 15 tests for Editorial Comments covering threading, HTML sanitization, and separation from regular comments
  • Added 25 tests for Notifications covering subscription management, permissions, and follow/unfollow operations
  • Added 22 tests for Calendar covering date boundary calculations, week offsets, and permission checks

Reviewed changes

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

File Description
tests/Integration/UserGroupsTest.php Tests for user group CRUD operations, membership management, and validation
tests/Integration/NotificationsSubscriptionTest.php Tests for notification subscription/permission logic, follow/unfollow, and user deletion cleanup
tests/Integration/EditorialCommentsTest.php Tests for editorial comment creation, threading, HTML sanitization, and type separation
tests/Integration/CalendarModuleTest.php Tests for week boundary calculations, date formatting, and post modification permissions

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@GaryJones GaryJones self-assigned this Nov 25, 2025
@GaryJones GaryJones added the type: maintenance Routine maintenance and code quality improvements label Nov 25, 2025
@GaryJones GaryJones force-pushed the add/user-groups-tests branch 2 times, most recently from c857718 to 84e7c41 Compare November 26, 2025 11:30
GaryJones and others added 4 commits November 26, 2025 11:39
Adds comprehensive integration tests for the User Groups module covering:
- CRUD operations (add, get, update, delete usergroups)
- User membership management (add/remove users, get groups for user)
- Data integrity (unique user IDs, slug prefixing, special characters)

This brings the User Groups module from 0% to meaningful test coverage
with 21 new tests validating core functionality.

Note: AJAX handler tests were not included because the module uses die()
instead of wp_die(), which prevents proper test isolation. This should
be addressed in a future refactoring effort.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Adds comprehensive integration tests for the Editorial Comments module:
- Comment creation and retrieval with editorial-comment type
- Separation from regular WordPress comments
- Threaded/nested comment support
- Notification list meta storage
- User association and capability checks
- HTML content sanitization (allowed vs stripped tags)
- Comment ordering and deletion

15 new tests validating core editorial comment functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Adds comprehensive tests for the Notifications subscription system:
- user_can_be_notified permission checks (admin, editor, author, subscriber)
- Follow/unfollow users on posts by ID, login, or object
- Multiple user subscriptions and append/replace behavior
- Usergroup following integration
- Getting followers by login, ID, or email
- Getting posts a user follows
- User deletion cleanup from following taxonomy
- edit_post_subscriptions capability verification
- Filter hook for custom notification permissions

25 new tests covering the critical permission and subscription functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Adds comprehensive tests for the Calendar module:
- Date calculations: get_beginning_of_week, get_ending_of_week
- Various start-of-week options (Sunday, Monday, Saturday)
- Week boundaries across month and year transitions
- Week offset calculations for multi-week views
- Custom date format output
- Permission checks: current_user_can_modify_post
  - Admin/editor can modify any post
  - Author can modify own posts (draft and published)
  - Contributor can only modify own drafts
- Time period header HTML generation

22 new tests validating calendar date calculations and permissions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@GaryJones GaryJones force-pushed the add/user-groups-tests branch from 84e7c41 to 2af06ae Compare November 26, 2025 11:41
@GaryJones GaryJones merged commit 5c8fbb5 into develop Nov 26, 2025
10 checks passed
@GaryJones GaryJones deleted the add/user-groups-tests branch November 26, 2025 11:45
@GaryJones GaryJones added this to the Next patch milestone Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: maintenance Routine maintenance and code quality improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants