Skip to content

refactor: extract DOM parsing logic into dedicated service - #75

Merged
kubrickcode merged 1 commit into
mainfrom
develop/shlee/55
Nov 29, 2025
Merged

refactor: extract DOM parsing logic into dedicated service#75
kubrickcode merged 1 commit into
mainfrom
develop/shlee/55

Conversation

@kubrickcode

Copy link
Copy Markdown
Owner
  • Separated DOM parsing logic from content.ts into dedicated service
  • Moved extractIssueNumbers() and parseRepositoryInfo() to dom-parser.service
  • Validated various GitHub page structures and edge cases with 39 test cases
  • Removed issue-parser.ts and consolidated functionality into new service

fix #55

@vercel

vercel Bot commented Nov 29, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
github-project-status-viewer Ready Ready Preview Comment Nov 29, 2025 5:42am
github-project-status-viewer-p4ii Ready Ready Preview Comment Nov 29, 2025 5:42am

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @kubrickcode, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the codebase by extracting all DOM parsing logic into a new dom-parser.service. This change significantly improves the separation of concerns, making the content.ts file primarily responsible for orchestration rather than direct DOM manipulation. The new service is thoroughly tested with 39 new unit tests, ensuring robustness and maintainability, and the removal of the issue-parser.ts file further consolidates related functionality.

Highlights

  • DOM Parsing Extraction: The logic for extracting issue numbers and parsing repository information has been moved from content.ts and issue-parser.ts into a new, dedicated service: dom-parser.service.ts.
  • Enhanced Test Coverage: A comprehensive suite of 39 new test cases has been added for the dom-parser.service, validating its functionality across various GitHub page structures and edge cases.
  • Codebase Simplification: The issue-parser.ts file has been removed, and content.ts has been streamlined by delegating DOM parsing responsibilities to the new service, improving separation of concerns.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the refactor Refactoring code label Nov 29, 2025
@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request is a great refactoring that extracts DOM parsing logic into a dedicated service, improving code organization and testability. The new dom-parser.service is well-tested with a comprehensive suite of unit tests. I have one suggestion for the new service to better align with the repository's style guide regarding immutability and avoiding magic strings.

Comment thread extension/src/services/dom-parser.service.ts Outdated
@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request effectively refactors the DOM parsing logic into a dedicated dom-parser.service. The new service is well-structured and comes with a comprehensive suite of 39 test cases, which is excellent. The separation of concerns improves the maintainability of the content script.

My review includes two main points:

  1. A suggestion to improve the implementation of extractIssueNumbers by using optional chaining, in line with the repository's style guide.
  2. A concern about removing all meaningful tests for content.ts and replacing them with a placeholder test. While some logic is now in the new service, content.ts still contains important logic that would benefit from unit testing.

Overall, this is a solid refactoring that improves the codebase. Addressing the testing concern for content.ts would make it even better.

Comment on lines +6 to 8
it("should be tested through E2E tests", () => {
expect(true).toBe(true);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This test always passes and provides no value, giving a false sense of security that content.ts is tested. The style guide states that unit tests should be prioritized.1

While content.ts interacts with the DOM and browser APIs, making it hard to test, it contains non-trivial logic (e.g., debouncing, observation, polling for SPA navigation) that could be unit-tested with mocks. Please consider either adding meaningful tests that cover some of this logic or removing this spec file entirely to avoid confusion.

Style Guide References

Footnotes

  1. The style guide indicates that unit tests should be prioritized over integration or E2E tests.

Comment thread extension/src/services/dom-parser.service.ts
- Separated DOM parsing logic from content.ts into dedicated service
- Moved extractIssueNumbers() and parseRepositoryInfo() to dom-parser.service
- Validated various GitHub page structures and edge cases with 39 test cases
- Removed issue-parser.ts and consolidated functionality into new service

fix #55
@kubrickcode

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 2.0.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactoring code released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract DOM parser utilities

1 participant