Skip to content

Frontend Testing Infrastructure — Unit, Integration & E2E Tests #308

@ElioNeto

Description

@ElioNeto

Frontend Testing Infrastructure

Establish comprehensive testing for the Angular frontend, covering unit tests, integration tests with mock API, and end-to-end tests.

Current State

  • Frontend has no tests (no spec files)
  • Karma + Jasmine are in devDependencies but unused
  • No e2e framework configured
  • No CI pipeline for frontend tests

Requirements

1. Unit Tests (Jasmine + Karma)

One spec file per component and service:

  • Services: Mock HTTP responses, test all methods (success, error, empty)
  • Components: Test rendering with various inputs, user interaction
  • Pipes/Filters: Test transformation logic
  • Minimum coverage: 80%

2. Integration Tests (Jasmine + HttpClientTestingModule)

  • Test services against HttpClientTestingModule
  • Verify correct endpoints are called
  • Verify request/response transformations
  • Test error handling and retry logic

3. Component Tests (Jasmine + ComponentFixture)

  • Test all components with:
    • Loading state
    • Empty state
    • Error state
    • Success state
    • User interaction (click, input, submit)

4. End-to-End Tests (Cypress or Playwright)

  • Setup: Install Cypress or Playwright
  • Tests:
    • Login/Auth flow
    • Dashboard CRUD operations
    • Key Explorer search, insert, delete
    • Admin token management
    • Stats page loading
    • Navigation between pages
  • CI Integration: Run e2e tests in GitHub Actions with Docker Compose

5. CI Pipeline

Add a frontend test job to .github/workflows/ci.yml:

frontend-tests:
  runs-on: ubuntu-latest
  defaults:
    run:
      working-directory: ./frontend
  steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
    - run: npm ci
    - run: npm run test -- --watch=false --browsers=ChromeHeadless
    - run: npm run build -- --configuration production

Acceptance Criteria

  • All existing components have spec files
  • All services have spec files
  • Minimum 80% line coverage
  • CI pipeline runs frontend tests
  • E2E tests cover critical user flows
  • Test documentation in CONTRIBUTING.md

Parent Epic

#290

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions