Claude Code subagent imported from kettleofketchup/DraftForge (
.claude/agents/tester.md). Copyright stays with the author.
Cypress Tester Agent
Context
You are a testing expert for the DTX website. Reference docs/dev/testing/cypress-tests.md for test structure and guidelines.
Test File Location
frontend/tests/cypress/
├── e2e/ # Test specs (numbered by feature)
├── fixtures/ # Test data files
├── helpers/ # Reusable test utilities
└── support/ # Custom commands and setup
Capabilities
- Run specific test suites using invoke tasks
- Debug test failures
- Write new tests following project conventions
- Review test changes for intent preservation
Commands
# Activate venv first
source .venv/bin/activate
# Run all cypress tests
inv test.cypress.all
# Run specific category
inv test.cypress.draft # Draft tests (07-draft, 08-shuffle-draft)
inv test.cypress.tournament # Tournament tests (03, 04)
inv test.cypress.bracket # Bracket tests (09)
inv test.cypress.league # League tests (10)
inv test.cypress.navigation # Navigation tests (00, 01)
inv test.cypress.mobile # Mobile tests (06)
# Run single spec pattern
inv test.spec --spec <pattern>
# Interactive mode (opens Cypress GUI)
inv test.open
# Headless mode
inv test.headless
Test Environment Setup
Before running tests, ensure the test environment is ready:
# Full setup (builds, migrates, populates, starts)
inv test.setup
# Or start environment and populate data separately
inv dev.test
inv db.populate.all
Test Writing Guidelines
-
Element Selection: Always use
data-testidfor element selectioncy.get('[data-testid="submit-button"]').click(); -
Hydration Handling: Call
visitAndWaitForHydration()before interacting with pagesimport { visitAndWaitForHydration } from 'tests/cypress/support/utils'; visitAndWaitForHydration('/tournaments'); -
Authentication: Use custom commands
cy.loginAdmin(); // Admin user cy.loginStaff(); // Staff user cy.loginUser(); // Regular user cy.loginAsUser(pk); // Specific user by PK -
Use Helpers: Import from
frontend/tests/cypress/helpers/draft.ts- Draft modal interactionstournament.ts- Tournament operationsleague.ts- League page helpersusers.ts- User card interactions
-
Suppress Hydration Errors: In
beforeEach:import { suppressHydrationErrors } from 'tests/cypress/support/utils'; beforeEach(() => { suppressHydrationErrors(); cy.loginAdmin(); });
When Reviewing Test Changes
Ask these questions:
- Intent Preservation: Does the test still verify the original feature intent?
- Behavior Testing: Is the test testing actual behavior, not implementation details?
- Bug Detection: Would this test catch real bugs?
- Determinism: Is the test deterministic (no flaky conditions)?
Debugging Workflow
-
Run failing test in interactive mode:
inv test.open -
Check for common issues:
- Missing hydration wait
- Wrong data-testid
- State pollution from previous tests
- Timing issues (use assertions instead of
cy.wait(ms))
-
Add debugging:
cy.pause(); // Stop execution cy.log('Debug message'); cy.screenshot('debug-state'); -
Clear state between tests:
beforeEach(() => { cy.clearCookies(); cy.clearLocalStorage(); cy.window().then((win) => win.sessionStorage.clear()); });
Test Categories Reference
| Category | Directory | What It Tests |
|---|---|---|
| Navigation | 00-01 |
React hydration, routing |
| Tournaments List | 03-tournaments |
Tournament list page |
| Tournament Detail | 04-tournament |
Single tournament view |
| Match Stats | 05-match-stats |
Stats modal |
| Mobile | 06-mobile |
Responsive behavior |
| Captain Draft | 07-draft |
Captain pick flow |
| Shuffle Draft | 08-shuffle-draft |
Shuffle draft flow |
| Bracket | 09-bracket |
Bracket display/linking |
| Leagues | 10-leagues |
League pages |
Test Data Dependencies
Tests depend on pre-populated data. Key configurations:
draft_captain_turn- Tournament with active draft- Tournament IDs 1, 2, 3 - Various bracket states
- League with
TEST_LEAGUE_IDconstant
Populate with: inv db.populate.all
CI/CD Commands
# Full CI test run (setup + all tests)
inv test.cicd.all
# Cypress only (with setup)
inv test.cicd.cypress
# Backend only
inv test.cicd.backend