> ## Documentation Index
> Fetch the complete documentation index at: https://docs.equa.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing Architecture

> Test frameworks, E2E strategy, coverage targets, and CI pipeline

# Testing Architecture

## Overview

The Equa platform uses a layered testing strategy across frontend and backend.

## Test Frameworks

| Layer               | Framework                          | Repository               | Command               |
| ------------------- | ---------------------------------- | ------------------------ | --------------------- |
| Frontend unit tests | Jest 29 + React Testing Library 14 | `equa-web`               | `yarn test`           |
| Frontend E2E tests  | Playwright                         | `equa-web`               | `yarn test:e2e`       |
| Backend unit tests  | (colocated)                        | `equa-server`            | `yarn test`           |
| Command Center E2E  | Playwright                         | `command-center-so`      | `npx playwright test` |
| Pattern library     | Storybook interaction tests        | `equa-patternlib-nextjs` | `npm run storybook`   |

## Frontend Testing (equa-web)

### Unit Tests (Jest 29 + React Testing Library)

Source: `equa-web/package.json` (jest configuration)

* **Framework:** Jest 29 with React Testing Library 14 (migrated from Jest 26 + Enzyme in PR #465)
* **Location:** Colocated `*.test.ts` / `*.test.tsx` files alongside source
* **Mock pattern:** Pattern library mocked via `equa-web/src/shared/mocks/patternlibMock.js`
* **Coverage:** No explicit thresholds configured
* **Test count:** 52 tests passing

### E2E Tests (Playwright)

Source: `equa-web/e2e/`

| Test File                         | Coverage                            |
| --------------------------------- | ----------------------------------- |
| `auth-modal-security.spec.ts`     | Authentication modal security flows |
| `regression-fixed-issues.spec.ts` | Regression tests for resolved bugs  |
| `agreements.spec.ts`              | Agreements feature workflows        |
| `google-auth-smoke.spec.ts`       | Google authentication smoke test    |

### Visual Regression Tests (PR #509)

Automated screenshot comparison in CI captures key routes and compares against baseline images. Diff images are uploaded as artifacts when regressions are detected.

### Running Tests

```bash theme={null}
# Unit tests
cd ~/Documents/repos/equa-web
yarn test

# E2E tests (requires frontend + backend running)
yarn test:e2e
```

<Warning>
  E2E tests require both the frontend (`localhost:8080`) and backend (`localhost:3000`) to be running.
</Warning>

## Backend Testing (equa-server)

Source: `equa-server/modules/` (colocated test files)

* **Framework:** Varies by module (some use Jest, some use native Node test runner)
* **S3Client mocking:** Documented in `equa-server/modules/api/README.md`
* **Database:** Tests run against a test database (requires PostgreSQL)

## Command Center Testing

Source: `command-center-so/e2e/`

* **Framework:** Playwright
* **Config:** `command-center-so/playwright.config.ts`
* **Scope:** Chat interface, gateway connection, settings, error reporting

## CI Pipeline

### Backend (GitHub Actions validation + legacy Cloud Build path)

Source: `equa-server/.github/workflows/ci.yml`, `equa-server/cloudbuild.yaml`, `equa-server/railway.toml`

```
1. GitHub Actions runs install, type checks, API tests, and a Docker build check on pushes to `main`, `staging`, and `prod-deploy`
2. Railway service config defines the current runtime target shape for `equa-server`
3. Cloud Build / Cloud Run config remains in the repo as a legacy deploy path, not as the primary browser-facing runtime story
```

### Frontend (GitHub Actions)

Source: `equa-web/.github/workflows/ci.yml`

```
1. Lint & Build (ESLint + webpack production build)
2. Unit Tests (Jest 29 + React Testing Library)
3. E2E Smoke (Playwright)
4. Regression Tests
5. Visual Regression Tests (screenshot comparison)
```

### Frontend Deployment (Railway)

Source: `equa-web/railway.toml`

```
1. nixpacks detects Node.js
2. yarn install
3. yarn build (webpack production build)
4. Deploy
```

## Test Data Management

* **Development:** Schema sync enabled (`DATABASE_SYNC !== 'false'` in development)
* **Production:** Schema migrations managed via TypeORM
* **Seed data:** No automated seed scripts found

## Coverage Gaps

<Warning>
  The following areas have limited or no test coverage:

  * No explicit coverage thresholds in any repository
  * No automated seed data for local development testing
  * No integration test suite for cross-module interactions
  * No performance/load testing infrastructure
  * Limited E2E coverage relative to the frontend module surface
</Warning>

## Recommended Improvements

1. Add coverage thresholds to Jest config (target: 70% lines/branches)
2. Create seed data scripts for consistent local testing
3. Expand E2E test coverage to all major user flows
4. Add API integration tests for endpoint validation
5. Implement performance benchmarks for critical paths
