Skip to content

Conversation

@HardMax71
Copy link
Owner

@HardMax71 HardMax71 commented Jan 31, 2026


Summary by cubic

Add E2E code coverage to the frontend using Monocart Playwright Reporter and tighten unit-test coverage filters to avoid double counting. Generates HTML and LCOV reports focused on real app code.

  • New Features

    • Capture JS coverage in Playwright (page, userPage, adminPage) and attach to the test report.
    • Add Monocart reporter to output coverage/e2e/report.html and coverage/e2e/lcov.info, filtered to /src and excluding node_modules and tests.
    • Align Vitest coverage: exclude API, test files, tests, and barrel index files.
  • Dependencies

    • Added monocart-reporter (dev).

Written for commit 4c2ac22. Summary will update on new commits.

Summary by CodeRabbit

  • Tests

    • Enabled automatic per-test E2E coverage collection and automatic attachment of coverage reports for Playwright runs.
    • Expanded coverage filtering to exclude non-unit targets and refine unit test reporting.
    • Added a test mock helper to standardize API response unwrapping in unit tests.
  • Chores

    • Added a coverage reporter package and updated test-runner configuration to produce consolidated E2E coverage outputs.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 31, 2026

📝 Walkthrough

Walkthrough

Adds JS coverage collection to Playwright E2E: fixtures start/stop coverage around pages and attach reports; Playwright reporters always include monocart-reporter with coverage config; monocart-reporter dependency added; vitest coverage excludes expanded; a test mock for api-interceptors was added.

Changes

Cohort / File(s) Summary
E2E Fixtures
frontend/e2e/fixtures.ts
Started/stopped JS coverage in overridden page, userPage, and adminPage fixtures and attached coverage via testInfo. Added page: Page to TestFixtures declarations and updated fixture signatures to accept testInfo.
Playwright Config
frontend/playwright.config.ts
Reworked reporter into an array that always appends monocart-reporter with coverage settings (v8, text, lcovonly → coverage/e2e/lcov.info) and a sourceFilter including /src/ while excluding node_modules/__tests__.
Dependency
frontend/package.json
Added monocart-reporter (^2.9.23) to dependencies/devDependencies.
Vitest Coverage
frontend/vitest.config.ts
Expanded coverage exclude list to omit __tests__ folders and barrel re-exports (src/**/index.ts) (plus existing exclusions).
Test Utilities
frontend/src/lib/__tests__/user-settings.test.ts
Added a mock for ../api-interceptors exposing an unwrap helper that throws on error or returns data to stabilize tests.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Test as Playwright Test
    participant Fixture as E2E Fixture
    participant Page as Browser Page
    participant Reporter as monocart-reporter

    Test->>Fixture: request `page` / `userPage` (provides testInfo)
    Fixture->>Page: start JS coverage
    Fixture-->>Test: yield Page to test
    Test->>Page: execute test actions
    Test->>Fixture: test finishes
    Fixture->>Page: stop JS coverage, collect data
    Fixture->>Reporter: attach coverage via testInfo
    Reporter-->>Test: generate coverage outputs (HTML, lcov, etc.)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped from page to page and traced each line,
I wrapped the tests in coverage, neat and fine.
Monocart gathers every little trace,
Reports unfurl like a carrot-shaped lace,
A rabbit’s cheer for coverage done in time! 🎋

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: coverage configs' is vague and generic, using non-descriptive language that doesn't clearly indicate what coverage configurations are being fixed or why. Revise the title to be more specific about the primary change, such as 'feat: add E2E code coverage and align unit test coverage filters' to better reflect the main objectives.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/frontend-e2e-tests-added

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@frontend/e2e/fixtures.ts`:
- Around line 24-30: Wrap the JS coverage teardown in a try/finally and skip
collection if the page has been closed: for the page fixture (the async page: ({
page }, use, testInfo) => { ... }) and similarly for userPage and adminPage
fixtures, call page.coverage.startJSCoverage before use, then in finally check
page.isClosed() and only call await page.coverage.stopJSCoverage() and
attachCoverageReport(coverage, testInfo) when not closed; ensure any exceptions
from stopJSCoverage are not raised when the page is closed by guarding with that
check.
- Line 2: The import in frontend/e2e/fixtures.ts wrongly pulls
attachCoverageReport from 'monocart-reporter/playwright'; update the module
import to pull attachCoverageReport directly from the package root by changing
the import source to 'monocart-reporter' so the symbol attachCoverageReport is
imported from the main entry that exports it (no other code changes needed).

In `@frontend/playwright.config.ts`:
- Around line 13-27: The sourceFilter function currently checks
sourcePath.includes('/src/') which breaks on Windows backslashes; update the
reporter's sourceFilter (the arrow function assigned to sourceFilter in the
reporter config) to first normalize the incoming sourcePath by converting
Windows backslashes to forward slashes (or use path.posix/replace backslashes)
and then perform precise directory checks using '/src/', '/node_modules/' and
'/__tests__/' (avoid loose substring matches) so filtering works cross-platform
and avoids false positives.

In `@frontend/vitest.config.ts`:
- Around line 19-31: Update the exclude glob in the vitest config's exclude
array so nested route components are skipped; specifically, in
frontend/vitest.config.ts modify the exclude pattern 'src/routes/*.svelte'
within the exclude array to 'src/routes/**/*.svelte' to ensure all routes at any
depth (e.g., src/routes/admin/AdminEvents.svelte) are excluded from coverage.

@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@frontend/playwright.config.ts`:
- Around line 15-19: The monocart-reporter config writes to
coverage/e2e/report.html and coverage/e2e/lcov.info but the directory may not
exist; fix by ensuring the directory is created before the reporter runs—add a
top-level require/import for fs and call fs.mkdirSync('coverage/e2e', {
recursive: true }) (or equivalent) in the Playwright config file before the
reporter configuration block (the monocart-reporter entry and its outputFile
paths) so the parent directory exists when the reporter writes files.

@HardMax71 HardMax71 merged commit f6b4add into main Jan 31, 2026
22 checks passed
@HardMax71 HardMax71 deleted the fix/frontend-e2e-tests-added branch January 31, 2026 15:44
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.

2 participants