Skip to content

🧪 Improve DOT extraction robustness and add unit tests - #3

Merged
pakorn269 merged 1 commit into
mainfrom
improve-dot-extraction-testing-14586452728125148765
Mar 14, 2026
Merged

pakorn269 merged 1 commit into
mainfrom
improve-dot-extraction-testing-14586452728125148765

Conversation

@pakorn269

Copy link
Copy Markdown
Owner

🎯 What: The testing gap addressed

The extractDotBlocks and extractGraphBody functions in render-graphs.js lacked unit tests and failed on several edge cases, including Windows-style line endings (\r\n) and nameless digraphs (e.g., digraph { ... }), which are valid in Graphviz but were not handled correctly by the existing regex.

📊 Coverage: What scenarios are now tested

  • extractDotBlocks:
    • Standard Unix line endings.
    • Windows line endings after the ```dot marker.
    • Multiple DOT blocks in a single markdown file.
    • Nameless digraphs (ensuring they get a default name like graph_1).
  • extractGraphBody:
    • Standard named digraphs.
    • Nameless digraphs.
    • Correct removal of rankdir attributes.
    • Robust extraction with nested braces (e.g., subgraphs).
    • Graceful handling of malformed input (missing braces).

✨ Result: The improvement in test coverage

A new unit test suite has been added in tests/writing-skills/render-graphs.test.js. The core logic of the graph rendering script is now exported and testable, ensuring that future changes can be made with confidence. Bug fixes were implemented to handle a wider variety of valid Graphviz inputs and cross-platform markdown files.


PR created automatically by Jules for task 14586452728125148765 started by @pakorn269

…dge cases

- Modified `skills/writing-skills/render-graphs.js` to export functions and support nameless digraphs and Windows line endings.
- Created `tests/writing-skills/render-graphs.test.js` with comprehensive test cases.
- Improved robustness of `extractGraphBody` by using `indexOf`/`lastIndexOf` for brace matching.
- Verified all tests pass in the sandbox environment.

Co-authored-by: pakorn269 <[email protected]>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings March 14, 2026 01:22

Copilot AI left a comment

Copy link
Copy Markdown

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 improves the writing-skills Graphviz rendering utility to be more testable and more robust across newline formats, and adds a small unit test suite for the parsing helpers.

Changes:

  • Add a focused test file covering DOT block extraction and graph-body parsing edge cases.
  • Make DOT-fence extraction work with Windows CRLF newlines.
  • Refactor render-graphs.js to be safely require()-able (guard main() and export helper functions).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/writing-skills/render-graphs.test.js Adds unit tests for extractDotBlocks() and extractGraphBody() (including CRLF and nested-brace cases).
skills/writing-skills/render-graphs.js Improves parsing robustness, avoids running main() on import, and exports helpers for tests.

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

@pakorn269
pakorn269 merged commit 33c6a71 into main Mar 14, 2026
4 checks passed
@pakorn269
pakorn269 deleted the improve-dot-extraction-testing-14586452728125148765 branch March 14, 2026 01:58
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.

2 participants