Add prefix and suffix inputs to wrap comment body

Co-authored-by: marocchino <128431+marocchino@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-13 12:52:46 +00:00
parent 58d8e91c23
commit 5b837e833d
4 changed files with 87 additions and 2 deletions

View file

@ -210,4 +210,49 @@ describe("getBody", () => {
expect(await config.getBody()).toBe("")
expect(core.setFailed).toHaveBeenCalledWith("glob error")
})
test("wraps message with prefix and suffix", async () => {
const {config, core} = await loadConfig()
vi.mocked(core.getInput).mockImplementation(name => {
if (name === "message") return "hello there"
if (name === "prefix") return "```"
if (name === "suffix") return "```"
return ""
})
expect(await config.getBody()).toBe("```\nhello there\n```")
})
test("wraps file content with prefix and suffix", async () => {
const {config, core} = await loadConfig()
vi.mocked(core.getMultilineInput).mockReturnValue(["__tests__/assets/result"])
vi.mocked(core.getInput).mockImplementation(name => {
if (name === "prefix") return "```"
if (name === "suffix") return "```"
return ""
})
mockGlobCreate.mockResolvedValue({
glob: vi.fn().mockResolvedValue([resolve("__tests__/assets/result")]),
})
expect(await config.getBody()).toBe("```\nhi there\n\n```")
})
test("applies only prefix when suffix is not provided", async () => {
const {config, core} = await loadConfig()
vi.mocked(core.getInput).mockImplementation(name => {
if (name === "message") return "hello there"
if (name === "prefix") return "```"
return ""
})
expect(await config.getBody()).toBe("```\nhello there")
})
test("applies only suffix when prefix is not provided", async () => {
const {config, core} = await loadConfig()
vi.mocked(core.getInput).mockImplementation(name => {
if (name === "message") return "hello there"
if (name === "suffix") return "```"
return ""
})
expect(await config.getBody()).toBe("hello there\n```")
})
})