{
  "meta": {
    "title": "Prophet-Priest-King User Journey",
    "description": "Complete user journeys for all personas: Personal Survey Users, Organization Members, and Super Admins",
    "version": "2.0.0",
    "lastUpdated": "2025-11-22",
    "notes": {
      "templatePlaceholders": "Test data may contain template placeholders like {timestamp} that should be replaced with actual values by consuming code. Example: 'test-{timestamp}@example.com' becomes 'test-1732287600000@example.com'"
    }
  },
  "personas": [
    {
      "id": "personal-user",
      "name": "Personal Survey User",
      "icon": "👤",
      "description": "Individual user who takes the assessment for personal spiritual leadership development",
      "characteristics": [
        "Not part of any organization",
        "Has only a personal survey",
        "Cannot view organization features",
        "Can delete own survey anytime"
      ],
      "journeyRef": "personal-user-journey"
    },
    {
      "id": "org-member",
      "name": "Organization Member",
      "icon": "🏛️",
      "description": "User who belongs to a church or ministry organization and participates in team assessments",
      "characteristics": [
        "Member of one organization",
        "Can take organizational surveys",
        "Can view organization dashboard and statistics",
        "Can invite other members (if allowed)",
        "Has equal permissions with other members",
        "Can switch between personal and organizational survey contexts"
      ],
      "journeyRef": "org-member-journey"
    },
    {
      "id": "super-admin",
      "name": "Super Administrator",
      "icon": "🔑",
      "description": "System administrator with elevated privileges across the entire application",
      "characteristics": [
        "Has isAdmin flag in Firebase",
        "Can view all organizations",
        "Can delete any user account (except own)",
        "Can delete organizations",
        "Can move personal surveys to organizations",
        "Cannot delete sole administrators of organizations"
      ],
      "journeyRef": "super-admin-journey"
    }
  ],
  "journeys": {
    "personal-user-journey": {
      "personaId": "personal-user",
      "title": "Personal Survey User Journey",
      "description": "Complete journey for an individual using the app for personal spiritual assessment",
      "steps": [
        {
          "id": "signup",
          "order": 1,
          "title": "User Sign-Up",
          "description": "New user creates an account with email and password",
          "userGoal": "Create a new account to access the leadership assessment",
          "actions": [
            "Navigate to authentication page",
            "Click 'Sign Up' tab or button",
            "Enter first name",
            "Enter last name",
            "Enter email address",
            "Enter password",
            "Click 'Sign Up' button"
          ],
          "expectedOutcome": "User is authenticated and redirected to home page",
          "testData": {
            "firstName": "John",
            "lastName": "Tester",
            "email": "test-{timestamp}@example.com",
            "password": "TestPassword123!"
          },
          "validations": [
            "User is redirected to /home route",
            "Navigation bar shows user is authenticated",
            "No error messages are displayed"
          ]
        },
        {
          "id": "signin",
          "order": 2,
          "title": "User Sign-In",
          "description": "Existing user signs in with credentials",
          "userGoal": "Access the application with existing account",
          "actions": [
            "Navigate to authentication page",
            "Ensure 'Sign In' tab is active",
            "Enter email address",
            "Enter password",
            "Click 'Sign In' button"
          ],
          "expectedOutcome": "User is authenticated and redirected to home page",
          "testData": {
            "email": "existing user email from signup",
            "password": "TestPassword123!"
          },
          "validations": [
            "User is redirected to /home route",
            "Navigation bar shows user is authenticated",
            "User's name is displayed in navigation"
          ]
        },
        {
          "id": "create-survey",
          "order": 3,
          "title": "Create Personal Survey",
          "description": "User completes their first personal leadership assessment survey",
          "userGoal": "Complete the Prophet-Priest-King leadership assessment to discover my biblical leadership profile",
          "actions": [
            "Navigate to Survey page from home",
            "Verify survey context is 'Personal Survey'",
            "Click 'Start Survey' button",
            "Answer all 30 survey questions (10 per category: Prophet, Priest, King)",
            "Submit the survey",
            "View results page with calculated scores"
          ],
          "expectedOutcome": "Survey is saved, results are displayed, and biblical leadership profile is calculated",
          "testData": {
            "surveyType": "Prophet profile",
            "surveyContext": "personal",
            "targetScores": {
              "prophet": 45,
              "priest": 25,
              "king": 25
            },
            "totalQuestions": 30
          },
          "validations": [
            "Survey results are displayed on screen",
            "Prophet, Priest, and King scores are shown",
            "Scores match expected profile (Prophet dominant)",
            "Results page shows 'Edit Survey' and 'Retake Survey' buttons",
            "Survey is not linked to any organization"
          ]
        },
        {
          "id": "view-profile",
          "order": 4,
          "title": "View Biblical Leadership Profile",
          "description": "User views their profile page showing biblical leadership assessment results",
          "userGoal": "Review my biblical leadership profile and scores",
          "actions": [
            "Navigate to Profile page from navigation menu",
            "View biblical leadership profile section",
            "Review Prophet, Priest, and King scores",
            "Read profile interpretation"
          ],
          "expectedOutcome": "Profile displays current biblical leadership assessment results",
          "testData": {
            "expectedProfile": "Prophet profile based on survey"
          },
          "validations": [
            "Profile page loads successfully",
            "Biblical leadership scores are displayed",
            "Profile matches survey results",
            "User information is displayed correctly"
          ]
        },
        {
          "id": "edit-survey",
          "order": 5,
          "title": "Edit Survey",
          "description": "User modifies their existing survey responses",
          "userGoal": "Update my survey answers to better reflect my current leadership style",
          "actions": [
            "Navigate to Survey page",
            "Click 'Edit Survey' button",
            "Modify responses to survey questions",
            "Submit the updated survey",
            "View updated results"
          ],
          "expectedOutcome": "Survey responses are updated, new results are calculated and displayed",
          "testData": {
            "surveyType": "Priest profile",
            "targetScores": {
              "prophet": 25,
              "priest": 45,
              "king": 25
            }
          },
          "validations": [
            "Updated survey results are displayed",
            "Scores reflect the modified answers",
            "New profile (Priest dominant) is shown",
            "Profile page reflects the updated results"
          ]
        },
        {
          "id": "retake-survey",
          "order": 6,
          "title": "Retake Survey",
          "description": "User takes the survey again to track leadership growth over time",
          "userGoal": "Retake the assessment to see how my leadership style has evolved",
          "actions": [
            "Navigate to Survey page",
            "Click 'Retake Survey' button",
            "Answer all 30 survey questions with new responses",
            "Submit the new survey",
            "View new results"
          ],
          "expectedOutcome": "New survey replaces old one, fresh results are calculated and displayed",
          "testData": {
            "surveyType": "King profile",
            "targetScores": {
              "prophet": 25,
              "priest": 25,
              "king": 45
            }
          },
          "validations": [
            "New survey results are displayed",
            "Scores reflect the retake responses",
            "New profile (King dominant) is shown",
            "Profile page reflects the latest results",
            "Previous survey data is replaced (not duplicated)"
          ]
        },
        {
          "id": "verify-profile-updates",
          "order": 7,
          "title": "Verify Profile Updates",
          "description": "Confirm that profile has been updated with latest survey results",
          "userGoal": "Ensure my profile reflects my most recent assessment",
          "actions": [
            "Navigate to Profile page",
            "Verify biblical leadership profile displays latest scores",
            "Confirm profile interpretation matches current assessment"
          ],
          "expectedOutcome": "Profile shows most recent survey results with correct biblical leadership profile",
          "testData": {
            "expectedProfile": "King profile based on latest survey"
          },
          "validations": [
            "Profile displays valid scores for all three categories",
            "Scores are greater than zero",
            "Profile matches the latest survey results",
            "All profile updates throughout journey are distinct and correct"
          ]
        },
        {
          "id": "signout",
          "order": 8,
          "title": "User Sign-Out",
          "description": "User logs out of the application",
          "userGoal": "Safely log out and end my session",
          "actions": [
            "Click user menu or sign-out button in navigation",
            "Click 'Sign Out' option",
            "Confirm sign-out if prompted"
          ],
          "expectedOutcome": "User is signed out and redirected to authentication page",
          "validations": [
            "User is redirected to authentication page",
            "Navigation shows unauthenticated state",
            "Protected routes are no longer accessible"
          ]
        }
      ]
    },
    "org-member-journey": {
      "personaId": "org-member",
      "title": "Organization Member Journey",
      "description": "Complete journey for a user participating in organizational team assessments",
      "steps": [
        {
          "id": "signup-or-signin",
          "order": 1,
          "title": "Sign-Up or Sign-In",
          "description": "User creates account or signs in (same as personal user)",
          "userGoal": "Access the application to join an organization",
          "actions": [
            "Complete sign-up or sign-in process"
          ],
          "expectedOutcome": "User is authenticated and on home page",
          "testData": {
            "firstName": "Jane",
            "lastName": "OrgMember",
            "email": "jane-{timestamp}@example.com",
            "password": "TestPassword123!"
          },
          "validations": [
            "User is authenticated",
            "Home page loads successfully"
          ]
        },
        {
          "id": "join-organization",
          "order": 2,
          "title": "Join Organization",
          "description": "User joins an organization via invitation link or code",
          "userGoal": "Become a member of my church or ministry organization",
          "actions": [
            "Receive invitation link or code from organization member",
            "Click invitation link OR navigate to Organizations and enter code",
            "Review organization details on join page",
            "Click 'Join Organization' button",
            "Wait for confirmation message"
          ],
          "expectedOutcome": "User becomes member of organization and is redirected to organization dashboard",
          "testData": {
            "invitationCode": "ABC12345",
            "organizationName": "Test Church"
          },
          "validations": [
            "User is added to organization memberships",
            "Organization member count increments",
            "Success message displays",
            "User is redirected to organization dashboard",
            "Survey context switches to organization"
          ]
        },
        {
          "id": "view-org-dashboard",
          "order": 3,
          "title": "View Organization Dashboard",
          "description": "User views organization dashboard with team statistics and member list",
          "userGoal": "See team survey statistics and understand our collective leadership profile",
          "actions": [
            "Click 'Organizations' card on home page",
            "System auto-navigates to organization dashboard (user has only 1 org)",
            "Review organization information",
            "View aggregate survey statistics (if surveys exist)",
            "Review member list",
            "Explore dashboard features"
          ],
          "expectedOutcome": "Dashboard displays with organization data and available actions",
          "testData": {
            "expectedStats": "Aggregate Prophet, Priest, King scores",
            "expectedMembers": "List of organization members"
          },
          "validations": [
            "Organization name and description display",
            "Member list shows all members",
            "Action buttons are visible (Take Survey, View Matrix, etc.)",
            "If surveys exist, statistics are shown",
            "User can see invitation link/code"
          ]
        },
        {
          "id": "take-org-survey",
          "order": 4,
          "title": "Take Organizational Survey",
          "description": "User completes survey in organizational context",
          "userGoal": "Complete my assessment as part of my organization's team evaluation",
          "actions": [
            "Verify survey context is set to organization",
            "Navigate to Survey page",
            "Click 'Start Survey' button",
            "Answer all 30 survey questions",
            "Submit the survey",
            "View results"
          ],
          "expectedOutcome": "Survey is saved with organizationId, results displayed, organization statistics updated",
          "testData": {
            "surveyType": "Balanced profile",
            "surveyContext": "organization",
            "organizationId": "org-123",
            "targetScores": {
              "prophet": 35,
              "priest": 35,
              "king": 35
            }
          },
          "validations": [
            "Survey is linked to organization",
            "Results display correctly",
            "Organization dashboard statistics update",
            "User appears in organization survey matrix (if viewed)"
          ]
        },
        {
          "id": "view-survey-matrix",
          "order": 5,
          "title": "View Survey Response Matrix",
          "description": "User views detailed matrix showing all team members' responses",
          "userGoal": "See how all team members answered each question",
          "actions": [
            "Navigate to organization dashboard",
            "Click 'View Survey Matrix' button",
            "Matrix expands showing all questions and member responses",
            "Scroll horizontally to view all members",
            "Review star ratings for each question",
            "Click 'Hide Survey Matrix' to collapse"
          ],
          "expectedOutcome": "Matrix displays with all questions and member responses in star format",
          "testData": {
            "expectedQuestions": 30,
            "expectedCategories": ["Prophet", "Priest", "King"]
          },
          "validations": [
            "Matrix shows all 30 questions organized by category",
            "Member names appear as column headers",
            "Responses display as star ratings (1-5 stars)",
            "Members without surveys show placeholders",
            "Question column remains fixed during horizontal scroll"
          ]
        },
        {
          "id": "compare-members",
          "order": 6,
          "title": "Compare Team Members",
          "description": "User selects and compares multiple members to see team dynamics",
          "userGoal": "Understand how our team members complement each other",
          "actions": [
            "Select 2-5 members using checkboxes on member cards or matrix",
            "Selected members highlight with blue border",
            "Click 'Compare Selected' button",
            "Review comparison dialog showing:",
            "- Team member overview with scores",
            "- Team balance analysis",
            "- Complementary strengths",
            "- Potential friction points",
            "- Growth opportunities",
            "- Biblical reflection",
            "Click 'Close' to return to dashboard"
          ],
          "expectedOutcome": "Comparison insights display with actionable team dynamics analysis",
          "testData": {
            "selectedMembers": ["member1", "member2", "member3"],
            "minSelection": 2,
            "maxSelection": 5
          },
          "validations": [
            "Comparison dialog opens",
            "All selected members' scores display",
            "Team balance score calculated",
            "Complementary strengths identified",
            "Recommendations provided",
            "Biblical references included"
          ]
        },
        {
          "id": "view-member-survey",
          "order": 7,
          "title": "View Another Member's Survey",
          "description": "User views a team member's survey in read-only mode",
          "userGoal": "See detailed responses from a specific team member",
          "actions": [
            "Navigate to organization dashboard",
            "Find member in members list",
            "Click 'View Survey' button for that member",
            "Full survey results page loads",
            "Review member's survey details",
            "Use browser back to return to dashboard"
          ],
          "expectedOutcome": "Member's survey displays in read-only mode",
          "testData": {
            "targetMember": "Another organization member",
            "readonly": true
          },
          "validations": [
            "Survey page loads for selected member",
            "Page is read-only (no edit/retake buttons)",
            "All survey details visible",
            "Print option available",
            "Back button returns to dashboard"
          ]
        },
        {
          "id": "invite-new-members",
          "order": 8,
          "title": "Invite New Members",
          "description": "User generates and shares invitation link with new members",
          "userGoal": "Invite others from my church to join our organization",
          "actions": [
            "Navigate to organization dashboard",
            "Click 'Invite Members' button",
            "View invitation link and code",
            "Click 'Copy Link' button",
            "Share link via email or messaging"
          ],
          "expectedOutcome": "Invitation link copied to clipboard for sharing",
          "testData": {
            "invitationLink": "https://app.url/join/ABC12345",
            "invitationCode": "ABC12345"
          },
          "validations": [
            "Invitation panel displays",
            "Link format is correct",
            "Code is displayed",
            "Copy confirmation message shows",
            "Link can be shared externally"
          ]
        },
        {
          "id": "edit-org-settings",
          "order": 9,
          "title": "Edit Organization Settings",
          "description": "User updates organization details (all members have equal permissions)",
          "userGoal": "Update our organization's name or settings",
          "actions": [
            "Navigate to organization dashboard",
            "Click 'Edit Settings' button",
            "Modify organization name, description, or settings",
            "Click 'Update Organization' button",
            "View success confirmation"
          ],
          "expectedOutcome": "Organization settings are updated successfully",
          "testData": {
            "newName": "Updated Church Name",
            "newDescription": "Updated description",
            "allowMemberInvites": true
          },
          "validations": [
            "Settings form displays with current values",
            "Changes save successfully",
            "Dashboard reflects updates",
            "Success message displays"
          ]
        },
        {
          "id": "switch-survey-context",
          "order": 10,
          "title": "Switch Survey Context",
          "description": "User switches between personal and organizational survey contexts",
          "userGoal": "Take a personal survey separate from my organizational survey",
          "actions": [
            "Click profile dropdown in navigation",
            "View 'Survey Context' section",
            "See available contexts: Personal (👤) and Organization (🏛️)",
            "Click desired context",
            "Context updates",
            "Take survey in selected context"
          ],
          "expectedOutcome": "Survey context switches, allowing separate surveys in different contexts",
          "testData": {
            "contexts": ["personal", "organization"],
            "constraint": "One survey per context"
          },
          "validations": [
            "Context selector displays available options",
            "Selected context updates",
            "Survey page reflects current context",
            "Separate surveys can exist in each context",
            "User cannot have duplicate surveys in same context"
          ]
        }
      ]
    },
    "super-admin-journey": {
      "personaId": "super-admin",
      "title": "Super Administrator Journey",
      "description": "Complete journey for system administrators managing the application",
      "steps": [
        {
          "id": "admin-signin",
          "order": 1,
          "title": "Super Admin Sign-In",
          "description": "Super admin signs in with elevated privileges",
          "userGoal": "Access administrative functions",
          "actions": [
            "Sign in with admin-flagged account",
            "Verify isAdmin flag is set in userProfiles Firestore document"
          ],
          "expectedOutcome": "Admin is authenticated with elevated permissions",
          "testData": {
            "email": "admin@example.com",
            "password": "AdminPassword123!",
            "isAdmin": true
          },
          "validations": [
            "User is authenticated",
            "Admin flag is present",
            "Additional admin features visible"
          ]
        },
        {
          "id": "view-all-organizations",
          "order": 2,
          "title": "View All Organizations",
          "description": "Super admin accesses system-wide organization list",
          "userGoal": "See and manage all organizations in the system",
          "actions": [
            "Click 'Organizations' card on home page",
            "System detects admin flag and navigates to /organizations",
            "View list of ALL organizations",
            "See 'Super Admin View' badge",
            "Review organization details and member counts"
          ],
          "expectedOutcome": "Admin sees complete list of all organizations in system",
          "testData": {
            "expectedRoute": "/organizations",
            "badge": "🔑 Super Admin View - All Organizations"
          },
          "validations": [
            "Admin is routed to /organizations (not individual org)",
            "All organizations display in list",
            "Super admin badge is visible",
            "Each organization shows member count and status",
            "Admin can access any organization"
          ]
        },
        {
          "id": "view-member-management",
          "order": 3,
          "title": "Access Member Management",
          "description": "Super admin navigates to member management for any organization",
          "userGoal": "View and manage members across organizations",
          "actions": [
            "Navigate to organization dashboard",
            "Click 'Manage Members' button",
            "View complete member list with admin controls",
            "See 'Delete Account' buttons (super-admin only)"
          ],
          "expectedOutcome": "Admin sees member management with elevated controls",
          "testData": {
            "route": "/organization/:id/members"
          },
          "validations": [
            "Member list displays all members",
            "'Delete Account' buttons visible (except for admin's own account)",
            "Admin can perform member operations",
            "Standard 'Remove' buttons also visible"
          ]
        },
        {
          "id": "delete-user-account",
          "order": 4,
          "title": "Delete User Account",
          "description": "Super admin permanently deletes a user account and all data",
          "userGoal": "Remove a user account from the system completely",
          "actions": [
            "View member management page",
            "Click 'Delete Account' button for target user",
            "System loads deletion summary showing:",
            "- User name and email",
            "- Number of surveys",
            "- Organization memberships",
            "- Admin roles in organizations",
            "If user is last admin in any org:",
            "- Error displays, deletion blocked",
            "- Admin must assign another admin first",
            "If no blockers:",
            "- Type user's email address exactly",
            "- Click 'DELETE ACCOUNT PERMANENTLY' button",
            "- Confirm deletion",
            "System deletes all user data:",
            "- All surveys (all contexts)",
            "- User survey index",
            "- Organization memberships",
            "- User profile",
            "- Updates organization member counts",
            "Success message displays",
            "Member list refreshes"
          ],
          "expectedOutcome": "User account and all associated data permanently deleted",
          "testData": {
            "targetUser": "user@example.com",
            "confirmationType": "email address",
            "blockers": ["last admin in organization"]
          },
          "validations": [
            "Deletion summary loads correctly",
            "Last admin blocker prevents deletion if applicable",
            "Email confirmation required",
            "Delete button disabled until email matches",
            "All user data removed from Firestore",
            "Organization member counts updated",
            "Success message displays",
            "Member list refreshes without deleted user",
            "Firebase Auth account remains (manual deletion needed)"
          ]
        },
        {
          "id": "delete-organization",
          "order": 5,
          "title": "Delete Organization",
          "description": "Super admin permanently deletes an organization",
          "userGoal": "Remove an inactive or problematic organization",
          "actions": [
            "Navigate to organization dashboard or list",
            "Click 'Delete Organization' button (super-admin only)",
            "Review deletion confirmation",
            "Confirm deletion",
            "System removes organization and all memberships"
          ],
          "expectedOutcome": "Organization and all memberships deleted",
          "testData": {
            "organizationId": "org-to-delete"
          },
          "validations": [
            "Delete button only visible to super-admins",
            "Confirmation dialog displays",
            "Organization deleted from database",
            "All memberships removed",
            "Organization no longer appears in lists"
          ]
        },
        {
          "id": "move-personal-survey",
          "order": 6,
          "title": "Move Personal Survey to Organization",
          "description": "Super admin moves a user's personal survey to an organization",
          "userGoal": "Help users transition personal surveys to organizational context",
          "actions": [
            "Navigate to admin features or user management",
            "Select user with personal survey",
            "Choose target organization",
            "Click 'Move Survey' button",
            "Confirm move operation",
            "Survey is reassigned to organization context"
          ],
          "expectedOutcome": "Personal survey becomes organizational survey",
          "testData": {
            "userId": "user-123",
            "surveyId": "survey-456",
            "targetOrganizationId": "org-789"
          },
          "validations": [
            "Survey organizationId field updates",
            "Survey no longer appears as personal",
            "Survey appears in organization dashboard",
            "Organization statistics include moved survey",
            "User can view survey in organizational context"
          ]
        },
        {
          "id": "view-all-personal-surveys",
          "order": 7,
          "title": "View All Personal Surveys",
          "description": "Super admin views system-wide list of personal surveys",
          "userGoal": "Monitor personal survey usage and identify surveys for potential organizational migration",
          "actions": [
            "Navigate to admin dashboard or surveys section",
            "Filter to show only personal surveys (organizationId null or empty)",
            "View list with user information",
            "Identify surveys that could be moved to organizations"
          ],
          "expectedOutcome": "Complete list of all personal surveys in system",
          "testData": {
            "filterCriteria": "organizationId is null"
          },
          "validations": [
            "Only personal surveys display",
            "User information shown for each survey",
            "Survey details accessible",
            "Move to organization option available"
          ]
        },
        {
          "id": "monitor-system-health",
          "order": 8,
          "title": "Monitor System Health",
          "description": "Super admin reviews system-wide statistics and health",
          "userGoal": "Ensure the application is functioning properly",
          "actions": [
            "View admin dashboard",
            "Review system statistics:",
            "- Total users",
            "- Total organizations",
            "- Total surveys (personal and organizational)",
            "- Active users",
            "Monitor for issues or anomalies"
          ],
          "expectedOutcome": "System health data visible to admin",
          "testData": {
            "metrics": ["userCount", "orgCount", "surveyCount"]
          },
          "validations": [
            "All metrics display correctly",
            "Data is current",
            "No system errors visible"
          ]
        }
      ]
    }
  },
  "testConfiguration": {
    "environment": "Firebase Emulators",
    "emulatorPorts": {
      "auth": 9099,
      "firestore": 8080,
      "ui": 4000
    },
    "applicationUrl": "http://localhost:4200",
    "testFramework": "Playwright",
    "browserSupport": ["chromium", "firefox", "webkit"]
  },
  "dataModel": {
    "userProfile": {
      "firstName": "string",
      "lastName": "string",
      "email": "string",
      "biblicalLeadershipProfile": "Prophet | Priest | King | Balanced",
      "scores": {
        "prophet": "number (0-50)",
        "priest": "number (0-50)",
        "king": "number (0-50)"
      }
    },
    "survey": {
      "userId": "string",
      "questions": "array of 30 responses (1-5 rating)",
      "createdAt": "timestamp",
      "updatedAt": "timestamp",
      "scores": {
        "prophet": "number",
        "priest": "number",
        "king": "number"
      }
    }
  },
  "businessRules": {
    "oneSurveyPerUser": "Each user can have only one survey at a time. Edit and Retake operations update the existing survey.",
    "surveyScoring": "30 questions total: 10 Prophet, 10 Priest, 10 King. Each rated 1-5. Maximum score per category: 50.",
    "profileCalculation": "Biblical leadership profile is determined by the highest score among Prophet, Priest, and King categories.",
    "authentication": "Email/password authentication only. Users must be authenticated to access surveys and profiles."
  }
}
