# 2026-03-28 Q-004 Coverage Remediation Pass 21

## Scope

- Continue strict `Q-004` closure work after Pass 20.
- Fully close the shared error-model hotspot in:
  - `frontend/admin/src/lib/errors/AppError.ts`
  - `frontend/admin/src/lib/errors/index.ts`
- Re-verify closure through targeted error-module tests and full frontend validation.

## Changes

### Frontend

- Added dedicated error-module coverage in:
  - `frontend/admin/src/lib/errors/AppError.test.ts`
- Newly covered behavior includes:
  - `AppError` constructor defaults
  - explicit option handling with `cause`
  - backend response to error-type mapping
  - factory helpers for auth / forbidden / validation / network errors
  - `isAuthError`, `isForbidden`, and `isNetworkError`
  - user-facing message mapping across all error types
  - `isAppError`
  - `getErrorMessage`
  - `isFormValidationError`

### Backend

- No backend code changes were required in this pass.

## Verified Commands

```powershell
cd D:\project\frontend\admin
npm.cmd run test:run -- src/lib/errors/AppError.test.ts
npm.cmd run lint
npm.cmd run build
npm.cmd run test:coverage
```

## Results

### Frontend coverage

- Overall:
  - statements `93.07%`
  - branches `81.35%`
  - functions `90.32%`
  - lines `93.26%`
- Target areas:
  - `src/lib/errors/AppError.ts`: statements `100%`, branches `100%`, functions `100%`, lines `100%`
  - `src/lib/errors/index.ts`: statements `100%`, branches `100%`, functions `100%`, lines `100%`

### Validation outcomes

- Full frontend coverage run now completes with:
  - `51` passing test files
  - `238` passing tests
- The required sequential frontend validation path passed:
  - `test:run -- src/lib/errors/AppError.test.ts`
  - `lint`
  - `build`
  - `test:coverage`

## Validation Notes

- The successful frontend coverage run still emits one post-summary jsdom `AggregateError` network-noise line.
  - It does not fail the command.
  - It remains a real validation-hygiene issue and cannot be hidden.

## Real Conclusion

- `src/lib/errors/AppError.ts` is no longer an open `Q-004` gap.
- `src/lib/errors/index.ts` is no longer an open `Q-004` gap.
- `Q-004` still cannot be honestly declared closed.
- After this pass, the remaining higher-value frontend gaps narrow further to:
  - `src/pages/admin/ImportExportPage/ImportExportPage.tsx`
  - `src/pages/NotFoundPage/NotFoundPage.tsx`
  - `src/lib/hooks/useBreadcrumbs.ts`
  - `src/app/providers/ThemeProvider.tsx`
  - the post-summary jsdom `AggregateError` coverage-noise hygiene issue
