Test Cases: Segment Management

⚠️ PARTLY SUPERSEDED — read the Communications index first. Update 2026-06-16 (#224): a segment management UI now exists at /admin/segments (create / edit / delete for ADMIN / COMMS_MANAGER); segments are also still selectable from the composer's "Audience" <select>. However, the API's only filters are still status / roles / membershipTypeIdthere is NO "unpaid invoices" or any billing/payment filter. Three read-only system segments auto-seed: All Active Members, Administrators, Pending Members. Any billing/dues custom-filter steps below remain not-applicable.

Module: Communications - Segments

Backend Endpoints:

Frontend Page: frontend/pwa-app/src/pages/AdminBroadcastEditPage.tsx

Prerequisites

Test Data - Segments

Segment NameCriteriaExpected Count
All Active Membersstatus = ACTIVE~150
Overdue PaymentsHas overdue invoice~12
New Members (This Year)joined >= Jan 1~25
Event Registrants (Summit)Registered for EVT-2024-002~85
Regular Members OnlymembershipType = Regular~100

Test Cases

TC-COMM-016: View All Segments

StepActionExpected Result
1Login as ADMIN.Dashboard displayed.
2Navigate to Broadcasts > Segments.Segment list displayed.
3Verify all segments listed.Default and custom segments visible.
4Verify member counts.Count displayed for each segment.

TC-COMM-017: Create Simple Segment - By Status

StepActionExpected Result
1Click "Create Segment".Segment builder displayed.
2Enter name: "Active Members Only".Name entered.
3Add condition: Status equals ACTIVE.Condition added.
4Preview segment.Member count and sample list shown.
5Save segment.API POST /api/segments called.
6Verify segment created.Appears in segment list.

TC-COMM-018: Create Segment - By Membership Type

StepActionExpected Result
1Create new segment.Builder displayed.
2Name: "Corporate Members".Name entered.
3Add condition: membershipType equals "Corporate Member".Condition added.
4Preview.Shows corporate members only.
5Save.Segment created.

TC-COMM-019: Create Segment - Multiple Conditions (AND)

StepActionExpected Result
1Create new segment.Builder displayed.
2Name: "Active Regular Members".-
3Add condition 1: status equals ACTIVE.First condition.
4Add condition 2: membershipType equals "Regular Member".Second condition.
5Set logic: AND (both must match).Logic configured.
6Preview.Only active regular members shown.
7Verify count.Intersection of both criteria.

TC-COMM-020: Create Segment - Multiple Conditions (OR)

StepActionExpected Result
1Create segment: "Students or Associates".-
2Add condition: membershipType equals "Student Member".First condition.
3Add condition: membershipType equals "Associate Member".Second condition.
4Set logic: OR (either matches).Logic configured.
5Preview.Both student and associate members included.
6Verify count.Union of both criteria.

TC-COMM-021: Create Segment - Date-Based Condition

StepActionExpected Result
1Create segment: "Joined This Year".-
2Add condition: joinDate >= January 1, 2024.Date condition.
3Preview.Members who joined since Jan 1 shown.
4Verify.Only 2024 joiners in list.

TC-COMM-022: Create Segment - Invoice Status Condition

StepActionExpected Result
1Create segment: "Members with Overdue Invoices".-
2Add condition: hasOverdueInvoice equals true.Condition added.
3Preview.Members with overdue invoices shown.
4Verify members match.Antonio Dela Cruz included (has overdue invoice).

TC-COMM-023: Create Segment - Event Registration Condition

StepActionExpected Result
1Create segment: "Summit Registrants".-
2Add condition: registeredForEvent equals "EVT-2024-002".Event condition.
3Preview.Event registrants shown.
4Verify count.Matches event registration count.

TC-COMM-024: Edit Existing Segment

StepActionExpected Result
1Click on existing segment.Segment details displayed.
2Click "Edit".Builder opens with existing conditions.
3Add new condition or modify existing.Changes made.
4Save.API PUT /api/segments/:id called.
5Verify changes.Updated conditions reflected.
6Verify count updated.New member count based on new criteria.

TC-COMM-025: Delete Segment

StepActionExpected Result
1Select segment not used in broadcasts.-
2Click "Delete".Confirmation dialog.
3Confirm.Segment deleted.
4Verify removed from list.Segment no longer visible.

TC-COMM-026: Cannot Delete Segment in Use

StepActionExpected Result
1Attempt to delete segment used in pending broadcast.Warning displayed.
2Verify message."Segment is used in active broadcasts".
3Options.Must update broadcasts first or force delete.

TC-COMM-027: Preview Segment Before Saving

StepActionExpected Result
1Define segment conditions.Conditions set.
2Click "Preview" without saving.API POST /api/segments/preview called.
3Verify preview results.Member count and sample list displayed.
4Adjust conditions if needed.Re-preview.
5Save when satisfied.Segment saved with previewed conditions.

TC-COMM-028: Segment with Zero Members

StepActionExpected Result
1Create segment with impossible condition.e.g., status = "NONEXISTENT".
2Preview.Shows 0 members.
3Attempt to save.Warning: "Segment has no members".
4Can still save if intended.Segment created (may be future use).

TC-COMM-029: Complex Segment with Nested Conditions

StepActionExpected Result
1Create segment: "Active members who are (Regular OR Corporate) AND joined this year".Complex logic.
2Build nested conditions.Group conditions appropriately.
3Preview.Results match complex criteria.
4Verify accuracy.Manually verify sample members meet all criteria.

TC-COMM-030: Segment Refresh/Recalculate

StepActionExpected Result
1View segment created earlier.Shows previous member count.
2New member joins matching criteria.Member added to system.
3Refresh/recalculate segment.Count updates to include new member.
4Verify dynamic nature.Segments are evaluated at send time.

API Test Cases

TC-COMM-API-005: GET /api/segments

Expected Response: 200 OK

{

"segments": [

{

"id": "seg_all_active",

"name": "All Active Members",

"conditions": [

{ "field": "status", "operator": "equals", "value": "ACTIVE" }

],

"memberCount": 150,

"createdAt": "timestamp"

}

]

}

TC-COMM-API-006: POST /api/segments

Request:

{

"name": "Overdue Payment Members",

"conditions": [

{ "field": "status", "operator": "equals", "value": "ACTIVE" },

{ "field": "hasOverdueInvoice", "operator": "equals", "value": true }

],

"logic": "AND"

}

Expected Response: 201 Created

TC-COMM-API-007: POST /api/segments/preview

Request:

{

"conditions": [

{ "field": "membershipType", "operator": "equals", "value": "Regular Member" },

{ "field": "joinDate", "operator": "greaterThan", "value": "2024-01-01" }

],

"logic": "AND"

}

Expected Response: 200 OK

{

"memberCount": 25,

"sampleMembers": [

{ "id": "MEM-...", "name": "Maria Cruz", "email": "..." },

{ "id": "MEM-...", "name": "Carlos Garcia", "email": "..." }

]

}

TC-COMM-API-008: GET /api/segments/:id

Expected Response: 200 OK

{

"id": "seg_overdue",

"name": "Overdue Payment Members",

"conditions": [...],

"memberCount": 12,

"members": [

{ "id": "MEM-2024-0006", "name": "Antonio Dela Cruz", "email": "..." }

]

}