Skip to content

Add component tests for the DisputePanel state machine and its five state views #203

Description

@greatest0fallt1me

Description

components/disputes/DisputePanel.tsx (DisputePanel) is a state-machine container that renders one of five views — none, open, voting, ended, executed — from NoneState, OpenState, VotingState, EndedState, and ExecutedState under components/disputes/states/, and accepts an optional onStateChange callback. The shared primitives (TallyBar, CountdownTimer, WarningBanner, DetailsAccordion) already have tests under components/disputes/shared/__tests__/, but DisputePanel, DisputeStateBadge, and the five state views have none. This issue closes that gap using the existing mock fixtures in components/disputes/mock-data.ts.

Requirements and context

  • Add components/disputes/__tests__/DisputePanel.test.tsx driving the panel with mockNoneDispute, mockOpenDispute, mockVotingDispute, mockEndedDispute, and mockExecutedDispute from components/disputes/mock-data.ts.
  • Assert the correct state view renders for each DisputeData input and that DisputeStateBadge shows the matching label/state.
  • Cover at least one state transition (e.g. none to open) and assert onStateChange fires with the new state.
  • Non-functional: control time for any CountdownTimer rendered inside states with fake timers so deadlines do not cause flakiness.
  • Follow the conventions in components/disputes/shared/__tests__/TallyBar.test.tsx and CountdownTimer.test.tsx.

Acceptance criteria

  • components/disputes/__tests__/DisputePanel.test.tsx exists and passes under pnpm test.
  • Each of the five states renders its expected view from the matching mock fixture.
  • DisputeStateBadge label is asserted for every state.
  • At least one transition asserts the onStateChange callback payload.
  • Combined coverage for DisputePanel.tsx and components/disputes/states/* reaches >=85% lines.

Suggested execution

1. Fork the repo and create a branchgit checkout -b feature/dispute-panel-tests.

2. Implement changes — add tests under components/disputes/__tests__/; reuse fixtures from components/disputes/mock-data.ts.

3. Write/extend tests — Jest + React Testing Library with pnpm; mirror the sibling shared/__tests__/ style (describe/it, role queries, fake timers for countdowns).

4. Test and commit

pnpm install
pnpm test
pnpm test:coverage
pnpm lint

Example commit message

test(disputes): cover DisputePanel state machine and the five state views

Guidelines

  • Raise coverage for the disputes state-machine files from 0% to >=85% line coverage.
  • Keep assertions accessibility-aware (the states already expose ARIA roles via shared components); document any missing labels.
  • Timeframe: 96 hours.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions