# pocs/poc-02-tickets/seeds/seed-tickets.yaml
#
# Support Ticket POC — Seed Manifest
#
# Standard seeder contract:
#   - admin user: password Admin123!, role admin, verified
#   - role-specific demo users: password Demo123!, verified
#   - predictable data with stable titles for deterministic tests
#   - idempotent: safe to run on every server start
#
# Execution order (four phases):
#   Phase 1 — Roles
#   Phase 2 — Users
#   Phase 3 — Assignments
#   Phase 4 — Domain data (categories and tickets)
#
# Note on state machine transitions:
#   Seeded tickets are created with status fields set directly (bypassing
#   the state machine) to establish known test state. State machine
#   transitions are tested via the API in TESTING.md.

# ─── Phase 1: Roles ─────────────────────────────────────────────

roles:
  - name: admin
    description: "Full system access. Can manage all tickets, unblock, and delete."

  - name: agent
    description: "Support agent. Can assign, resolve, and close tickets."

  - name: customer
    description: "End user. Can create tickets, add comments, and reopen closed tickets."

# ─── Phase 2: Users ─────────────────────────────────────────────

users:
  - username: admin
    email: admin@tickets.example.com
    password: "Admin123!"
    verified: true

  - username: sarah
    email: sarah@tickets.example.com
    password: "Demo123!"
    verified: true

  - username: mike
    email: mike@tickets.example.com
    password: "Demo123!"
    verified: true

  - username: alice
    email: alice@tickets.example.com
    password: "Demo123!"
    verified: true

  - username: bob
    email: bob@tickets.example.com
    password: "Demo123!"
    verified: true

# ─── Phase 3: Assignments ───────────────────────────────────────

assignments:
  - username: admin
    roles: [admin]

  - username: sarah
    roles: [agent]

  - username: mike
    roles: [agent]

  - username: alice
    roles: [customer]

  - username: bob
    roles: [customer]

# ─── Phase 4: Domain data ───────────────────────────────────────
#
# Categories first, then tickets.
#
# identity_field notes:
#   - For Category: name is unique — safe identity field
#   - For Ticket: title is used as identity for seeder idempotency

data:

  # ── Categories ─────────────────────────────────────────────────

  - action: adl.tickets.category.create
    data:
      name: "Account"
      description: "Login, registration, and account management issues"

  - action: adl.tickets.category.create
    data:
      name: "Billing"
      description: "Charges, invoices, refunds, and payment issues"

  - action: adl.tickets.category.create
    data:
      name: "Technical"
      description: "Bugs, errors, and technical problems"

  - action: adl.tickets.category.create
    data:
      name: "Feature Request"
      description: "New feature suggestions and enhancement requests"

  # ── Tickets ────────────────────────────────────────────────────
  #
  # Ticket 1: in_progress (alice reported, sarah assigned)
  # Ticket 2: open (bob reported, unassigned)
  # Ticket 3: open (alice reported, unassigned)
  # Ticket 4: resolved (bob reported, mike assigned)
  # Ticket 5: closed (alice reported, sarah assigned)

  - action: adl.tickets.ticket.create
    as: admin
    data:
      title: "Cannot log in to my account"
      description: |
        I've been trying to log in for the past hour but keep getting
        "Invalid credentials" even though I'm sure my password is correct.
        I've tried resetting my password but the reset email never arrives.
      status: "in_progress"
      priority: "high"
      reporterId: "alice"
      reporterName: "Alice"
      assigneeId: "sarah"
      assigneeName: "Sarah"

  - action: adl.tickets.ticket.create
    as: admin
    data:
      title: "Billing charge incorrect"
      description: |
        I was charged $49.99 on my last invoice but my plan is $29.99/month.
        Please review and issue a refund for the difference.
      status: "open"
      priority: "medium"
      reporterId: "bob"
      reporterName: "Bob"

  - action: adl.tickets.ticket.create
    as: admin
    data:
      title: "Feature request: dark mode"
      description: |
        It would be great to have a dark mode option in the dashboard.
        The current light theme is hard on the eyes during late-night sessions.
      status: "open"
      priority: "low"
      reporterId: "alice"
      reporterName: "Alice"

  - action: adl.tickets.ticket.create
    as: admin
    data:
      title: "API returns 500 on export"
      description: |
        When I try to export my data via the API endpoint /api/export,
        I get a 500 Internal Server Error. This started happening after
        the last update. Here's the request I'm making:

        ```
        curl -X POST https://app.example.com/api/export \
          -H "Authorization: Bearer <token>" \
          -d '{"format":"csv"}'
        ```
      status: "resolved"
      priority: "critical"
      reporterId: "bob"
      reporterName: "Bob"
      assigneeId: "mike"
      assigneeName: "Mike"
      resolution: "Fixed a null pointer in the export handler. Deployed in v2.3.1."

  - action: adl.tickets.ticket.create
    as: admin
    data:
      title: "Old ticket — password reset"
      description: |
        I need to reset my password but the self-service reset page
        is returning an error. Can an admin reset it manually?
      status: "closed"
      priority: "medium"
      reporterId: "alice"
      reporterName: "Alice"
      assigneeId: "sarah"
      assigneeName: "Sarah"
      resolution: "Password reset manually. User confirmed access restored."
      closedAt: "2026-02-15T10:30:00Z"
