Skip to content

fix: Fix test infrastructure and add comprehensive test coverage [MBA-1487]#9

Open
devin-ai-integration[bot] wants to merge 6 commits intomainfrom
devin/1776200950-fix-test-infra-coverage
Open

fix: Fix test infrastructure and add comprehensive test coverage [MBA-1487]#9
devin-ai-integration[bot] wants to merge 6 commits intomainfrom
devin/1776200950-fix-test-infra-coverage

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 14, 2026

Summary

Fixes broken test tooling and adds comprehensive unit + E2E test coverage per MBA-1487.

Test infra fixes:

  • Updated tsconfig.app.json to include all src/**/*.ts (excluding specs and test-setup.ts) and tsconfig.spec.json to include both specs and source files; removed stale "types": ["jasmine"] (project uses Vitest)
  • Removed broken zone.js / zone.js/testing imports from test-setup.ts and all 6 existing service spec files — the app uses zoneless Angular 21 (provideZonelessChangeDetection) and zone.js was never installed as a dependency
  • Removed redundant per-file beforeAll TestBed initialization from each spec (now handled centrally in test-setup.ts)

New components & tests:

  • Created TestComponent and TestDirectiveComponent displaying VERSION.full, with data-testid attributes for E2E targeting
  • Added these to AppComponent template alongside a <h2 data-testid="app-heading">Hello, angular-app</h2> heading
  • Created AppModule as an NgModule wrapper importing the standalone components
  • Unit tests for both new components, AppComponent, and AppModule (191 total tests passing)

E2E & Playwright config:

  • baseURL now reads process.env.BASE_URL with fallback to http://localhost:4200/
  • New e2e/app-shell.spec.ts with 4 tests: heading render, data-testid visibility, no JS console errors, visual regression (toHaveScreenshot)
  • Committed baseline screenshot for visual regression (App-Shell-visual-regression-1-chromium-linux.png)

Coverage:

  • Added @vitest/coverage-v8@4.0.18 dev dependency
  • Added 80% statement coverage threshold in vitest.config.ts
  • Current coverage: 86.06% statements

Updates since last revision

  • Changed heading from <h1> to <h2 data-testid="app-heading"> to avoid Playwright strict-mode violations (existing E2E tests use page.locator('h1') which resolved to 2 elements with the original <h1>)
  • Excluded src/test-setup.ts from tsconfig.app.json per Devin Review feedback — it was being compiled during ng build unnecessarily
  • E2E locators in app-shell.spec.ts now use [data-testid="app-heading"] instead of tag-based selectors

Review & Testing Checklist for Human

  • Production UI impact: app.component.html now renders <h2>Hello, angular-app</h2>, <app-test />, and <app-test-directive /> above the router outlet on every page. This visibly changes the Conduit app UI. Confirm this is intentional and acceptable.
  • console.info in production: Both TestComponent.ngOnInit and TestDirectiveComponent constructor call console.info(...) on every page load. Verify this is desired for production builds.
  • @angular/core version drift: bun.lock resolved @angular/core to 21.2.4 (was 21.1.1), while package.json still pins 21.1.1. Confirm this resolution change is acceptable or if it should be reverted.
  • Run bun run test --run to verify all 191 unit tests pass
  • Run bun run test:e2e to verify all Playwright E2E tests pass (including visual regression baseline generation)
  • Run bun run test:coverage -- --run to verify the 80% statement threshold is met

Suggested manual test

  1. bun run start → open http://localhost:4200/
  2. Verify "Hello, angular-app" heading and two "Angular Version: X.X.X" lines appear above the article feed
  3. Verify no JavaScript console errors

Notes

  • The AppModule is not used at runtime (app bootstraps via bootstrapApplication); it exists solely to support the module compilation and render tests requested in the ticket.
  • The visual regression baseline screenshot is environment-specific (chromium-linux) and may need regeneration on first run in different environments.

Frontend with new components
Coverage report showing 86.06% statements

Link to Devin session: https://app.devin.ai/sessions/d81ab689be07495c9a65722550909cfd


Open with Devin

Part A: Fix broken test infra
- Update tsconfig.app.json with proper include/exclude for source files
- Update tsconfig.spec.json with proper include for spec and source files
- Remove broken zone.js imports from test-setup.ts and all existing spec files
- Create app.component.spec.ts

Part B: Fix Playwright E2E config
- Add process.env.BASE_URL fallback to playwright.config.ts

Part C: Add unit tests
- Create TestComponent with Angular version display
- Create TestDirectiveComponent with Angular version display
- Create AppModule importing all standalone components
- Add comprehensive unit tests for all new components

Part D: Expand E2E tests
- Add app-shell.spec.ts with heading, testid, console error, and visual regression tests

Part E: Code coverage
- Configure vitest coverage thresholds (80% statements)

Co-Authored-By: unknown <>
@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

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration
Copy link
Copy Markdown
Author

Test Results — MBA-1487

Tested locally: unit tests, build, E2E, coverage, and frontend rendering.

All Tests Passing
  • Unit tests (191/191): PASSED — bun run test --run
  • Build: PASSED — bun run build
  • E2E tests (126/126): PASSED — bun run test:e2e
  • Coverage (86.06% statements): PASSED — above 80% threshold
  • Frontend renders correctly: PASSED — heading, both Angular Version elements visible
Frontend App Screenshot

Frontend

HTML Code Coverage Report

86.06% Statements, 42.85% Branches, 91.52% Functions, 83.33% Lines

Coverage

Playwright HTML Report (126/126 passed)
Top of report Bottom of report
Top Bottom
Visual Regression Baseline Screenshot

Baseline

Devin session

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.

0 participants