# Groups Integration Test Commands

Reusable command classes for groups integration tests. Import from these files instead of writing raw `apiGet`/`apiPost` calls in tests.

**When you add a new command file, update this document.** Add a row to the matching category table (or create a new category if needed).

## Group CRUD

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `CreateGroup` | `createGroup.ts` | `POST /groups` | Create a group; `createRandomGroup` helper creates one with random data |
| `EditGroup` | `editGroup.ts` | `PUT /groups/:id` | Full group replacement |
| `EditGroupPartially` | `editGroupPartially.ts` | `PATCH /groups/:id` | Selective field update |
| `DeleteGroup` | `deleteGroup.ts` | `DELETE /groups/:id` | Delete a group |
| `GetGroupById` | `getGroupById.ts` | `GET /groups/:id` | Fetch single group |
| `ToggleArchiveGroup` | `toggleArchiveGroup.ts` | `PATCH /groups/:id/archive` | Archive or unarchive a group |

## Group Listing & Discovery

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `ListGroups` | `listGroups.ts` | `GET /groups` | Paginated list of groups the user belongs to |
| `ExploreGroups` | `exploreGroups.ts` | `GET /groups/explore` | Cursor-paginated group discovery (non-members) |
| `PinGroup` | `pinGroup.ts` | `POST /groups/:id/pin` | Pin a group for the logged user |
| `UnPinGroup` | `unPinGroup.ts` | `DELETE /groups/:id/pin` | Unpin a group |
| `ReorderPinnedGroup` | `reorderPinnedGroup.ts` | `PATCH /groups/:id/pin` | Reorder a pinned group's position |

## Members

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `AddGroupMembers` | `addGroupMembers.ts` | `PUT /groups/:id/members` | Bulk add members to a group |
| `InviteGroupMembers` | `inviteGroupMembers.ts` | `POST /groups/:id/invite` | Send invitations to users |
| `DeleteGroupMember` | `deleteGroupMember.ts` | `DELETE /groups/:id/members/:userId` | Remove a single member |
| `BulkDeleteMembersFromGroup` | `bulkDeleteMembersFromGroup.ts` | `POST /groups/:id/members/bulk-delete` | Remove multiple members |
| `JoinGroup` | `joinGroup.ts` | `POST /groups/:id/join` | Join an open group |
| `LeaveGroup` | `leaveGroup.ts` | `DELETE /groups/:id/membership` | Leave a group |
| `ListGroupMembers` | `listGroupMembers.ts` | `GET /groups/:id/members` | Cursor-paginated member list |
| `ListAssignableMembers` | `listAssignableMembers.ts` | `GET /groups/:id/assignable-members` | List instance users eligible for assignment |
| `UpdateGroupMemberRole` | `updateGroupMemberRole.ts` | `PUT /groups/:id/members/:userId/role` | Change member role (ADMIN / REGULAR) |

## Member Policy Templates (Segmentation)

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `CreateGroupMemberPolicyTemplate` | `createGroupMemberPolicyTemplate.ts` | `POST /groups/members-policy-templates` | Create a policy template for bulk criteria |
| `EditGroupMemberPolicy` | `editGroupMemberPolicy.ts` | `PUT /groups/:id/members-policy` | Replace all criteria for a group policy |
| `EditGroupMemberPolicyTemplate` | `editGroupMemberPolicyTemplate.ts` | `PUT /groups/members-policy-templates/:id/criteria` | Update criteria on a template |
| `GetGroupMemberPolicy` | `getGroupMemberPolicy.ts` | `GET /groups/:id/members-policy` | Paginated criteria of a group's member policy |
| `GetMemberPolicyTemplateUsers` | `getMemberPolicyTemplateUsers.ts` | `GET /groups/members-policy-templates/:id/users` | Paginated users matched by a policy template |
| `DevopsResyncGroupMembersAudience` | `devopsResyncGroupMembersAudience.ts` | `POST /devops/groups/:id/members-policy/sync` | Re-apply a group's existing gathering criteria to re-sync `GroupMembers` |

## Join Requests

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `GetPendingGroupRequests` | `getPendingGroupRequests.ts` | `GET /groups/:id/requests` | List pending join requests |
| `GetGroupRequestCount` | `getGroupRequestCount.ts` | `GET /groups/:id/requests/count` | Count requests (optionally by status) |
| `ReviewGroupRequest` | `reviewGroupRequest.ts` | `PUT /groups/:id/requests/:requestId/status` | Accept or reject a single request |
| `ReviewAllGroupRequest` | `reviewAllGroupRequests.ts` | `PUT /groups/:id/requests/status` | Bulk accept or reject all pending requests |

## Posts

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `CreateGroupPost` | `createGroupPost.ts` | `POST /groups/:id/posts` | Create a post in a group |
| `EditGroupPost` | `editGroupPost.ts` | `PUT /groups/:id/posts/:postId` | Full post replacement |
| `EditGroupPostPartially` | `editGroupPostPartially.ts` | `PATCH /groups/:id/posts/:postId` | Selective post field update |
| `EditGroupPostPublicationDate` | `editGroupPostPublicationDate.ts` | `PATCH /groups/:id/posts/:postId/publication-datetime` | Reschedule a post's publication datetime |
| `DeleteGroupPost` | `deleteGroupPost.ts` | `DELETE /groups/:id/posts/:postId` | Delete a post |
| `GetGroupPostById` | `getGroupPostById.ts` | `GET /groups/:id/posts/:postId` | Fetch single post |
| `ListGroupPosts` | `listGroupPosts.ts` | `GET /groups/:id/posts` | Cursor-paginated post listing for a group |
| `ListUserGroupPosts` | `listUserGroupPosts.ts` | `GET /groups/user/:userId/posts` | Cursor-paginated posts by a specific user |
| `PinGroupPost` | `pinGroupPost.ts` | `POST /groups/:id/posts/:postId/pin` | Pin a post |
| `UnPinGroupPost` | `unPinGroupPost.ts` | `POST /groups/:id/posts/:postId/unpin` | Unpin a post |
| `SetGroupPostAsViewed` | `setGroupPostAsViewed.ts` | `POST /groups/:id/posts/:postId/viewed` | Mark a post as viewed by the logged user |
| `PublishScheduledGroupPosts` | `publishScheduledGroupPosts.ts` | `POST /groups/posts/publish-scheduled` | Trigger publication of all scheduled posts |

## Post Approval & Edit Requests

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `GetPendingGroupPosts` | `getPendingGroupPosts.ts` | `GET /groups/:id/posts/pending` | List pending post approval requests |
| `CreateGroupPostEditRequest` | `createGroupPostEditRequest.ts` | `POST /groups/:id/posts/:postId/edit-requests` | Create an edit review request |
| `DeleteGroupPostRequest` | `deleteGroupPostRequest.ts` | `DELETE /groups/:id/post-requests/:requestId` | Cancel a post request |
| `ReviewGroupPost` | `reviewGroupPost.ts` | `PATCH /groups/:id/posts/review` | Bulk approve or reject pending posts |

## Comments

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `CreateGroupPostComment` | `createGroupPostComment.ts` | `POST /groups/:id/posts/:postId/comments` | Add a comment to a post |
| `EditGroupPostComment` | `editGroupPostComment.ts` | `PUT /groups/:id/posts/:postId/comments/:commentId` | Edit a comment |
| `DeleteGroupPostComment` | `deleteGroupPostComment.ts` | `DELETE /groups/:id/posts/:postId/comments/:commentId` | Delete a comment |
| `ListGroupPostComments` | `listGroupPostComments.ts` | `GET /groups/:id/posts/:postId/comments` | Cursor-paginated comment list |

## Reactions

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `CreateGroupPostReaction` | `createGroupPostReaction.ts` | `POST /groups/:id/posts/:postId/reactions` | Add a reaction to a post |
| `DeleteGroupPostReaction` | `deleteGroupPostReaction.ts` | `DELETE /groups/:id/posts/:postId/reactions` | Remove a reaction from a post |
| `CreateGroupPostCommentReaction` | `createGroupPostCommentReaction.ts` | `POST /groups/:id/posts/:postId/comments/:commentId/reactions` | Add a reaction to a comment |
| `DeleteGroupPostCommentReaction` | `deleteGroupPostCommentReaction.ts` | `DELETE /groups/:id/posts/:postId/comments/:commentId/reactions` | Remove a reaction from a comment |
| `ListGroupPostReactors` | `listGroupPostReactors.ts` | `GET /groups/:id/posts/:postId/stats/reactors` | List users who reacted to a post |
| `ListUserGroupPostReactors` | `listUserGroupPostReactors.ts` | `GET /groups/:id/posts/:postId/reactions/users` | Cursor-paginated reactors with emoji filter |
| `ListUserGroupPostCommentReactors` | `listUserGroupPostCommentReactors.ts` | `GET /groups/:id/posts/:postId/comments/:commentId/reactions/users` | Cursor-paginated comment reactors |

## Polls

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `VoteGroupPostPoll` | `voteGroupPostPoll.ts` | `POST /groups/:id/posts/:postId/polls/:pollId/options/:optionId/answer` | Cast a vote on a poll option |
| `EditGroupPostPollDeadline` | `editGroupPostPollDeadline.ts` | `PATCH /groups/:id/posts/:postId/polls/:pollId/ends-at` | Update a poll's deadline |
| `ListGroupPostPollOptionVoters` | `listGroupPostPollOptionVoters.ts` | `GET /groups/:id/posts/:postId/polls/:pollId/options/:optionId/voters` | Cursor-paginated voters for a poll option |

## Post & Group Stats

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `GetGroupPostStatsSummary` | `getGroupPostStatsSummary.ts` | `GET /groups/:id/posts/:postId/stats/summary` | Views, reactions, comment counts for a post |
| `ListGroupPostCommenters` | `listGroupPostCommenters.ts` | `GET /groups/:id/posts/:postId/stats/commenters` | List users who commented on a post |
| `ListGroupPostViewers` | `listGroupPostViewers.ts` | `GET /groups/:id/posts/:postId/stats/viewers` | List users who viewed a post |
| `ListGroupPostViews` | `listGroupPostViews.ts` | `GET /groups/:id/posts/:postId/views` | Cursor-paginated view records |
| `GetGroupStatsSummary` | `getGroupStatsSummary.ts` | `GET /groups/:id/stats/summary` | Group-level stats summary (last 28 days) |
| `GetGroupMostActiveMembers` | `getGroupMostActiveMembers.ts` | `GET /groups/:id/stats/most-active-members` | Cursor-paginated most active members |
| `CreateGroupMembersReport` | `createGroupMembersReport.ts` | `GET /groups/:id/members/report` | Trigger members report email |
| `CreateGroupMostActiveMembersReport` | `createGroupMostActiveMembersReport.ts` | `GET /groups/:id/stats/most-active-members/report` | Trigger most active members report email |

## Notification Configuration

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `GetUserGroupNotificationConfiguration` | `getUserGroupNotificationConfiguration.ts` | `GET /groups/:id/notification-configuration` | Get user's notification prefs for a group |
| `UpsertUserGroupNotificationConfiguration` | `upsertUserGroupNotificationConfiguration.ts` | `PUT /groups/:id/notification-configuration` | Set user's notification prefs for a group |

## Red Bubbles (Unread Counts)

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `GetUnreadCount` | `getUnreadCount.ts` | `GET /red-bubbles/groups` | Total unread count across all groups |
| `ClearUnreadCount` | `clearUnreadCount.ts` | `POST /red-bubbles/groups/:id/clear` | Mark a group as read |

## Multi-Company

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `AddInstanceMultiCompanyGroup` | `addInstanceMultiCompanyGroup.ts` | `POST /groups/:id/linked-instances` | Link an instance to a multi-company group |
| `CountGroupLinkedInstances` | `countGroupLinkedInstances.ts` | `GET /groups/:id/linked-instances/count` | Count linked instances for a group |
| `ListGroupLinkedInstances` | `listGroupLinkedInstances.ts` | `GET /groups/:id/linked-instances` | Cursor-paginated list of linked instances |
| `InviteMulticompany` | `inviteMulticompany.ts` | `POST /groups/:id/company-invitations` | Send a cross-instance invitation |
| `GetMulticompanyInvitation` | `getMulticompanyInvitation.ts` | `GET /groups/company-invitations/:token` | Fetch an invitation by token |
| `ListMulticompanyInvitations` | `listMulticompanyInvitations.ts` | `GET /groups/company-invitations` | List sent invitations for the instance |
| `ListReceivedMulticompanyInvitations` | `listReceivedMulticompanyInvitations.ts` | `GET /groups/company-invitations/received` | List received invitations |
| `UpdateMulticompanyInvitationStatus` | `updateMulticompanyInvitationStatus.ts` | `PATCH /groups/company-invitations/:token` | Accept or reject an invitation |

## Livestream

| Command | File | HTTP | Description |
|---------|------|------|-------------|
| `AnswerLivestreamPoll` | `answerLivestreamPoll.ts` | `POST /groups/:id/posts/:postId/livestream_poll_answer` | Vote on an active livestream poll |
| `FindLivestreamPoll` | `findLivestreamPoll.ts` | `GET /groups/:id/posts/:postId/livestream_poll` | Fetch active or last ended poll |
| `FindGroupPostLivestreamStats` | `findLivestreamStats.ts` | `GET /groups/:id/posts/:postId/livestream_stats` | Aggregate livestream stats for a post |
| `FindGroupPostLivestreamViewersTimeline` | `findLivestreamViewersTimeline.ts` | `GET /groups/:id/posts/:postId/livestream_viewers_timeline` | Viewers over time timeline |
| `SearchGroupPostLivestreamViewersStats` | `searchViewerStats.ts` | `GET /groups/:id/posts/:postId/livestream_viewer_sessions_stats` | Per-viewer session stats (searchable) |
| `SearchGroupPostLivestreamViewers` | `searchViewers.ts` | `GET /groups/:id/posts/:postId/livestream_viewers` | Paginated viewer list (searchable) |
| `DownloadLivestreamStats` | `downloadLivestreamStats.ts` | `GET /groups/:id/posts/:postId/livestream_stats/report` | Download livestream stats as binary report |
