# formulas/run-user-test.toml
#
# Persona-based UX evaluation against the harb stack.
#
# Type: sense — produces UX metrics, changes no code or contracts.
# The formula spins up a full self-contained stack, runs Playwright against
# all 5 personas, collects structured reports, then tears the stack down.

[formula]
id          = "run-user-test"
type        = "sense"
description = "Persona-based UX evaluation against the harb stack"
depends_on  = [973]   # evidence directory structure must exist

# ── Stack management ─────────────────────────────────────────────────────────
# The formula is self-contained: it starts and stops its own stack.

[stack]
start_cmd  = "./scripts/dev.sh start"
health_cmd = "./scripts/dev.sh health"
stop_cmd   = "./scripts/dev.sh stop"

# ── Inputs ───────────────────────────────────────────────────────────────────
# 5 personas across 2 funnels. Each persona has a dedicated Playwright spec
# that simulates the full journey: connect wallet → mint ETH → buy KRK →
# stake → verify position.

[[inputs.funnels]]
name = "passive-holder"

  [[inputs.funnels.personas]]
  name    = "tyler"
  display = "Tyler 'Bags' Morrison"
  spec    = "tests/e2e/usertest/tyler-retail-degen.spec.ts"

  [[inputs.funnels.personas]]
  name    = "alex"
  display = "Alex Rivera"
  spec    = "tests/e2e/usertest/alex-newcomer.spec.ts"

  [[inputs.funnels.personas]]
  name    = "sarah"
  display = "Sarah Park"
  spec    = "tests/e2e/usertest/sarah-yield-farmer.spec.ts"

[[inputs.funnels]]
name = "staker"

  [[inputs.funnels.personas]]
  name    = "priya"
  display = "Dr. Priya Malhotra"
  spec    = "tests/e2e/usertest/priya-institutional.spec.ts"

  [[inputs.funnels.personas]]
  name    = "marcus"
  display = "Marcus 'Flash' Chen"
  spec    = "tests/e2e/usertest/marcus-degen.spec.ts"

# ── Steps ────────────────────────────────────────────────────────────────────

[[steps]]
id          = "stack-up"
description = "Spin up full stack (boots Docker services, waits for health)"
run         = "./scripts/dev.sh start"

[[steps]]
id          = "run-personas"
description = "Run all 5 personas via Playwright (workers=1, sequential to avoid account conflicts)"
run         = "./scripts/run-usertest.sh"
after       = ["stack-up"]

[[steps]]
id          = "collect"
description = "Aggregate per-persona JSON reports from tmp/usertest-results/ into evidence/user-test/{date}.json"
output      = "evidence/user-test/{date}.json"
schema      = "evidence/README.md#user-test"
after       = ["run-personas"]

[[steps]]
id          = "stack-down"
description = "Tear down stack"
run         = "./scripts/dev.sh stop"
after       = ["collect"]

[[steps]]
id          = "deliver"
description = "Commit evidence file to main and post summary to issue as comment"
after       = ["collect"]

# ── Products ─────────────────────────────────────────────────────────────────
# Three outputs following the standard evidence delivery pattern:
#   1. evidence file  → committed to main
#   2. screenshots    → referenced inside the evidence file
#   3. summary        → posted as issue comment

[[products]]
type        = "evidence"
path        = "evidence/user-test/{date}.json"
schema      = "evidence/README.md#user-test"
destination = "commit"

[[products]]
type        = "screenshots"
path        = "test-results/usertest/"
destination = "evidence-ref"   # paths recorded in the evidence file, not committed separately

[[products]]
type        = "summary"
destination = "issue-comment"
