-
Notifications
You must be signed in to change notification settings - Fork 424
[jsweep] Clean update_pr_description_helpers.cjs #40584
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
Changes from all commits
7772a4a
dc0ceb2
47b5ac7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,18 @@ describe("update_pr_description_helpers.cjs", () => { | |
| const footer = buildAIFooter("Test & Workflow", "https://github.com/owner/repo/actions/runs/123"); | ||
| expect(footer).toContain("Test & Workflow"); | ||
| }); | ||
|
|
||
| it("should include historyUrl in footer when provided", () => { | ||
| const historyUrl = "https://github.com/search?q=repo%3Aowner%2Frepo"; | ||
| const footer = buildAIFooter("Test Workflow", "https://github.com/owner/repo/actions/runs/123", historyUrl); | ||
| expect(footer).toContain(historyUrl); | ||
| }); | ||
|
|
||
| it("should return a non-empty footer string", () => { | ||
|
Contributor
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. Redundant test: this 💡 DetailsEvery other The Consider replacing this with a more targeted assertion — for example verifying the footer contains the |
||
| const footer = buildAIFooter("Test Workflow", "https://github.com/owner/repo/actions/runs/123"); | ||
| expect(typeof footer).toBe("string"); | ||
|
Contributor
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. [/tdd] The 💡 Consider a behavioural assertion insteadA more valuable spec would verify something the other tests don't cover, for example that a footer produced with no optional args still contains the mandatory attribution marker. The current check reads as a type-level sanity probe rather than a specification. |
||
| expect(footer.length).toBeGreaterThan(0); | ||
| }); | ||
| }); | ||
|
|
||
| describe("buildIslandStartMarker", () => { | ||
|
|
@@ -96,6 +108,34 @@ describe("update_pr_description_helpers.cjs", () => { | |
| expect(result2.found).toBe(true); | ||
| expect(result1.startIndex).toBeLessThan(result2.startIndex); | ||
| }); | ||
|
|
||
| it("should return exact startIndex=0 and endIndex=body.length when island spans entire body", () => { | ||
| const startMarker = buildIslandStartMarker("wf"); | ||
| const endMarker = buildIslandEndMarker("wf"); | ||
| const body = `${startMarker}inner${endMarker}`; | ||
| const result = findIsland(body, "wf"); | ||
| expect(result.found).toBe(true); | ||
| expect(result.startIndex).toBe(0); | ||
| expect(result.endIndex).toBe(body.length); | ||
| }); | ||
|
|
||
| it("should not find island in empty body", () => { | ||
| const result = findIsland("", "test-workflow"); | ||
| expect(result.found).toBe(false); | ||
| expect(result.startIndex).toBe(-1); | ||
| expect(result.endIndex).toBe(-1); | ||
| }); | ||
|
|
||
| it("should find island with prefix content and return correct startIndex", () => { | ||
| const prefix = "prefix content\n"; | ||
| const startMarker = buildIslandStartMarker("wf"); | ||
| const endMarker = buildIslandEndMarker("wf"); | ||
| const body = `${prefix}${startMarker}inner${endMarker}`; | ||
| const result = findIsland(body, "wf"); | ||
| expect(result.found).toBe(true); | ||
| expect(result.startIndex).toBe(prefix.length); | ||
| expect(result.endIndex).toBe(body.length); | ||
| }); | ||
| }); | ||
|
|
||
| describe("updateBody - replace operation", () => { | ||
|
|
||
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.
[/tdd] The
detectionCautiontruthy branch —${detectionCaution}\n\n${sanitizedNewContent}— has no test coverage. The PR adds tests forfindIslandandbuildAIFooter, but the code path that was actually changed (updateBody's caution injection) is never exercised with a non-emptydetectionCaution.💡 Suggested test scaffold
To cover this branch you would need to mock
assembleMarkdownBodyPartsto return a non-emptydetectionCaution, then assert the output starts with the caution block followed by the sanitized content:Without this test the template-literal on this line is validated only by visual inspection.