[PR #1738] [MERGED] Consolidate Chrome test helpers across all plugin tests #1488

Closed
opened 2026-03-01 14:50:00 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ArchiveBox/ArchiveBox/pull/1738
Author: @pirate
Created: 12/31/2025
Status: Merged
Merged: 12/31/2025
Merged by: @pirate

Base: devHead: claude/reduce-chrome-duplication-JgWVr


📝 Commits (6)

  • 65c8390 Consolidate Chrome test helpers across all plugin tests
  • ef92a99 Refactor test_chrome.py to use shared helpers
  • 7d74dd9 Add Chrome CDP integration tests for singlefile
  • d72ab7c Add simpler Chrome test helpers and update test files
  • adeffb4 Add JS-Python path delegation to reduce Chrome-related duplication
  • 1cfb77a Rename Python helpers to match JS function names in snake_case

📊 Changes

15 files changed (+978 additions, -701 deletions)

View changed files

📝 archivebox/plugins/chrome/chrome_utils.js (+128 -13)
📝 archivebox/plugins/chrome/tests/chrome_test_helpers.py (+637 -55)
📝 archivebox/plugins/chrome/tests/test_chrome.py (+14 -59)
📝 archivebox/plugins/dom/tests/test_dom.py (+14 -21)
📝 archivebox/plugins/favicon/tests/test_favicon.py (+8 -3)
📝 archivebox/plugins/istilldontcareaboutcookies/tests/test_istilldontcareaboutcookies.py (+8 -149)
📝 archivebox/plugins/mercury/tests/test_mercury.py (+9 -4)
📝 archivebox/plugins/pdf/tests/test_pdf.py (+13 -20)
📝 archivebox/plugins/readability/tests/test_readability.py (+8 -4)
📝 archivebox/plugins/screenshot/tests/test_screenshot.py (+12 -20)
📝 archivebox/plugins/singlefile/on_Snapshot__50_singlefile.py (+3 -21)
📝 archivebox/plugins/singlefile/tests/test_singlefile.py (+97 -4)
📝 archivebox/plugins/title/tests/test_title.py (+8 -3)
📝 archivebox/plugins/twocaptcha/tests/test_twocaptcha.py (+11 -170)
📝 archivebox/plugins/ublock/tests/test_ublock.py (+8 -155)

📄 Description

Summary

Related issues

Changes these areas

  • Bugfixes
  • Feature behavior
  • Command line interface
  • Configuration options
  • Internal architecture
  • Snapshot data layout on disk

Summary by cubic

Consolidated Chrome test helpers and centralized path/Chrome logic to chrome_utils.js, removing duplicated code across plugin tests and adding reliable helpers for launching and cleaning up Chrome. Tests are simpler, more consistent, and add SingleFile CDP coverage.

  • New Features

    • chrome_utils.js exposes getMachineType, getLibDir, getNodeModulesDir, getExtensionsDir, getTestEnv, killChrome CLI commands.
    • New Python helpers in chrome_test_helpers.py delegate to JS with Python fallbacks: get_machine_type, get_lib_dir, get_node_modules_dir, get_extensions_dir, find_chromium, kill_chrome, get_test_env.
    • Test utilities: get_plugin_dir, get_hook_script, run_hook, parse_jsonl_output, run_hook_and_parse, chromium_session context manager, setup_test_env, launch_chromium_session, kill_chromium_session, plus lazy LIB_DIR and NODE_MODULES_DIR.
    • SingleFile tests now verify CDP connection to an existing Chrome session and disabled behavior.
  • Refactors

    • Updated all plugin tests (ublock, twocaptcha, istilldontcareaboutcookies, screenshot, dom, pdf, singlefile, favicon, readability, mercury, title) to use shared helpers.
    • Large removal of duplicated setup/teardown, path, and Chrome code across tests.
    • singlefile hook no longer hardcodes Chrome binary search; relies on CHROME_BINARY and centralized findChromium.
    • All Chrome cleanup paths use killChrome from JS for consistent process handling.

Written for commit 1cfb77a355. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ArchiveBox/ArchiveBox/pull/1738 **Author:** [@pirate](https://github.com/pirate) **Created:** 12/31/2025 **Status:** ✅ Merged **Merged:** 12/31/2025 **Merged by:** [@pirate](https://github.com/pirate) **Base:** `dev` ← **Head:** `claude/reduce-chrome-duplication-JgWVr` --- ### 📝 Commits (6) - [`65c8390`](https://github.com/ArchiveBox/ArchiveBox/commit/65c839032a488d27125500bfe527ce76d814c65b) Consolidate Chrome test helpers across all plugin tests - [`ef92a99`](https://github.com/ArchiveBox/ArchiveBox/commit/ef92a99c4ac854fac29a228119ecfd176ddd1860) Refactor test_chrome.py to use shared helpers - [`7d74dd9`](https://github.com/ArchiveBox/ArchiveBox/commit/7d74dd906c04aae58969fab0717c3c3eb66db051) Add Chrome CDP integration tests for singlefile - [`d72ab7c`](https://github.com/ArchiveBox/ArchiveBox/commit/d72ab7c397283f8bc04e01a3a29936ae915a763b) Add simpler Chrome test helpers and update test files - [`adeffb4`](https://github.com/ArchiveBox/ArchiveBox/commit/adeffb4bc5061a46da220d6544f8af4af43ca669) Add JS-Python path delegation to reduce Chrome-related duplication - [`1cfb77a`](https://github.com/ArchiveBox/ArchiveBox/commit/1cfb77a35598994b4898060a2177f63f40c85d7f) Rename Python helpers to match JS function names in snake_case ### 📊 Changes **15 files changed** (+978 additions, -701 deletions) <details> <summary>View changed files</summary> 📝 `archivebox/plugins/chrome/chrome_utils.js` (+128 -13) 📝 `archivebox/plugins/chrome/tests/chrome_test_helpers.py` (+637 -55) 📝 `archivebox/plugins/chrome/tests/test_chrome.py` (+14 -59) 📝 `archivebox/plugins/dom/tests/test_dom.py` (+14 -21) 📝 `archivebox/plugins/favicon/tests/test_favicon.py` (+8 -3) 📝 `archivebox/plugins/istilldontcareaboutcookies/tests/test_istilldontcareaboutcookies.py` (+8 -149) 📝 `archivebox/plugins/mercury/tests/test_mercury.py` (+9 -4) 📝 `archivebox/plugins/pdf/tests/test_pdf.py` (+13 -20) 📝 `archivebox/plugins/readability/tests/test_readability.py` (+8 -4) 📝 `archivebox/plugins/screenshot/tests/test_screenshot.py` (+12 -20) 📝 `archivebox/plugins/singlefile/on_Snapshot__50_singlefile.py` (+3 -21) 📝 `archivebox/plugins/singlefile/tests/test_singlefile.py` (+97 -4) 📝 `archivebox/plugins/title/tests/test_title.py` (+8 -3) 📝 `archivebox/plugins/twocaptcha/tests/test_twocaptcha.py` (+11 -170) 📝 `archivebox/plugins/ublock/tests/test_ublock.py` (+8 -155) </details> ### 📄 Description <!-- IMPORTANT: Do not submit PRs with only formatting / PEP8 / line length changes. --> # Summary <!--e.g. This PR fixes ABC or adds the ability to do XYZ...--> # Related issues <!-- e.g. #123 or Roadmap goal # https://github.com/pirate/ArchiveBox/wiki/Roadmap --> # Changes these areas - [ ] Bugfixes - [ ] Feature behavior - [ ] Command line interface - [ ] Configuration options - [ ] Internal architecture - [ ] Snapshot data layout on disk <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Consolidated Chrome test helpers and centralized path/Chrome logic to chrome_utils.js, removing duplicated code across plugin tests and adding reliable helpers for launching and cleaning up Chrome. Tests are simpler, more consistent, and add SingleFile CDP coverage. - **New Features** - chrome_utils.js exposes getMachineType, getLibDir, getNodeModulesDir, getExtensionsDir, getTestEnv, killChrome CLI commands. - New Python helpers in chrome_test_helpers.py delegate to JS with Python fallbacks: get_machine_type, get_lib_dir, get_node_modules_dir, get_extensions_dir, find_chromium, kill_chrome, get_test_env. - Test utilities: get_plugin_dir, get_hook_script, run_hook, parse_jsonl_output, run_hook_and_parse, chromium_session context manager, setup_test_env, launch_chromium_session, kill_chromium_session, plus lazy LIB_DIR and NODE_MODULES_DIR. - SingleFile tests now verify CDP connection to an existing Chrome session and disabled behavior. - **Refactors** - Updated all plugin tests (ublock, twocaptcha, istilldontcareaboutcookies, screenshot, dom, pdf, singlefile, favicon, readability, mercury, title) to use shared helpers. - Large removal of duplicated setup/teardown, path, and Chrome code across tests. - singlefile hook no longer hardcodes Chrome binary search; relies on CHROME_BINARY and centralized findChromium. - All Chrome cleanup paths use killChrome from JS for consistent process handling. <sup>Written for commit 1cfb77a35598994b4898060a2177f63f40c85d7f. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-01 14:50:00 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ArchiveBox#1488
No description provided.