Skip to content

[CRITICAL] Automated testing and CI pipelines coverage [Size: M, Priori... #20

Description

@devwif

[CRITICAL] Improve Automated Testing and CI Pipeline Coverage for WebTUI


🚨 Problem Statement

The current state of automated testing and continuous integration (CI) pipeline coverage in the aldrin-labs/webtui repository is insufficient. This lack of robust automated tests and comprehensive pipeline checks significantly increases the risk of regression bugs and slows down safe, iterative development. Without proper test coverage and CI validation, every new feature or bug fix introduces uncertainty, undermining code quality, security, and developer confidence.

We must urgently enhance the automated test suite and CI pipelines to ensure code correctness, security, and maintainability while enabling rapid, safe releases.


📚 Technical Context

  • Repository: aldrin-labs/webtui
  • Primary Language: Astro + TypeScript
  • Current Dev Dependencies: turbo, typescript, @biomejs/biome
  • Existing CI: GitHub Actions workflow web.yml
  • Current Testing Status: Minimal or no automated test coverage; CI pipelines do not comprehensively validate the codebase
  • Project Phase: Early development with foundational UI components, theming, and modular CSS terminal UI library
  • Known Challenges: Lack of tests impacts reliability & security; no explicit lint/test stages or coverage metrics in CI; documentation gaps on contribution/testing guidelines

🎯 Goals and Success Criteria

Primary Goal:

  • Establish a robust, scalable automated testing framework covering critical components, utilities, and core workflows.
  • Integrate comprehensive CI pipeline steps that automatically run tests, linting, and security checks on every push and pull request.

Acceptance Criteria:

  • Existing codebase is audited for coverage gaps and testability improvements identified
  • Unit tests added for all foundational UI components and utility functions (target >80% coverage)
  • Integration/e2e tests implemented for critical user flows and theming behavior
  • GitHub Actions CI pipeline updated to:
    • Run linting and formatting checks
    • Execute all automated tests with coverage reports
    • Fail builds on test or lint failures
  • Security and dependency checks included in CI (e.g., npm audit, dependabot)
  • Documentation updated with clear testing guidelines and CI pipeline overview
  • No regressions or flaky tests introduced (verified via pipeline stability)
  • Test coverage reports are published and accessible for monitoring

🛠 Detailed Implementation Steps

  1. Audit Current State

    • Review existing test files, if any
    • Identify untested components and critical code paths
    • Analyze current GitHub Actions workflow for CI coverage gaps
  2. Select and Configure Testing Tools

    • Ensure suitable testing framework is in place (e.g., Jest, Testing Library, Playwright for e2e)
    • Configure coverage reporting (e.g., jest --coverage)
    • Integrate testing utilities compatible with Astro/TypeScript
  3. Write Unit and Integration Tests

    • Create unit tests per component in /src/components/ covering props, behavior, and styling logic
    • Cover utility functions and API interaction layers
    • Add integration tests for theme switching, layout rendering, and accessibility states
  4. Implement End-to-End (E2E) Tests

    • Use Playwright or Cypress to simulate user interactions in a headless browser
    • Test key flows: rendering terminal UI, switching themes, responsive layout, component interaction
  5. Enhance CI Pipeline

    • Modify .github/workflows/web.yml to add:
      • Linting (biome lint, prettier --check)
      • Testing with coverage (jest --coverage or equivalent)
      • Build validation (astro build)
      • Security audit (npm audit --audit-level=moderate)
      • Caching dependencies for performance
    • Configure pipeline to fail on any lint or test failure
    • Add badges for test coverage, security status
  6. Documentation Updates

    • Add CONTRIBUTING.md or expand existing docs with:
      • Testing setup instructions
      • How to run tests locally and interpret coverage
      • CI pipeline overview and expected outcomes
    • Add a TESTING.md if more granular details are needed
  7. Validation and Stabilization

    • Run multiple CI builds to ensure no flaky tests
    • Peer review test coverage and CI configuration
    • Address edge cases or flaky behavior

📝 Technical Specifications

  • Testing Framework: Jest + Testing Library for unit/integration; Playwright for e2e
  • CI Pipeline:
    • Run on every push and PR to main/master branch
    • Steps: checkout → install → lint → test → build → security audit
    • Utilize GitHub Actions caching for node_modules and build artifacts
  • Coverage Threshold: Enforce minimum 80% code coverage, configurable via Jest threshold settings
  • Linting: Biome linting rules with strict error-level enforcement
  • Security: npm audit with fail on moderate or higher vulnerabilities
  • Reporting: Upload coverage reports as workflow artifacts or integrate with Coveralls/Codecov
  • Documentation: Markdown files in repo root or docs folder, linked from main README

✅ Validation Checklist

  • Codebase audited for existing test coverage and gaps identified
  • Unit tests added for all core components and utilities
  • Integration tests cover key application flows and theming
  • E2E tests simulate real user interactions successfully
  • CI workflow updated and verified to run lint, tests, build, and security audit on each push/PR
  • CI build fails on any test or lint failure
  • Test coverage threshold enforced and reports generated
  • Documentation updated with testing and CI guidelines
  • No flaky or failing tests after multiple runs
  • Security audit integrated and passes without critical issues

🧪 Testing Requirements

  • Local Testing:
    • Run npm run test or equivalent command to execute unit/integration tests
    • Run npm run test:e2e for end-to-end testing locally
    • Verify linting and formatting compliance with npm run lint and npm run format:check
  • CI Validation:
    • Observe GitHub Actions workflow results on PRs and pushes
    • Confirm coverage reports are generated and meet thresholds
    • Confirm pipeline fails on introduced lint or test errors
  • Regression Verification:
    • Run full test suite after feature merges to ensure no regressions
    • Monitor flaky test reports and address instability if any

📚 Documentation Needs

  • Create or update CONTRIBUTING.md with:
    • How to write tests for new components
    • How to run tests and interpret results
    • Code coverage expectations and how to check them
  • Add TESTING.md with detailed testing strategy and example tests
  • Update README with CI badge for test status and coverage
  • Document CI workflow structure and failure modes
  • Provide troubleshooting tips for common test failures

⚠️ Potential Challenges

  • Astro components testing may require additional setup/mocks to simulate SSR vs client
  • Achieving stable e2e tests can be tricky given UI dynamic states and theming
  • Integrating coverage reporting tools with GitHub Actions might need config tuning
  • Ensuring tests do not become brittle with UI changes requires careful test design
  • Balancing coverage scope and maintainability to avoid over-testing trivial code

🔗 Resources & References


Let's put the pedal to the metal and turn this repo into a fortress of reliability and developer joy! 🚀💥


Part of AI Development Plan Milestone #1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions