Skip to content

refactor: consolidate repeated test and benchmark setup - #314

Merged
JustasMonkev merged 1 commit into
mainfrom
refactor/test-setup-duplication
Oct 29, 2026
Merged

JustasMonkev merged 1 commit into
mainfrom
refactor/test-setup-duplication

Conversation

@JustasMonkev

@JustasMonkev JustasMonkev commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

tests/
├── utils.test.ts                  → shared HTML snapshot/compression lifecycle
├── navigation-dialogs.test.ts     → shared crawl setup, wait, and cleanup
├── mcp-http.test.ts               → shared event-stream-suppressing fetch
└── transportFixture.ts            → synchronous forwarding for two race suites
bench/
└── statistics.mjs                 → shared median calculation

Keep scenario assertions, provider-switch conditions, timeout budgets, and benchmark timing loops explicit. No production behavior or public API changes.

Evidence

  • Before: seven compression cases repeated browser setup/cleanup; three crawl cases repeated lifecycle handling; two race suites repeated forwarding transports; HTTP cases duplicated fetch suppression; two benchmarks duplicated median calculation (source inspection).
    After: shared helpers preserve those operations and all existing assertions. npm test: 72 files passed, 2 skipped; 1,852 tests passed, 5 skipped.
  • npm run lint, npm run build, and the slop checker passed.
  • Both node bench/data-url-bench.mjs and node bench/reading-order-bench.mjs completed with their built-in correctness assertions passing.
  • Initial sandboxed tests could not launch browsers or bind local listeners; the full suite passed with those permissions enabled.

Merge Danger

Door: two-way

Revert-only refactor; no data or configuration migration.

Blast Radius: tests

Shared fixtures affect the named regression suites; the shared median affects two benchmark reports. Message forwarding remains synchronous, and crawl cleanup still closes the context before awaiting the audit.

Summary by CodeRabbit

  • Tests
    • Standardized test setup and cleanup across browser, navigation, and transport scenarios while preserving existing behavioral checks.
    • Added shared support for observing transport messages in test scenarios.
  • Chores
    • Consolidated benchmark median calculations into a shared utility, keeping benchmark result calculations consistent.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; the shared helpers preserve the existing test and benchmark behavior.

Summary

This PR shares repeated test setup and benchmark code without changing production behavior.

  • Compression tests share browser setup and keep their own scenarios.
  • Crawl tests share setup, waiting, and cleanup.
  • Race tests share transport forwarding without moving their race triggers.
  • HTTP tests share a fetch helper that holds open event streams.
  • Both benchmark reports use the same median calculation.

No actionable issues found. This review used source inspection; tests and benchmarks were not run.

Reviews (1) · Last reviewed commit: "refactor: consolidate repeated test and ..." · Reviewed by Greptile

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T17:55:20.514683Z fe9a6b8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 47d829f7-61b5-4bdd-928e-b1d317e66d34
Commits

Reviewing files that changed from the base of the PR and between ef973fe and fe9a6b8.

Files selected for processing: 9
  • bench/data-url-bench.mjs
  • bench/reading-order-bench.mjs
  • bench/statistics.mjs
  • tests/mcp-http.test.ts
  • tests/navigation-dialogs.test.ts
  • tests/transportFixture.ts
  • tests/utils.test.ts
  • tests/vscode-host-recipient.test.ts
  • tests/webmcp-proxy.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The changes add a shared median function for two benchmarks and consolidate test helpers for HTTP requests, crawl dialogs, HTML compression, and transport forwarding.

Changes: Benchmark Median

Layer / File(s) Summary
Add and use shared median
bench/statistics.mjs, bench/data-url-bench.mjs, bench/reading-order-bench.mjs
bench/statistics.mjs exports median(samples). Both benchmarks import it instead of defining local median functions.

HTTP Test Fetch Helper

Layer / File(s) Summary
Share noStreamFetch
tests/mcp-http.test.ts
The test file adds noStreamFetch, which keeps GET requests pending until aborted and delegates other methods to fetch. Two tests now use the shared helper.

Navigation Dialog Test Helpers

Layer / File(s) Summary
Share crawl setup and checks
tests/navigation-dialogs.test.ts
The file adds prepareCrawl and checkCrawl. Three tests use them for crawl setup, completion checks, assertions, and cleanup.

HTML Compression Test Helper

Layer / File(s) Summary
Share Chromium compression setup
tests/utils.test.ts
The file adds compressHtml and uses it in seven integration tests. Their existing compression and preservation assertions remain.

Forwarding Transport Test Helper

Layer / File(s) Summary
Add and use forwardTransport
tests/transportFixture.ts, tests/vscode-host-recipient.test.ts, tests/webmcp-proxy.test.ts
The fixture adds forwardTransport. Two tests use it to observe tool responses and trigger provider switches.

Priority: Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Refactor

Possibly related PRs

Suggested reviewers: claude

Merge Risk: Minimal · up to fe9a6

No merge-blocking risk is established for the test and benchmark refactor.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "refactor: consolidate repeated test and benchmark setup" matches the main change. The PR moves repeated test and benchmark setup into shared helpers. These include median in statistics.mjs,…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Title check

Explanation

The title "refactor: consolidate repeated test and benchmark setup" matches the main change. The PR moves repeated test and benchmark setup into shared helpers. These include median in statistics.mjs, forwardTransport in transportFixture.ts, and shared crawl and HTML compression helpers. The title is concise, specific, and follows conventional commit style. Scope is limited to tests and two benchmark scripts, with no production behavior changes, which the title accurately reflects.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 9 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@JustasMonkev
JustasMonkev merged commit a4b512a into main Oct 29, 2026
14 checks passed
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