# User Testing Scripts This directory contains 5 Playwright test scripts simulating different user personas interacting with the Kraiken DeFi protocol. ## Personas 1. **Marcus "Flash" Chen** (`marcus-degen.spec.ts`) - Degen/MEV Hunter - Anvil account #1 - Tests edge cases, probes snatching mechanics, looks for exploits - Skeptical, technical, profit-driven 2. **Sarah Park** (`sarah-yield-farmer.spec.ts`) - Cautious Yield Farmer - Anvil account #2 - Researches thoroughly, seeks sustainable returns - Conservative, reads everything, compares to Aave 3. **Tyler "Bags" Morrison** (`tyler-retail-degen.spec.ts`) - Retail Degen - Anvil account #3 - YOLOs in without reading, gets confused easily - Impulsive, mobile-first, community-driven 4. **Dr. Priya Malhotra** (`priya-institutional.spec.ts`) - Institutional/Analytical Investor - Anvil account #4 - Analyzes mechanism design with academic rigor - Methodical, game-theory focused, large capital allocator 5. **Alex Rivera** (`alex-newcomer.spec.ts`) - Crypto-Curious Newcomer - Anvil account #0 - First time in DeFi, intimidated but willing to learn - Needs hand-holding, compares to Coinbase ## Prerequisites 1. **Running stack** (required before tests): ```bash cd /home/debian/harb ./scripts/dev.sh start ``` 2. **Wait for stack health**: - Anvil on port 8545 - Ponder/GraphQL on port 42069 - Web-app on port 5173 (proxied on 8081) - Contracts deployed (deployments-local.json populated) ## Running Tests ### All personas: ```bash cd /home/debian/harb npx playwright test tests/e2e/usertest/ ``` ### Individual persona: ```bash npx playwright test tests/e2e/usertest/marcus-degen.spec.ts npx playwright test tests/e2e/usertest/sarah-yield-farmer.spec.ts npx playwright test tests/e2e/usertest/tyler-retail-degen.spec.ts npx playwright test tests/e2e/usertest/priya-institutional.spec.ts npx playwright test tests/e2e/usertest/alex-newcomer.spec.ts ``` ### With UI (headed mode): ```bash npx playwright test tests/e2e/usertest/marcus-degen.spec.ts --headed ``` ### Debug mode: ```bash npx playwright test tests/e2e/usertest/marcus-degen.spec.ts --debug ``` ## Output ### Screenshots Saved to `test-results/usertest//`: - Landing page - Wallet connection - Swap transactions - Stake forms - Error states - Final dashboard ### JSON Reports Saved to `/home/debian/harb/tmp/usertest-results/.json`: ```json { "personaName": "Marcus Flash Chen", "testDate": "2026-02-13T21:45:00.000Z", "pagesVisited": [ { "page": "Landing", "url": "http://localhost:8081/app/", "timeSpent": 2000, "timestamp": "2026-02-13T21:45:02.000Z" } ], "actionsAttempted": [ { "action": "Connect wallet", "success": true, "timestamp": "2026-02-13T21:45:05.000Z" } ], "screenshots": ["test-results/usertest/marcus-flash-chen/..."], "uiObservations": [ "Lands on app, immediately skeptical - what's the catch?" ], "copyFeedback": [ "Landing page needs 'Audited by X' badge prominently displayed" ], "tokenomicsQuestions": [ "What prevents someone from flash-loaning to manipulate VWAP?" ], "overallSentiment": "Intrigued but cautious. Mechanics are novel..." } ``` ### Console Logs Each test logs observations in real-time: ``` [Marcus] Lands on app, immediately skeptical - what's the catch? [Marcus - COPY] Landing page needs "Audited by X" badge prominently displayed [Marcus - TOKENOMICS] What prevents someone from flash-loaning to manipulate VWAP? [SCREENSHOT] landing-page: test-results/usertest/marcus-flash-chen/... ``` ## What Each Test Does ### Marcus (Degen) 1. Lands on app, looks for audit/docs 2. Connects wallet immediately 3. Tests small swap (0.01 ETH) then large swap (1.5 ETH) 4. Stakes at low tax rate (2%) to test snatching 5. Looks for snatch targets among other positions 6. Examines statistics for meta trends ### Sarah (Yield Farmer) 1. Reads landing page thoroughly 2. Looks for About/Docs/Team FIRST 3. Checks for audit badge 4. Connects wallet hesitantly 5. Studies statistics and tax rates 6. Small test purchase (0.1 ETH) 7. Conservative stake at 15% tax 8. Compares to Aave mentally ### Tyler (Retail) 1. Glances at landing, immediately connects wallet 2. Looks for buy button (gets confused) 3. Finds cheats page randomly 4. Buys $150 worth without research 5. Stakes at random tax rate (5%) 6. Checks for immediate gains 7. Gets confused about tax/snatching 8. Looks for Discord to ask questions ### Priya (Institutional) 1. Looks for whitepaper/technical docs 2. Checks for audit and governance info 3. Analyzes liquidity snapshot 4. Tests large swap (5 ETH) to measure slippage 5. Reviews tax rate distribution for Nash equilibrium 6. Stakes at calculated optimal rate (12%) 7. Evaluates risk, composability, exit liquidity 8. Writes detailed assessment ### Alex (Newcomer) 1. Reads landing page carefully but confused 2. Looks for tutorial/getting started 3. Nervous about connecting wallet (scam fears) 4. Reads info tooltips, still confused 5. Looks for FAQ (risk disclosures) 6. Tiny test purchase (0.05 ETH) 7. Overwhelmed by tax rate choices 8. Stakes conservatively at 15%, worried about snatching 9. Compares to Coinbase staking ## Analyzing Results ### Key Metrics: - **Time spent per page** - Which pages confuse users? Where do they linger? - **Failed actions** - What breaks? What error messages are unclear? - **UI observations** - What's confusing, missing, or broken? - **Copy feedback** - What messaging needs improvement? - **Tokenomics questions** - What concepts aren't explained? ### Common Themes to Look For: - **Onboarding friction** - Do newcomers understand what to do? - **Trust signals** - Are audit/security concerns addressed? - **Tax rate confusion** - Can users choose optimal rates? - **Snatching fear** - Is the mechanism explained clearly? - **Return visibility** - Can users see earnings potential? ## Extending Tests To add a new persona: 1. Copy an existing spec file 2. Update persona details and behaviors 3. Use a different Anvil account (keys in wallet-provider.ts) 4. Implement persona-specific journey 5. Add to this README ## Troubleshooting ### Tests fail immediately: - Check stack is running: `./scripts/dev.sh status` - Check deployments exist: `cat onchain/deployments-local.json` ### Wallet connection fails: - Check wallet-provider.ts is creating correct context - Verify RPC URL is accessible ### Screenshots missing: - Check `test-results/usertest/` directory exists - Verify filesystem permissions ### JSON reports empty: - Check `tmp/usertest-results/` directory exists - Verify writeReport() is called in finally block