Skip to content

fix: run src/browser unit tests in CI and stabilize the vendor digest - #238

Open
Agnik47 wants to merge 1 commit into
agentrhq:mainfrom
Agnik47:fix/231-run-browser-tests-in-ci
Open

fix: run src/browser unit tests in CI and stabilize the vendor digest#238
Agnik47 wants to merge 1 commit into
agentrhq:mainfrom
Agnik47:fix/231-run-browser-tests-in-ci

Conversation

@Agnik47

@Agnik47 Agnik47 commented Aug 8, 2026

Copy link
Copy Markdown

Description

The unit vitest project excluded src/browser/**/*.test.ts, and no other project picked those files up — plugin covers plugins/*/test/**, e2e lists individual files under tests/e2e/, and smoke covers tests/smoke/**. The result was that 44 test files / 596 tests covering CDP, snapshots, the Playwright sandbox and the local Cloak runtime ran in no CI job at all.

Removing the exclude also restores vitest's default excludes (node_modules, dist) for that project, and matches the other four projects, none of which set exclude.

One small correction to the issue: the exclude came from #196, not #216. #216 only dropped the clis/** half of the list during the adapter migration:

commit unit exclude
c08cb276 (init) ['clis/**/*.test.{ts,js}']
b51cac37 (#196) ['clis/**/*.test.{ts,js}', 'src/browser/**/*.test.ts']
0470ac43 (#216) ['src/browser/**/*.test.ts']

Why the two extra changes are here

Enabling the tests surfaces a pre-existing failure in src/browser/run/playwright-client-build.test.ts, which shells out to build-playwright-sandbox-client.mjs --check. Without fixing it, this PR would turn the windows-latest unit job red. Two independent causes:

1. The vendor digest was platform-dependent. vendorDigest() hashes each vendored file's relative path, built with path.join(), so entries hash as client\artifact.ts on Windows and client/artifact.ts everywhere else. The check could therefore never pass on Windows:

as-is (native separator) : 882f0880d4838423647cc617ff199298536b606803fd8dbcdb3cb5a8bed31131
POSIX-normalized         : 23a97afd31faa0e5a64b116e897c3b90123eafcc2ca9102586a062eaf533350d
vendor-manifest.json     : 23a97afd31faa0e5a64b116e897c3b90123eafcc2ca9102586a062eaf533350d

Normalizing the separator to / is a no-op on POSIX, so the pinned hash is unchanged and vendor-manifest.json needs no regeneration.

2. The vendored sources and generated bundle are compared byte-for-byte. On a checkout with core.autocrlf=true (the Git for Windows default, and there was no .gitattributes), CRLF breaks both the digest and the separate "bundle is up to date" comparison — the latter with a misleading Generated Playwright QuickJS client is out of date error. .gitattributes pins just those two paths to LF.

Both fixes are necessary; I verified each one independently fails without the other.

Related issue: #231

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Screenshots / Output

npm run typecheck, npm run build and the git diff --exit-code generated-artifact check all pass.

All 44 previously-skipped files now run and pass through the real unit project (Windows, Node 22):

$ npx vitest run --project unit src/browser/
 Test Files  44 passed (44)
      Tests  594 passed | 2 skipped (596)

Full unit project, before and after — same pre-existing failures, no new ones:

before:  Test Files  4 failed | 91 passed (95)     Tests  15 failed | 1544 passed | 5 skipped (1564)
after:   Test Files  4 failed | 135 passed (139)   Tests  15 failed | 2138 passed | 7 skipped (2160)

The 4 failing files (hosted/runner, hosted/files, plugin, docs-sync-review-cli) fail identically on unmodified main on this machine and pass in CI; they're a local environment artifact (my temp dir lives under $HOME, so paths render as ~\AppData\...). The two plugin-project failures (pypi, instagram) also reproduce on clean main.

One thing I could not verify

I don't have Bun locally, so I could not run the bun-test job, which also uses --project unit and will now execute these 44 files. QuickJSHost (WASM via quickjs-emscripten) and the test that spawns process.execPath look like the likeliest friction points under Bun. Flagging it rather than assuming — happy to adjust if that job goes red.

Notes

  • No new test added deliberately: the guard for the digest regression is playwright-client-build.test.ts itself, which now actually runs on Windows in CI. Adding a dedicated test would mean exporting vendorDigest() out of the provenance script purely for testability — happy to do it if you'd prefer.
  • .gitattributes is intentionally scoped to the two byte-sensitive paths rather than a repo-wide * text=auto.
  • Existing Windows clones will see those vendored files re-checkout as LF once this lands.

The `unit` vitest project excluded `src/browser/**/*.test.ts`, and no other
project picked them up: `plugin` covers `plugins/*/test/**`, `e2e` lists
individual files under `tests/e2e/`, and `smoke` covers `tests/smoke/**`.
That left 44 test files (596 tests) covering CDP, snapshots, the Playwright
sandbox and the local Cloak runtime out of every CI job.

The exclude was introduced in agentrhq#196 rather than agentrhq#216 — that merge only dropped
the `clis/**` half of the list after the adapter migration.

Dropping the exclude also restores vitest's default excludes (node_modules,
dist) and matches the other four projects, none of which set `exclude`.

Enabling the tests surfaces a pre-existing Windows failure in
`playwright-client-build.test.ts`, which shells out to
`build-playwright-sandbox-client.mjs --check`. Two independent causes:

- `vendorDigest()` hashes the relative path of each vendored file, built with
  `path.join()`, so entries hash as `client\artifact.ts` on Windows and
  `client/artifact.ts` elsewhere. The digest was therefore platform-dependent
  and could never match the pinned manifest on Windows. Normalizing the
  separator to `/` is a no-op on POSIX, so the pinned hash is unchanged.
- The vendored sources and the generated bundle are compared byte-for-byte, so
  a CRLF checkout breaks both the digest and the "bundle is up to date" check.
  `.gitattributes` pins just those paths to LF.

Refs agentrhq#231
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🟢 No documentation gap found — medium confidence

The automated review found no documentation gap in the supplied changes.

This review is advisory and does not block merging.

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