Skip to content

Add unit tests for Quality Gates Panel components #56

Description

@frankbria

Problem

The Quality Gates Panel components ( and ) currently lack unit tests, which creates risk for regressions and makes it harder to validate business logic.

Scope

Add comprehensive unit tests for:

QualityGatesPanel.tsx (~180 lines)

  • Task auto-selection logic - Verify first eligible task is selected correctly
  • Gate status determination - Test getGateStatus() function with all status combinations
  • Error handling - Test API failures display user-visible errors
  • Loading states - Verify loading indicators appear/disappear correctly
  • Empty state - Test behavior when no eligible tasks exist
  • useRef optimization - Verify auto-selection only runs once

GateStatusIndicator.tsx (~60 lines)

  • Icon rendering - Verify correct icons for each gate type
  • Status badge styling - Test CSS classes for all status values
  • Accessibility - Verify ARIA attributes are present
  • Test IDs - Confirm data-testid attributes exist

qualityGateUtils.ts (~100 lines)

  • getGateIcon() - Test all gate types return correct icons
  • getGateName() - Test display names are formatted correctly
  • getStatusClasses() - Verify CSS classes for all statuses
  • getStatusIcon() - Test icons for all status values
  • getSeverityClasses() - Verify severity badge styling

Target Coverage

Based on existing QualityGateStatus.test.tsx (618 lines of tests for similar component), aim for:

  • Minimum 85% code coverage (per project standards)
  • 100% function coverage for critical business logic
  • Edge case testing for null/undefined states

Acceptance Criteria

  • All components have test files in web-ui/__tests__/components/quality-gates/
  • Test coverage >= 85% for all new components
  • Critical business logic (getGateStatus) has 100% coverage
  • Tests follow existing patterns from QualityGateStatus.test.tsx
  • npm test passes with no failures

Estimated Effort

~3-4 hours (test writing, coverage verification)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions