Files
Charon/docs/plans/current_spec.md
GitHub Actions 10582872f9 fix(tests): Enhance CrowdSecConfig with new input fields and improve accessibility
- Added IDs to input fields in CrowdSecConfig for better accessibility.
- Updated labels to use <label> elements for checkboxes and inputs.
- Improved error handling and user feedback in the CrowdSecConfig tests.
- Enhanced test coverage for console enrollment and banned IP functionalities.

fix: Update SecurityHeaders to include aria-label for delete button

- Added aria-label to the delete button for better screen reader support.

test: Add comprehensive tests for proxyHostsHelpers and validation utilities

- Implemented tests for formatting and help text functions in proxyHostsHelpers.
- Added validation tests for email and IP address formats.

chore: Update vitest configuration for dynamic coverage thresholds

- Adjusted coverage thresholds to be dynamic based on environment variables.
- Included additional coverage reporters.

chore: Update frontend-test-coverage script to reflect new coverage threshold

- Increased minimum coverage requirement from 85% to 87.5%.

fix: Ensure tests pass with consistent data in passwd file

- Updated tests/etc/passwd to ensure consistent content.
2026-02-06 17:38:08 +00:00

14 KiB

QA Remediation Plan: Frontend Coverage, Type-Check, and Threshold Alignment

Objective: Complete the QA remediation for frontend test coverage and TypeScript type-checking, while aligning local vs CI coverage thresholds and auditing coverage configuration hygiene.

Scope: Frontend test suite, coverage thresholds, CI checks, and related config files.

Status (Feb 2026): Draft plan pending approval.


1. Introduction

This plan focuses on removing the friction points flagged in docs/reports/qa_report.md: a narrow frontend coverage gap, TypeScript test type errors, and inconsistent local vs CI coverage thresholds. The goal is to make the QA bar feel like a single, well-lit runway: every local run should match what CI expects, and coverage should be earned through tests that describe behavior, not through fragile exclusions.


2. Research Findings

2.1. Coverage and Thresholds

2.2. Type-Check Failures (Tests)

2.3. API Types Driving Test Mocks

2.4. CI Enforcement Points

2.5. Config Hygiene Review (Requested Files)

  • codecov.yml: patch threshold is 85; project threshold is auto + 1%.
  • .gitignore: already ignores playwright/.auth/ and playwright-report/.
  • .dockerignore: excludes Playwright and test artifacts.
  • Dockerfile: unrelated to coverage/type-check; no changes expected.

3. Requirements (EARS Notation)

  • WHEN coverage is collected for frontend or backend tests, THE SYSTEM SHALL use the skill runner as the primary path and treat direct scripts as a legacy fallback only.
  • WHEN the frontend test suite runs locally, THE SYSTEM SHALL enforce the same coverage threshold logic as CI to avoid threshold drift.
  • WHEN TypeScript type-check runs against test files, THE SYSTEM SHALL report zero type errors and zero unused symbol violations.
  • WHEN coverage reports are generated, THE SYSTEM SHALL include meaningful tests for API client and UI warning paths instead of relying on exclusions.
  • WHEN Codecov evaluates patch coverage, THE SYSTEM SHALL require 100% patch coverage for modified lines.
  • WHEN Playwright artifacts are generated, THE SYSTEM SHALL prevent secrets (e.g., playwright/.auth) from being tracked or uploaded inadvertently.
  • WHEN any test or coverage run is executed, THE SYSTEM SHALL execute E2E tests first to validate UI/UX stability before unit or integration tests.

4. Technical Specifications

4.1. Frontend Coverage Targets

Target: Restore frontend statements coverage to >= 87.5% (or align both local and CI to a single value, based on decision below).

Key files to cover:

4.2. Type-Check Corrections

Goal: Align test mocks to current domain types and remove unused imports.

Primary target files:

4.3. Threshold Alignment Strategy

Decision needed: unify local and CI thresholds.

Options:

  1. Single Threshold Everywhere (Recommended)
  2. Explicit Local/CI Split (Documented)
    • Keep 87.5 local, 85 CI, but document it clearly and reflect it in QA expectations.
    • Add a README or QA policy note to avoid confusion.

4.4. Codecov Configuration Alignment

  • Set patch target in codecov.yml to 100% and treat it as mandatory for every PR.
  • Maintain project thresholds consistent with the chosen coverage target.

4.5. Coverage Execution Priority

  • Primary: use the skill runner for coverage collection (Playwright coverage and test coverage scripts).
  • Legacy fallback: allow direct script invocation only when the skill runner cannot be used; record the reason.

4.6. Locale Coverage Consistency

Decision required: keep locale coverage consistent with Codecov by explicitly excluding locale resources.

Options:

  1. Exclude locale resources (Recommended)
  • Add frontend/src/locales/** to coverage exclude in frontend/vitest.config.ts.
  • Add a matching Codecov ignore entry for frontend/src/locales/** to keep reports consistent.
  1. Test locale resources
  • Add a small health test that imports locale JSON and validates required keys.
  • Keep Codecov ignore list unchanged.

4.5. Config Hygiene Review

  • .gitignore: verify playwright/.auth/ is present (it is) and keep it.
  • .dockerignore: no updates required; Playwright and test outputs are excluded.
  • Dockerfile: no updates required for this QA-focused task.

5. Implementation Plan

Phase 1: QA Baseline and Threshold Decision (Least Requests)

  1. Run baseline type-check

    • Execute npm run type-check in frontend/package.json to capture actual errors.
    • Record exact failing files and error messages; use these as the source of truth (not the report).
  2. Capture current coverage totals

  3. Decide coverage alignment approach

    • Choose between “single threshold everywhere” vs “documented split.”
    • Record decision in this plan and align tooling accordingly.
  4. Confirm E2E-first execution

  • Use the skill runner for E2E coverage and validate the required E2E-first order.
  • Capture rationale: UI/UX breakage invalidates downstream unit coverage signals.

Phase 2: Type-Check Fixes (Test Mocks and Imports)

  1. Repair mocks against current types

  2. Remove unused symbols

    • Remove unused imports and variables flagged by tsc (e.g., fireEvent, within, or unused mocks).
  3. Confirm clean type-check

    • Re-run npm run type-check until zero errors remain.

Phase 3: Coverage Restoration and Threshold Alignment

PIVOT: Focus on Form Component Branch Coverage (High ROI)

Current branch coverage is 79.89%, requiring +7.61 percentage points to reach 87.5% threshold. Form components have the lowest branch coverage and represent the highest ROI for closing this gap.

  1. Expand AccessListForm.tsx coverage (frontend/src/components/__tests__/AccessListForm.test.tsx)

    • Current branch coverage: 76.28%
    • Add tests for:
      • Form submission with invalid data (validation error paths).
      • Conditional rendering of optional fields (role selection, description toggles).
      • Error state handling and recovery.
      • Edit vs create modes (branching logic).
  2. Expand CredentialManager.tsx coverage (frontend/src/components/__tests__/CredentialManager.test.tsx)

    • Current branch coverage: 64.04% (lowest)
    • Add tests for:
      • Credential selection/deselection logic (branching).
      • Add/edit/delete credential modal flows.
      • Form field validation conditional branches.
      • Error state rendering and user feedback paths.
  3. Expand FileUploadSection.tsx coverage (frontend/src/components/__tests__/FileUploadSection.test.tsx)

    • Current branch coverage: 70.58%
    • Add tests for:
      • File type validation branches (accept/reject logic).
      • Drag-and-drop vs click upload paths.
      • Error handling (file too large, unsupported type).
      • Progress and completion state branches.
  4. Expand ProxyHostForm.tsx coverage (frontend/src/components/__tests__/ProxyHostForm.test.tsx)

    • Current branch coverage: 74.84%
    • Add tests for:
      • Conditional field rendering based on proxy type selection.
      • Form submission with various configurations.
      • Validation error paths (required fields, format validation).
      • Edit vs create mode branching.
  5. Address locale coverage

    • Decide on exclusion vs minimal test:
      • Exclude: add src/locales/** to coverage.exclude in frontend/vitest.config.ts.
      • Test: add a small test that imports and validates the locale JSON structure.
    • If exclusion is chosen, add a matching ignore entry to codecov.yml to keep local and Codecov coverage aligned.
  6. Align thresholds

  7. Coverage execution path

    • Use the coverage skill runner as the default path for E2E coverage and document the legacy fallback.

Phase 4: Integration and Verification

  1. Run coverage + type-check

    • npm run test:coverage
    • npm run type-check
  2. CI parity check

  3. Document outcome in QA report


6. Acceptance Criteria

  • Branch coverage reaches 87.5%+ (up from current 79.89%) through form component test expansion.
  • Overall frontend coverage meets or exceeds 87.5% threshold across all metrics.
  • Form components (AccessListForm, CredentialManager, FileUploadSection, ProxyHostForm) achieve branch coverage reflective of test expansion scope.
  • npm run type-check completes with zero errors and zero unused symbol violations.
  • Codecov patch coverage policy is mandatory at 100% for modified lines.
  • QA report reflects the new status and explicitly notes any intentionally excluded paths (locales).
  • E2E tests run first and pass before unit/integration coverage is collected.

7. Risks and Mitigations

  • Risk: Branch coverage tests require deep understanding of form validation and state management logic.
    • Mitigation: Analyze existing form test patterns and prioritize high-branch-count first (CredentialManager at 64% will yield largest gains).
  • Risk: Raising patch coverage in Codecov could fail legacy PRs.
    • Mitigation: Gate the change to the remediation branch and notify reviewers in PR summary.

8. Confidence Score

Confidence: 85%

Rationale: The form components are known, their branch coverage gaps are quantified (79.89% → 87.5%+), and branch coverage is directly testable through input validation paths, conditional rendering, and error state handling. The scope is well-defined and high-ROI.