-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add --tools filter to issues command #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { describe, it, expect, vi, beforeEach } from "vitest"; | ||
| import { formatAnalysisStatus } from "./formatting"; | ||
| import { formatAnalysisStatus, resolveToolUuids } from "./formatting"; | ||
|
|
||
| // Mock ansis to return raw text for easier testing | ||
| vi.mock("ansis", () => ({ | ||
|
|
@@ -92,3 +92,73 @@ describe("formatAnalysisStatus", () => { | |
| expect(result).toBe("Never"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("resolveToolUuids", () => { | ||
| const mockTools = [ | ||
| { uuid: "uuid-eslint", name: "ESLint", shortName: "eslint", prefix: "ESLint_" }, | ||
| { uuid: "uuid-eslint9", name: "ESLint 9", shortName: "eslint9", prefix: "ESLint9_" }, | ||
| { uuid: "uuid-semgrep", name: "Semgrep", shortName: "semgrep", prefix: "Semgrep_" }, | ||
| { uuid: "uuid-markdownlint", name: "Markdownlint", shortName: "markdownlint", prefix: "Markdownlint_" }, | ||
| { uuid: "uuid-remarklint", name: "Remarklint", shortName: "remarklint", prefix: "Remarklint_" }, | ||
| ] as any[]; | ||
|
|
||
| const fetchTools = vi.fn(async () => mockTools); | ||
|
|
||
| beforeEach(() => { | ||
| fetchTools.mockClear(); | ||
| }); | ||
|
|
||
| it("should pass UUIDs through without fetching tools", async () => { | ||
| const result = await resolveToolUuids( | ||
| ["a1b2c3d4-e5f6-7890-abcd-ef1234567890"], | ||
| fetchTools, | ||
| ); | ||
| expect(result).toEqual(["a1b2c3d4-e5f6-7890-abcd-ef1234567890"]); | ||
| expect(fetchTools).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("should resolve exact name match (case-insensitive)", async () => { | ||
| const result = await resolveToolUuids(["eslint"], fetchTools); | ||
| expect(result).toEqual(["uuid-eslint"]); | ||
| }); | ||
|
|
||
| it("should resolve exact shortName match (case-insensitive)", async () => { | ||
| const result = await resolveToolUuids(["eslint9"], fetchTools); | ||
| expect(result).toEqual(["uuid-eslint9"]); | ||
| }); | ||
|
|
||
| it("should resolve a unique substring match via name", async () => { | ||
| const result = await resolveToolUuids(["semgr"], fetchTools); | ||
| expect(result).toEqual(["uuid-semgrep"]); | ||
| }); | ||
|
|
||
| it("should error on ambiguous substring match", async () => { | ||
| await expect(resolveToolUuids(["mark"], fetchTools)).rejects.toThrow( | ||
| /ambiguous.*Markdownlint.*Remarklint/, | ||
| ); | ||
| }); | ||
|
Comment on lines
+135
to
+139
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch — fixing the spy references. |
||
|
|
||
| it("should error when tool is not found", async () => { | ||
| await expect(resolveToolUuids(["zzz"], fetchTools)).rejects.toThrow( | ||
| 'Tool "zzz" not found', | ||
| ); | ||
| }); | ||
|
|
||
| it("should deduplicate resolved UUIDs", async () => { | ||
| const result = await resolveToolUuids(["eslint", "eslint"], fetchTools); | ||
| expect(result).toEqual(["uuid-eslint"]); | ||
| }); | ||
|
|
||
| it("should handle mixed UUIDs and names, fetching tools only once", async () => { | ||
| const result = await resolveToolUuids( | ||
| ["a1b2c3d4-e5f6-7890-abcd-ef1234567890", "semgrep", "eslint"], | ||
| fetchTools, | ||
| ); | ||
| expect(result).toEqual([ | ||
| "a1b2c3d4-e5f6-7890-abcd-ef1234567890", | ||
| "uuid-semgrep", | ||
| "uuid-eslint", | ||
| ]); | ||
| expect(fetchTools).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚪ LOW RISK
Nitpick: The new test cases for the
--toolsfilter introduce significant duplication. Extracting a helper function to handle the common CLI setup and service mocking would improve maintainability and simplify the test suite.Try running the following prompt in your IDE agent:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing test suite in this file follows the same inline pattern. Introducing abstractions in tests reduces readability — keeping it as-is for consistency.