Conversation
- Add OPENCLI_HEADLESS=1 env var to browser.ts: when set, MCP launches its own headless Chromium (--headless) instead of connecting to an existing Chrome via extension (--extension). Fully backward compatible. - Create tests/e2e/ with real CLI integration tests: - helpers.ts: shared runCli() subprocess wrapper - public-commands.test.ts: hackernews, bbc, github (real HTTP) - browser-public.test.ts: v2ex, bilibili, zhihu (headless browser) - management.test.ts: list, validate commands - output-formats.test.ts: json/yaml/csv/md format verification - Create tests/smoke/api-health.test.ts for scheduled API monitoring - Update CI workflow (.github/workflows/ci.yml): - build: typecheck + build (fast gate) - unit-test: vitest with 2-shard parallelism - e2e-test: real headless Chromium via playwright install - smoke-test: weekly scheduled + manual dispatch - Update vitest.config.ts to include tests/**/*.test.ts - Add headless mode unit tests in browser.test.ts
The PR targets dev instead of main, so CI was not triggered. Add dev to both push and pull_request branch filters.
github adapter does not exist in src/clis/. Replace with v2ex (public API) in public-commands and smoke tests.
…tures - public-commands.test.ts: all 4 public API commands (hackernews, v2ex×3) - browser-public.test.ts: 21 tests across 15 sites (bbc, bilibili, weibo, zhihu, reddit, twitter, xueqiu, reuters, youtube, smzdm, boss, ctrip, coupang, xiaohongshu, yahoo-finance, v2ex) - browser-auth.test.ts: 14 login-required commands graceful failure (bilibili, twitter, v2ex, xueqiu, xiaohongshu) - management.test.ts: 12 tests (list×5 formats, validate×3, verify, version, help, unknown command error) - smoke/api-health.test.ts: public API health + registry integrity check Total: ~52 E2E test cases covering all sites and management commands.
- Create TESTING.md with full testing guide:
- Test architecture (unit / E2E / smoke, 3-layer)
- Current coverage table (~52 E2E tests, 8 unit test files)
- Local run commands with explanations
- Step-by-step guide for adding tests when creating new adapters
(with code templates for public, browser-public, and auth commands)
- Decision flowchart for choosing the right test file
- CI/CD pipeline explanation with sharding details
- Headless mode documentation
- Add Testing section to README.md with ToC entry and quick-start
Sites like bilibili, zhihu, smzdm, xiaohongshu return empty arrays on US GitHub runners due to bot detection / geo-blocking. expectDataOrSkip now treats empty arrays same as null: warn + pass.
- Create src/stealth.js: patches navigator.webdriver, chrome.runtime,
permissions, and languages to reduce bot detection in headless mode.
Modeled after playwright-bot-bypass skill.
- Modify buildMcpArgs to inject --init-script stealth.js in headless mode
- Update build script (package.json) to copy stealth.js to dist/
- Update browser.test.ts to verify --init-script is included
Tested locally:
- bilibili hot: ✅ returns data with stealth (was empty without)
- zhihu hot: still empty (requires binary-level patches like
rebrowser-playwright, beyond JavaScript-level fixes)
- Stealth section: how init-script works, what it patches, site compatibility table with actual test results - Explain why zhihu/xiaohongshu still get detected (WebGL/SwiftShader binary-level fingerprinting vs JS-level patches) - Real Chrome in CI section: 4 upgrade paths from current headless to xvfb headed mode, with workflow YAML snippets - Update table of contents
Separate workflow using real Chrome (via browser-actions/setup-chrome) in headed mode with xvfb virtual display. This provides better anti-detection than headless Chromium for sites with aggressive bot detection.
BREAKING: OPENCLI_HEADLESS env var no longer exists.
buildMcpArgs now auto-detects mode:
- PLAYWRIGHT_MCP_EXTENSION_TOKEN set → --extension (local user)
- Token not set → standalone browser (CI or no extension)
Other changes:
- Delete stealth.js (unnecessary with headed Chrome)
- Remove headless e2e-test job from ci.yml
- Keep e2e-headed.yml as sole E2E CI (xvfb + real Chrome)
- Update smoke-test to use xvfb + real Chrome
- Rewrite TESTING.md to reflect simplified architecture
- Update README.md testing section
- Fix browser.test.ts: extension test sets token, standalone test
verifies no --extension/--headless flags
ByteYue
pushed a commit
that referenced
this pull request
Mar 20, 2026
P0 Critical: - #1 Fix double IIFE wrapping: unified wrapForEval() replaces normalizeEvaluateSource + ad-hoc wrap in page.evaluate() - #2 Fix navigate race: check tab.status before addListener, reduced timeout 30s→15s P1 Should Fix: - jackwener#8 Remove unused permissions (scripting, host_permissions, content_scripts) - jackwener#10 Add retry (3x, 500ms) + timeout (30s) to sendCommand() P2 Cleanup: - jackwener#3 Extract isWebUrl() to safely handle undefined tab.url - jackwener#4 Sanitize maxDepth with Math.max/min bounds - jackwener#6 Delete empty src/daemon/ directory - jackwener#7 Remove dead createJsonRpcRequest + its test - jackwener#9 Remove stale IIFE-mode comment - jackwener#11 Validate body.id in daemon request handler - jackwener#12 Guard ensureAttached: detach+re-attach on 'already attached' - jackwener#14 Extract _tabOpt() helper (removes 13x spread duplication) - jackwener#15 Add verbose warning for unsupported consoleMessages() All 35 unit tests pass.
ByteYue
pushed a commit
that referenced
this pull request
Mar 20, 2026
Bug fixes: - #1 /logs?level=error returned 404 — use pathname for route matching - #2 Duplicate initialization — added 'initialized' guard flag Should fix: - jackwener#4 Added screenshot() to IPage interface - jackwener#5 Graceful shutdown rejects pending requests before exit - jackwener#6 Use process.execPath instead of 'npx tsx' for faster daemon spawn Cleanup: - jackwener#7 Removed duplicate 'browser' keyword in package.json - jackwener#8 Removed unused normalizeEvaluateSource import from browser.ts - jackwener#9 Changed dynamic import to static import in intercept.ts - jackwener#10 Added explicit throw at end of sendCommand for clarity 61 tests pass (4 test files). Extension: 10.55KB.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add E2E testing infrastructure with real Chrome in CI
What
Establish a comprehensive E2E testing framework for opencli using real Chrome + xvfb virtual display in GitHub Actions CI.
Changes
E2E Test Suite (~52 test cases)
public-commands.test.ts— Public API commands (hackernews, v2ex)browser-public.test.ts— Browser commands for public data across all 18 sites (21 tests)browser-auth.test.ts— Graceful failure verification for login-required commands (14 tests)management.test.ts— Full coverage of management commands (list/validate/verify/version/help)output-formats.test.ts— Output format validation (json/yaml/csv/md)smoke/api-health.test.ts— Scheduled API health checksAuto-detect Browser Mode
buildMcpArgsautomatically selects mode based onPLAYWRIGHT_MCP_EXTENSION_TOKEN:--extension(local user, connects to logged-in Chrome)CI Pipeline
e2e-headed.yml— Real Chrome viabrowser-actions/setup-chrome+xvfb-runin headed modeci.yml— build + unit-test (2 shards) + smoke-test (scheduled/manual)Documentation
TESTING.md— Architecture, coverage, local setup, how to add tests, CI explanationREADME.md— Added Testing section with quick-start commands