Family creation fails in Family Grouping – "Failed to create family" message displayed after clicking Create Family
Issue Summary
Currently, in the Family Grouping module, when a volunteer attempts to create a new family by entering the Book Number and selecting the Family Role, clicking the Create Family button results in an error message:
"Failed to create family"
The family is not created and no response is returned to the UI.
Current Behavior
User fills Book Number and selects Family Role. User clicks Create Family. System shows "Failed to create family" error message.
Expected Behavior
Family should be successfully created. The new family should appear under Family Memberships. Success feedback should be shown to the user.
Proposed Solution
What is broken
The Create Family API request or form submission process is failing, resulting in the UI displaying the error message "Failed to create family".
Who is affected Volunteers managing family grouping Healthcare coordinators using the system Impact Volunteers cannot create new family groups. Family grouping workflow becomes blocked. Patient grouping functionality cannot be used during medical camps. Steps to Reproduce Navigate to Volunteer → Family Grouping Enter a Book Number (example: 49) Select Family Role (Head) Click Create Family Observe the error message: Failed to create family
Test-Driven Development
Acceptance Criteria (Given-When-Then)
Acceptance Criteria (Given-When-Then) Scenario 1: Successful Family Creation Given a volunteer is on the Family Grouping page And enters a valid Book Number And selects a Family Role When the volunteer clicks the Create Family button Then the family should be created successfully And the new family should appear in the Family Memberships list And a success message should be displayed
Scenario 1: [Scenario Name]
Given [initial context/state]
And [additional preconditions]
When [action is performed]
Then [expected outcome]
And [additional outcomes]
Scenario 2: [Scenario Name] Scenario 2: API Failure Handling Given the Create Family API fails When the user clicks Create Family Then an error message should be displayed And the system should not crash
Test Cases
| Test ID | Test Description | Precondition | Test Steps | Expected Result | Priority |
|---|---|---|---|---|---|
| TC-001 | Create family successfully | Valid book number exists | 1. Enter book number2.Select role3. Click Create Family | Family created successfully | High |
| TC-002 | Error handling when API fails | API failure simulated | 1. Submit form | Error message displayed | High |
| TC-003 | Validation for empty fields | No data entered | 1. Click Create Family | Validation error shown | Med |
Unit Test Requirements
Components/Functions to Test:
Components/Functions to Test Module/Component Function Test Cases FamilyGrouping handleCreateFamily TC-001, TC-002 familyService createFamily API call TC-001 API Error Handler error handling logic TC-002
Test Assertions Required:
-
Renders correctly with initial state -
Handles user input correctly -
Validates input and shows errors -
Calls API with correct payload -
Handles loading state -
Handles success response -
Handles error response -
Updates UI state appropriately
Implementation Details
Files to Change
| File Path | Action | Purpose |
|---|---|---|
src/components/... |
Create/Modify | |
src/pages/... |
Create/Modify | |
src/types/... |
Create/Modify | |
src/__tests__/... |
Create | Unit tests |
Technical Considerations
Validate Book Number exists before creating family Ensure API request payload matches backend schema Handle API errors gracefully Use proper loading state during API call
UI/UX Requirements
Display loading state while creating family Show success toast after family creation Display clear error message if creation fails Ensure modal closes after successful creation Mockups/Wireframes:
Testing Strategy
Manual Testing Test Environment Browser: Chrome / Firefox Viewport: Desktop User Role: Volunteer Manual Test Steps Open Family Grouping page Enter Book Number Select Family Role Click Create Family Verify family appears in membership list
Automated Testing
Unit Tests:
-
Component render tests -
User interaction tests -
API integration tests -
Error handling tests
Integration Tests (if applicable):
-
Multi-component interaction tests -
Route navigation tests
Test Data Requirements
Unit Tests Component render tests User interaction tests API integration tests Error handling tests Integration Tests Family creation workflow UI update after API response
// Example mock data
const mockTestData = {
// Add required test data structure
}
Definition of Done
-
Acceptance criteria met (all Given-When-Then scenarios pass) -
All test cases executed and passing -
Unit tests written and passing (minimum coverage: __%) -
Manual testing completed -
Code reviewed and approved -
UI matches design specifications (if applicable) -
Responsive on all required viewport sizes -
Accessibility checks passed (aria labels, keyboard navigation) -
No console errors or warnings -
TypeScript types defined (no any) -
ESLint/Prettier checks pass -
Documentation updated (if applicable) -
i18n strings externalized (no hardcoded text)