Skip to content

refactor(playwright-coverage): split index into focused modules#177

Merged
soroushm merged 10 commits into
mainfrom
feature/playwright-covrage
Jun 25, 2026
Merged

refactor(playwright-coverage): split index into focused modules#177
soroushm merged 10 commits into
mainfrom
feature/playwright-covrage

Conversation

@soroushm

@soroushm soroushm commented Jun 25, 2026

Copy link
Copy Markdown
Member

What

Splits the @soroush.tech/playwright-coverage package's single ~195-line src/index.ts into focused, co-located modules while keeping the public API unchanged.

Module Contents
types.ts The public interfaces (JsCoverageSource, CoverageFixtureArgs, PlaywrightCoverageOptions, PlaywrightCoverage)
report.ts Report-config helpers (defaultEntryFilter, defaultSourcePath, toGlobs, buildSourceFilter, resolveReportOptions, resolveRawDir) — package-internal, not re-exported
collector.ts collect (private) + createAutoCoverageFixture + CoverageFixtureTuple
lifecycle.ts createGlobalSetup, createGlobalTeardown
index.ts playwrightCoverage factory + export * barrel re-exports

Each module gets a co-located *.test.ts. report.test.ts now unit-tests the helpers directly rather than driving them through createGlobalTeardown.

Why

The package was one chunky file. The public API stays in index.ts (single entry, default factory) while internals move to siblings — matching the new guidance added to packages.md: extract internal modules once the entry file grows unwieldy; the app-level "one file per helper" rule is scoped to components, not packages.

Also included

  • packages.md — documents when/how to split a package's internal modules.
  • package.json — version bump 0.1.0 → 1.0.0.
  • pnpm-lock.yaml — sync so the workspace package resolves.

Verification

  • pnpm lint — clean (0 warnings)
  • pnpm typecheck — clean
  • pnpm test:coverage — 25 tests, 100% statements/branches/functions/lines
  • pnpm build — succeeds
  • Public API unchanged; sole external consumer (apps/web e2e) uses only the default export.

Summary by CodeRabbit

  • New Features

    • Added a new Playwright coverage package for collecting and merging end-to-end browser coverage into a single report.
    • Release workflows now support multiline release notes input using \n line breaks.
  • Bug Fixes

    • The design system page is now included in the sitemap.
    • Improved page layout handling so content can expand more reliably in the app shell.
  • Documentation

    • Updated package documentation and publishing notes for the new coverage package.

soroushm added 6 commits June 25, 2026 23:39
Drop the noindex,nofollow opt-out from the design system page config so it
inherits the default index,follow. The sitemap plugin auto-includes any page
without a noindex robots meta, so /design/system now appears in sitemap.xml —
update the SEO e2e to assert that. Also genericize the sitemap plugin's
docstring and toPath comment so they no longer reference site-specific routes
or host. /projects remains the sole noindex page.
Switch the Content wrapper from View to Flex with flex-grow: 1 so it grows
to fill the parent's height instead of sizing to its content. Drop the now
unused View import.
…lose #175

Extract the Playwright -> monocart e2e coverage harness out of apps/web into a new
publishable workspace package, @soroush.tech/playwright-coverage:

- auto fixture capturing per-test V8 JS coverage (Chromium only)
- globalSetup/globalTeardown that clear and aggregate raw dumps into an lcov report
- declarative include/exclude glob API (picomatch, repo-relative, cross-platform)
  that builds the monocart sourceFilter; a raw report.sourceFilter still works as a
  fallback (globs win when both are set)

Mirrors @soroush.tech/vite-plugin-msw-server: peer deps (@playwright/test, monocart),
tsdown dual-build + publishConfig, MIT LICENSE, README (install/usage/options/Codecov
in CI/FAQ), 100% coverage.

apps/web now consumes it via workspace:* — fixtures, coverage.setup and
coverage.teardown re-export the instance from a shared coverage.ts that passes the
Vike +Page include glob; coverage-options.ts is removed. E2E coverage output is
unchanged (the 9 +Page.tsx files at 100%).
The workflow_dispatch `notes` input is a single-line string (dispatch has no
multiline field). Expand `\n` escapes to real line breaks with printf '%b' so
notes render as proper multiline markdown in the GitHub Release.
Lets the publish workflow target @soroush.tech/playwright-coverage. Requires a
manual first publish + npm trusted-publisher config before OIDC releases work.
…r/lifecycle modules

Extract the package internals from a single 195-line index.ts into focused
sibling modules — types, report config helpers, the per-test collector, and
the global setup/teardown lifecycle — each with co-located tests. index.ts
keeps the public API (default factory + barrel re-exports) unchanged.
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@soroushm, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 23 minutes and 20 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cb984a3a-09ac-4160-bba1-d7f674bae7ac

📥 Commits

Reviewing files that changed from the base of the PR and between d97c991 and f6c6597.

📒 Files selected for processing (6)
  • .github/workflows/cd-packages.yml
  • packages/packages.md
  • packages/playwright-coverage/src/lifecycle.test.ts
  • packages/playwright-coverage/src/report.ts
  • packages/playwright-coverage/src/types.ts
  • packages/playwright-coverage/vitest.config.ts
📝 Walkthrough

Walkthrough

The PR adds a reusable Playwright coverage package, wires it into the web app’s E2E coverage setup, and updates the package release workflow. It also removes the design system page’s noindex,nofollow robots setting and updates sitemap expectations.

Changes

Playwright coverage package

Layer / File(s) Summary
Coverage types and report options
packages/playwright-coverage/src/types.ts, packages/playwright-coverage/src/report.ts, packages/playwright-coverage/src/report.test.ts
PlaywrightCoverageOptions and report helpers define raw-dir resolution, glob handling, source-path normalization, and report option merging, with tests for the default and override behavior.
Auto coverage fixture
packages/playwright-coverage/src/collector.ts, packages/playwright-coverage/src/collector.test.ts
The auto fixture starts and stops page.coverage, writes each run to a JSON file under the raw directory, and its tests cover enabled, disabled, and browser-matched paths.
Lifecycle and public factory
packages/playwright-coverage/src/lifecycle.ts, packages/playwright-coverage/src/index.ts, packages/playwright-coverage/src/index.test.ts, packages/playwright-coverage/src/lifecycle.test.ts
playwrightCoverage exports Playwright test/expect together with lifecycle hooks; setup deletes stale dumps and teardown aggregates .json dumps into CoverageReport before generating output.
Package scaffolding and docs
packages/playwright-coverage/package.json, packages/playwright-coverage/tsconfig.json, packages/playwright-coverage/tsdown.config.ts, packages/playwright-coverage/eslint.config.js, packages/playwright-coverage/LICENSE, packages/playwright-coverage/README.md, packages/README.md, packages/packages.md
The new package manifest, build configs, license, and package docs define the published package entrypoint, scripts, dependencies, and packaging rules.
Web app wiring and release workflow
apps/web/package.json, apps/web/src/test/e2e/coverage.ts, apps/web/src/test/e2e/coverage.setup.ts, apps/web/src/test/e2e/coverage.teardown.ts, apps/web/src/test/e2e/fixtures.ts, .github/workflows/cd-packages.yml
The web E2E suite now imports the shared coverage package, and the package release workflow adds playwright-coverage to workflow_dispatch and expands \n escapes in release notes.

Design system indexing

Layer / File(s) Summary
Page layout and robots config
apps/web/src/common/Blueprint/Blueprint.tsx, apps/web/src/pages/design/system/+config.ts
The design system blueprint content now uses Flex with flex-grow: 1, and the page config no longer exports robots: 'noindex,nofollow'.
Sitemap expectations and comments
apps/web/src/test/e2e/seo.e2e.ts, packages/vite-plugin-sitemap/src/index.ts
The sitemap E2E test now expects the design system URL to be present, and the sitemap package comments are reworded around static-host redirects and noindex scanning.

Sequence Diagram(s)

sequenceDiagram
  participant PlaywrightTest
  participant playwrightCoverage
  participant page.coverage
  participant CoverageReport

  PlaywrightTest->>playwrightCoverage: call playwrightCoverage(options)
  playwrightCoverage->>PlaywrightTest: return test, expect, globalSetup, globalTeardown
  PlaywrightTest->>playwrightCoverage: run autoCoverage fixture
  playwrightCoverage->>page.coverage: startJSCoverage({ resetOnNavigation: false })
  PlaywrightTest->>playwrightCoverage: run test body
  playwrightCoverage->>page.coverage: stopJSCoverage()
  PlaywrightTest->>playwrightCoverage: run globalTeardown()
  playwrightCoverage->>CoverageReport: add(parsed raw dumps)
  playwrightCoverage->>CoverageReport: generate()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

  • soroush-tech/soroush.tech#173: Both PRs modify the manual npm publishing GitHub Actions workflow (.github/workflows/cd-packages.yml) and adjust package publishing inputs/output handling.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main refactor: splitting the playwright-coverage index into focused modules.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/playwright-covrage

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.

@socket-security

socket-security Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​picomatch@​4.0.31001007482100

View full report

Use String#replaceAll over global-regex replace in defaultSourcePath, and
flatten the nested ternary in toGlobs into a guard clause.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/playwright-coverage/src/index.ts (1)

6-8: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid exporting the internal collector helper from the barrel.

export * from './collector' turns createAutoCoverageFixture into a public API, which is broader than the factory-based surface described for this refactor. If that helper is meant to stay internal, this creates an unnecessary semver commitment.

Suggested diff
 export * from './types'
-export * from './collector'
 export * from './lifecycle'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/playwright-coverage/src/index.ts` around lines 6 - 8, The barrel in
index.ts is exporting the internal collector helper, which exposes
createAutoCoverageFixture as public API; remove the export from ./collector and
keep only the intended factory-based surface. Update the index.ts re-exports so
types and lifecycle remain public while the collector module stays internal, and
verify any needed symbols are imported directly from collector only within the
package.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/cd-packages.yml:
- Around line 99-100: The release notes processing in the workflow is expanding
more than just newline escapes, which can mutate markdown before gh release
create runs. Update the release-notes handling in cd-packages workflow to
convert only literal \n sequences from the workflow_dispatch input, and avoid
using a formatter that interprets other backslash escapes; keep the fix
localized to the step that prepares the release body.

In `@packages/playwright-coverage/src/lifecycle.test.ts`:
- Around line 92-99: The no-op test in createGlobalTeardown uses a fixed rawDir
path in lifecycle.test that can collide with an existing temp directory entry;
update the test to generate a fresh temporary parent directory and set rawDir to
a never-created child path so the absence check is reliably unique. Keep the
change scoped to the no-op case in the createGlobalTeardown test and preserve
the existing makeFakeReport setup.

In `@packages/playwright-coverage/src/types.ts`:
- Around line 40-41: The browser option in the coverage types is too broad and
should be narrowed to Playwright’s browser-name union. Update the `browser`
field in `types.ts` from `string` to the exact `'chromium' | 'firefox' |
'webkit'` union so `collect()` can only compare against valid `browserName`
values and typos are caught at compile time.

---

Nitpick comments:
In `@packages/playwright-coverage/src/index.ts`:
- Around line 6-8: The barrel in index.ts is exporting the internal collector
helper, which exposes createAutoCoverageFixture as public API; remove the export
from ./collector and keep only the intended factory-based surface. Update the
index.ts re-exports so types and lifecycle remain public while the collector
module stays internal, and verify any needed symbols are imported directly from
collector only within the package.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 358b9b65-0c6f-4f2c-89d2-0652a72930b1

📥 Commits

Reviewing files that changed from the base of the PR and between 37ee192 and d97c991.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (28)
  • .github/workflows/cd-packages.yml
  • apps/web/package.json
  • apps/web/src/common/Blueprint/Blueprint.tsx
  • apps/web/src/pages/design/system/+config.ts
  • apps/web/src/test/e2e/coverage-options.ts
  • apps/web/src/test/e2e/coverage.setup.ts
  • apps/web/src/test/e2e/coverage.teardown.ts
  • apps/web/src/test/e2e/coverage.ts
  • apps/web/src/test/e2e/fixtures.ts
  • apps/web/src/test/e2e/seo.e2e.ts
  • packages/README.md
  • packages/packages.md
  • packages/playwright-coverage/LICENSE
  • packages/playwright-coverage/README.md
  • packages/playwright-coverage/eslint.config.js
  • packages/playwright-coverage/package.json
  • packages/playwright-coverage/src/collector.test.ts
  • packages/playwright-coverage/src/collector.ts
  • packages/playwright-coverage/src/index.test.ts
  • packages/playwright-coverage/src/index.ts
  • packages/playwright-coverage/src/lifecycle.test.ts
  • packages/playwright-coverage/src/lifecycle.ts
  • packages/playwright-coverage/src/report.test.ts
  • packages/playwright-coverage/src/report.ts
  • packages/playwright-coverage/src/types.ts
  • packages/playwright-coverage/tsconfig.json
  • packages/playwright-coverage/tsdown.config.ts
  • packages/vite-plugin-sitemap/src/index.ts
💤 Files with no reviewable changes (2)
  • apps/web/src/pages/design/system/+config.ts
  • apps/web/src/test/e2e/coverage-options.ts

Comment thread .github/workflows/cd-packages.yml Outdated
Comment thread packages/playwright-coverage/src/lifecycle.test.ts
Comment thread packages/playwright-coverage/src/types.ts Outdated
- playwright-coverage: narrow the `browser` option from `string` to
  'chromium' | 'firefox' | 'webkit' so typos can't silently skip coverage.
- playwright-coverage: point the teardown no-op test at a unique fresh temp
  path instead of a fixed name that could collide and flake.
- CD: expand only literal `\n` in release notes via parameter expansion;
  the previous `printf '%b'` also interpreted `\t`/`\u`/`\c` and could mangle
  markdown.
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Bundle Report

Changes will decrease total bundle size by 248 bytes (-0.0%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
@soroush.tech/dev-esm 38.07MB -248 bytes (-0.0%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: @soroush.tech/dev-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
chunks/chunk-B8IYPMf7.js (New) 76.02kB 76.02kB 100.0% 🚀
entries/src_pages_design_system.mjs -264 bytes 45.82kB -0.57%
chunks/chunk-CLkGH4DX.js (New) 14.74kB 14.74kB 100.0% 🚀
chunks/chunk-Cd-08pu1.js (New) 4.1kB 4.1kB 100.0% 🚀
chunks/chunk-CJXdBW4v.js (New) 2.6kB 2.6kB 100.0% 🚀
chunks/chunk-DSOZLwMf.js (New) 2.11kB 2.11kB 100.0% 🚀
chunks/chunk-D_xc0_Q-.js (New) 1.9kB 1.9kB 100.0% 🚀
chunks/chunk-DNfeMudB.js (New) 1.77kB 1.77kB 100.0% 🚀
chunks/chunk-CJA8m71F.js (New) 1.6kB 1.6kB 100.0% 🚀
chunks/chunk-B0SP-c61.js (New) 1.43kB 1.43kB 100.0% 🚀
chunks/chunk-BDclXzcw.js (New) 1.23kB 1.23kB 100.0% 🚀
chunks/chunk-DEU5CKOq.js (New) 1.03kB 1.03kB 100.0% 🚀
chunks/chunk-DwrUQk47.js (Deleted) -76.0kB 0 bytes -100.0% 🗑️
chunks/chunk-BxjrYcmG.js (Deleted) -14.74kB 0 bytes -100.0% 🗑️
chunks/chunk-D_5kA_4_.js (Deleted) -4.1kB 0 bytes -100.0% 🗑️
chunks/chunk-BWusyjkM.js (Deleted) -2.6kB 0 bytes -100.0% 🗑️
chunks/chunk-BeZvgAQY.js (Deleted) -2.11kB 0 bytes -100.0% 🗑️
chunks/chunk-_Vq4LuW_.js (Deleted) -1.9kB 0 bytes -100.0% 🗑️
chunks/chunk-CsMZR17T.js (Deleted) -1.77kB 0 bytes -100.0% 🗑️
chunks/chunk-sMJMf9Uw.js (Deleted) -1.6kB 0 bytes -100.0% 🗑️
chunks/chunk-BiB2YQfk.js (Deleted) -1.43kB 0 bytes -100.0% 🗑️
chunks/chunk-B5VjVVD_.js (Deleted) -1.23kB 0 bytes -100.0% 🗑️
chunks/chunk-oB0ulHCJ.js (Deleted) -1.03kB 0 bytes -100.0% 🗑️

Files in chunks/chunk-B8IYPMf7.js:

  • ./src/common/Blueprint/Blueprint.tsx → Total Size: 1.43kB

soroushm added 2 commits June 26, 2026 00:55
The package had no vitest.config.ts, so coverage fell back to vitest's
default reporters (clover/html/json) and never wrote coverage/lcov.info —
breaking the CI step that rewrites SF: paths in that file. Add the same
config the sibling packages use (v8, ['text', 'lcov'], 100% thresholds).
Document that every package ships vitest.config.ts with
coverage.reporter ['text', 'lcov'] — CI reads each package's
coverage/lcov.info, so omitting it breaks the coverage step.
@sonarqubecloud

Copy link
Copy Markdown

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