Skip to content

Heretto integration support#408

Merged
hawkeyexl merged 8 commits into
mainfrom
heretto
Dec 17, 2025
Merged

Heretto integration support#408
hawkeyexl merged 8 commits into
mainfrom
heretto

Conversation

@hawkeyexl
Copy link
Copy Markdown
Contributor

@hawkeyexl hawkeyexl commented Dec 17, 2025

Improve Heretto API workflows by adding configuration options and handling variable loading. Update dependencies and ensure proper cleanup of temporary directories by checking for directories before removal. Add example configuration for Heretto integration.

Summary by CodeRabbit

  • Chores

    • Updated multiple dependencies including browser automation tools and related libraries for improved compatibility and performance.
  • Bug Fixes

    • Enhanced temporary file cleanup to correctly handle both file and directory removal, preventing cleanup errors.

✏️ Tip: You can customize this high-level summary in your review settings.

- Check each entry with fs.statSync to determine if it's a directory
- Remove directories with fs.rmSync(..., { recursive: true, force: true }) instead of calling fs.unlinkSync
- Prevent errors when nested folders are present in the temp folder
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 17, 2025

Walkthrough

This pull request updates the development configuration to integrate a new Heretto API service alongside existing integrations, refactors the test runner setup to use explicit runTests invocation with in-file JSON configuration, updates multiple dependencies to newer versions, and fixes directory cleanup logic in the utility function to differentiate between files and directories.

Changes

Cohort / File(s) Summary
Development Configuration
dev/index.js
Added dotenv environment variable loading; changed input from single string to array format; restructured runOn from compact object array to normalized format with explicit browser entries; introduced heretto integration configuration with organizationId, username, and apiToken sourced from environment variables; made result assignment explicit with const declaration
Dependency Updates
package.json
Updated @puppeteer/browsers, appium, appium-chromium-driver, appium-geckodriver, appium-safari-driver, and posthog-node to newer patch/minor versions; pinned doc-detective-common and doc-detective-resolver to specific dev versions by removing caret prefix
Utility Function
src/utils.js
Modified cleanTemp function to differentiate between files and directories—now uses fs.rmSync for recursive directory deletion and fs.unlinkSync for files, preventing errors from attempting to unlink directories

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Configuration changes in dev/index.js require verification that new input/runOn shapes are compatible with downstream code
  • Ensure environment variables (HERETTO_ORGANIZATION_ID, HERETTO_USERNAME, HERETTO_API_TOKEN) are properly documented and available in test environments
  • Verify cleanTemp function behavior with mixed file/directory scenarios to confirm no edge cases are missed

Possibly related PRs

Poem

🐰 A heretto helper hops into view,
With env vars and shapes all refreshed anew,
The temp paths now tidy, files sorted with care,
Dependencies dancing to versions so fair!
Tech stacks aligned in this springtime affair! 🌱

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Heretto integration support' is concise and directly reflects the main change—adding Heretto integration with configuration and environment variable support.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch heretto

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d428bb and 5c283df.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • dev/index.js (1 hunks)
  • package.json (1 hunks)
  • src/utils.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.js

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.js: Use log(config, level, message) for all logging, where level = "debug"|"info"|"warning"|"error"
Use getAvailableApps() to detect installed browsers instead of hardcoding browser paths

Files:

  • src/utils.js
🧠 Learnings (11)
📚 Learning: 2025-12-03T00:21:10.834Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T00:21:10.834Z
Learning: Applies to test/**/*.js : Use `fs.writeFileSync()` + `fs.unlinkSync()` in try/finally blocks for temporary test files to ensure cleanup

Applied to files:

  • src/utils.js
  • dev/index.js
📚 Learning: 2025-12-03T00:21:10.834Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T00:21:10.834Z
Learning: Applies to src/config.js : Browsers and drivers must match the current platform (detected via `puppeteer/browsers`) with Appium drivers installed for chromium, gecko, and safari

Applied to files:

  • package.json
📚 Learning: 2025-12-03T00:21:10.834Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T00:21:10.834Z
Learning: Applies to src/index.js : `src/index.js` must export `runTests()` as the main entry point for the package

Applied to files:

  • dev/index.js
📚 Learning: 2025-12-03T00:21:10.834Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T00:21:10.834Z
Learning: `src/tests.js` is the core orchestrator handling 600+ LOC of Appium/WebDriver management

Applied to files:

  • dev/index.js
📚 Learning: 2025-12-03T00:21:10.834Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T00:21:10.834Z
Learning: Applies to src/tests.js : Add new driver-based step actions to the `driverActions` array in `src/tests.js` and implement case in `runStep()` switch statement

Applied to files:

  • dev/index.js
📚 Learning: 2025-12-03T00:21:10.834Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T00:21:10.834Z
Learning: Applies to src/tests/*.js : Set step variables via `step.variables = { MY_VAR: "$$response.body.token" }` to store data as environment variables

Applied to files:

  • dev/index.js
📚 Learning: 2025-12-03T00:21:10.834Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T00:21:10.834Z
Learning: Applies to src/tests.js : `runSpecs()` in `src/tests.js` orchestrates test execution flow: spec → test → context → step hierarchy

Applied to files:

  • dev/index.js
📚 Learning: 2025-12-03T00:21:10.834Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T00:21:10.834Z
Learning: Tests follow nested hierarchy: spec (file) → test → context (browser/platform combo) → step (action), with contexts running serially and steps skipping after first failure

Applied to files:

  • dev/index.js
📚 Learning: 2025-12-03T00:21:10.834Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T00:21:10.834Z
Learning: Applies to test/**/*.js : HTTP request tests must run against test server on port 8092 in `test/server/`

Applied to files:

  • dev/index.js
📚 Learning: 2025-12-03T00:21:10.834Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T00:21:10.834Z
Learning: Applies to src/tests/*.js : Step handlers must return object with `{ status: "PASS"|"FAIL"|"WARNING", description: string, outputs: {} }`

Applied to files:

  • dev/index.js
📚 Learning: 2025-12-03T00:21:10.834Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T00:21:10.834Z
Learning: Applies to src/tests/httpRequest.js : Extract request/response examples from OpenAPI spec and use AJV for schema validation in HTTP request handling

Applied to files:

  • dev/index.js
🧬 Code graph analysis (1)
src/utils.js (5)
src/tests/runShell.js (1)
  • fs (7-7)
src/tests/saveScreenshot.js (1)
  • fs (5-5)
src/tests/httpRequest.js (1)
  • fs (3-3)
src/config.js (1)
  • fs (6-6)
src/tests/startRecording.js (1)
  • fs (4-4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: test (windows-latest, 24)
  • GitHub Check: test (ubuntu-latest, 24)
  • GitHub Check: test (macos-latest, 24)
  • GitHub Check: test (windows-latest, 22)
  • GitHub Check: test (ubuntu-latest, 20)
  • GitHub Check: test (macos-latest, 20)
  • GitHub Check: test (windows-latest, 20)
  • GitHub Check: test (ubuntu-latest, 22)
  • GitHub Check: test (macos-latest, 22)
🔇 Additional comments (5)
src/utils.js (1)

36-41: LGTM! Proper directory cleanup.

The enhanced logic correctly differentiates between files and directories, using fs.rmSync with recursive removal for directories and fs.unlinkSync for files. This ensures the temp directory cleanup handles both types properly.

dev/index.js (3)

2-3: LGTM! Proper environment setup.

Adding dotenv configuration enables loading environment variables from a .env file, which is appropriate for development/example scripts.


10-22: LGTM! Improved configuration structure.

The explicit object structure with browsers array is clearer and more maintainable than the previous compact format.


27-34: LGTM! Good credential management.

The Heretto integration properly uses environment variables for sensitive credentials, and the inline comments clearly document what each field requires.

package.json (1)

32-47: Run npm audit to verify dependency security before merging.

Appium 3.1.2 is the latest version published recently, and Appium 3 was designed to be leaner and rely on newer versions of software with better security characteristics. However, verify the complete dependency tree for known vulnerabilities by running npm audit in your environment. Check especially for transitive dependencies that may introduce risk, as appium and its driver packages have extensive dependency chains.


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 and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Heretto integration support to Doc Detective by introducing configuration options and example usage. The changes improve temporary file cleanup to handle both files and directories, update various dependencies to newer versions, and provide a working example of Heretto API integration with environment variable configuration.

  • Enhanced temporary directory cleanup to recursively remove directories in addition to files
  • Updated multiple browser automation and testing dependencies to newer versions
  • Added Heretto integration example configuration with environment variable loading

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/utils.js Enhanced cleanTemp() function to check if paths are directories and recursively remove them, fixing cleanup errors when temp directory contains subdirectories
package.json Updated dependencies including @puppeteer/browsers, appium drivers, and posthog-node; changed doc-detective-common and doc-detective-resolver to dev versions
dev/index.js Added Heretto integration example configuration with environment variable loading from dev/.env file, demonstrating how to configure organization ID, username, and API token

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils.js
Comment on lines +36 to +40
const stat = fs.statSync(curPath);
if (stat.isDirectory()) {
fs.rmSync(curPath, { recursive: true, force: true });
} else {
fs.unlinkSync(curPath);
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

The code now checks if a path is a directory before attempting removal, but there's no error handling for cases where fs.statSync might fail (e.g., if the file is deleted between readdirSync and statSync, or if there are permission issues). Consider wrapping the stat check and removal operations in a try-catch block to handle potential errors gracefully.

Suggested change
const stat = fs.statSync(curPath);
if (stat.isDirectory()) {
fs.rmSync(curPath, { recursive: true, force: true });
} else {
fs.unlinkSync(curPath);
try {
const stat = fs.statSync(curPath);
if (stat.isDirectory()) {
fs.rmSync(curPath, { recursive: true, force: true });
} else {
fs.unlinkSync(curPath);
}
} catch (err) {
// Ignore errors during cleanup (e.g., missing files, permission issues)

Copilot uses AI. Check for mistakes.
Comment thread package.json
Comment thread dev/index.js
@hawkeyexl hawkeyexl merged commit f0ae775 into main Dec 17, 2025
22 checks passed
@hawkeyexl hawkeyexl deleted the heretto branch December 17, 2025 16:20
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.

3 participants