Skip to content

feat: achieve 100% unit test coverage with performance regression guards#7

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1776152774-100-percent-test-coverage
Open

feat: achieve 100% unit test coverage with performance regression guards#7
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1776152774-100-percent-test-coverage

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Summary

Adds comprehensive unit tests across all components, services, interceptors, pipes, and directives — going from ~6 service-only spec files to 33 spec files with 447 tests achieving 100% line/branch/function/statement coverage.

New spec files (27): auth component, if-authenticated directive, 3 interceptors, footer/header layout, 5 article shared components, 3 article page components, 4 profile components/pages, profile routes, settings component, app component/config/routes, list-errors component, 2 pipes.

Expanded: user.service.spec.ts with error handling (4XX/5XX), exponential backoff retry logic, getCurrentUserSync(), and auth state observable tests.

Config changes:

  • vitest.config.ts: Added 100% coverage thresholds for lines/functions/branches/statements
  • package.json: Added test:coverage:ci script (vitest run --coverage)
  • Added @vitest/coverage-v8 and zone.js as dev dependencies

Review & Testing Checklist for Human

  • @angular/core version drift in bun.lock: The lockfile resolved @angular/core to 21.2.4 while package.json pins other @angular/* packages at 21.1.1. Verify this mismatch doesn't cause peer dependency issues or subtle runtime differences. Consider whether this bump was intentional or a side effect of bun install.
  • Coverage threshold sustainability: All thresholds are set to 100%. Confirm that .html and .css template files (which show 0% in the report) are properly excluded from threshold enforcement, and that adding new source files won't break CI until tests are added.
  • Mock fidelity in tests: Many test files use as any for service mocks rather than typed mocks. Spot-check a few specs (e.g., article.component.spec.ts, profile.component.spec.ts) to verify the mocks reflect actual service interfaces and that tests exercise real component logic rather than just the mocks.
  • provideAppInitializer integration test: The test in app.config.spec.ts bootstraps TestBed with the full appConfig.providers to cover lines 74-77. Verify this test isn't flaky — it relies on ApplicationInitStatus.donePromise resolving and the real JwtService/UserService initializing in jsdom.

Recommended test plan: Run bun run test:coverage:ci locally and confirm the coverage report shows 100% across all .ts files with exit code 0. Then try adding a new untested function to any source file and verify the threshold enforcement fails the run.

Notes

  • Tests follow existing repo conventions: Vitest with jsdom, zone.js imports, TestBed with beforeAll + initTestEnvironment pattern required by the pool: 'threads' config.
  • No production source code was modified — only test files and config.
  • The beforeAll / initTestEnvironment pattern means each spec file must initialize TestBed exactly once. Files with multiple describe blocks only call it in the first block.

Link to Devin session: https://app.devin.ai/sessions/8727d068b98941bfa16cb82f11b76ee3
Requested by: @dr-phil

…, interceptors, pipes, and directives

- Track 1: Core auth component & if-authenticated directive specs
- Track 2: API, error, and token interceptor specs
- Track 3: Footer and header layout component specs
- Track 4: Expanded articles, comments, and tags service specs
- Track 5: Article, editor, and home page component specs
- Track 6: Article comment, list, meta, preview, and favorite button specs
- Track 7: Follow button, profile articles/favorites, and profile page specs
- Track 8: Settings component, app component, app config, and app routes specs
- Track 9: List errors component, default-image and markdown pipe specs
- Track 10: Coverage thresholds (100% lines/functions/branches/statements) and test:coverage:ci script
- Added profile.routes.spec.ts for lazy-loaded route coverage
- Expanded user.service.spec.ts with error handling, retry logic, and sync method tests
- Added @vitest/coverage-v8 and zone.js dev dependencies

33 test files, 447 tests, 100% coverage on all metrics

Co-Authored-By: Phil Bedford <phil.g.bed@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant