From f564286dd62d2171c011c4a8dba6a81894ede558 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 04:51:05 +0000 Subject: [PATCH 1/3] Initial plan From 56a89323c1da1ab20ca3a01d8ccd48c7a4ebd746 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 04:59:14 +0000 Subject: [PATCH 2/3] Fix handle_noop_message test failures by creating temp files for agent output Instead of mocking loadAgentOutput with vi.mock(), create temporary files with actual agent output JSON data that the real loadAgentOutput function can read. This approach: 1. Tests the full integration flow (real file I/O + parsing) 2. Works with dynamic imports that bypass module mocks 3. Matches the pattern used in load_agent_output.test.cjs 4. Properly cleans up temp files in afterEach Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/handle_noop_message.test.cjs | 84 +++++++++++-------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/actions/setup/js/handle_noop_message.test.cjs b/actions/setup/js/handle_noop_message.test.cjs index b67598265b0..7e315243563 100644 --- a/actions/setup/js/handle_noop_message.test.cjs +++ b/actions/setup/js/handle_noop_message.test.cjs @@ -1,26 +1,23 @@ // @ts-check import { describe, it, expect, beforeEach, afterEach, vi } from "vitest"; - -// Mock load_agent_output at the module level -vi.mock("./load_agent_output.cjs", () => ({ - loadAgentOutput: vi.fn(), -})); +import fs from "fs"; +import path from "path"; +import os from "os"; describe("handle_noop_message", () => { let mockCore; let mockGithub; let mockContext; let originalEnv; - let mockLoadAgentOutput; + let tempDir; beforeEach(async () => { // Save original environment originalEnv = { ...process.env }; - // Get the mocked loadAgentOutput - const loadModule = await import("./load_agent_output.cjs"); - mockLoadAgentOutput = loadModule.loadAgentOutput; + // Create temp directory for test files + tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "handle-noop-test-")); // Mock core mockCore = { @@ -59,6 +56,12 @@ describe("handle_noop_message", () => { afterEach(() => { // Restore environment process.env = originalEnv; + + // Clean up temp directory + if (tempDir && fs.existsSync(tempDir)) { + fs.rmSync(tempDir, { recursive: true, force: true }); + } + vi.clearAllMocks(); }); @@ -94,14 +97,15 @@ describe("handle_noop_message", () => { process.env.GH_AW_NOOP_MESSAGE = "Some message"; process.env.GH_AW_AGENT_CONCLUSION = "success"; - // Mock loadAgentOutput to return noop + other outputs - mockLoadAgentOutput.mockReturnValue({ - success: true, + // Create agent output file with noop + other outputs + const outputFile = path.join(tempDir, "agent_output.json"); + fs.writeFileSync(outputFile, JSON.stringify({ items: [ { type: "noop", message: "No action needed" }, { type: "create_issue", title: "Some issue" }, ], - }); + })); + process.env.GH_AW_AGENT_OUTPUT = outputFile; const { main } = await import("./handle_noop_message.cjs?t=" + Date.now()); await main(); @@ -116,11 +120,12 @@ describe("handle_noop_message", () => { process.env.GH_AW_NOOP_MESSAGE = "No updates needed"; process.env.GH_AW_AGENT_CONCLUSION = "success"; - // Mock loadAgentOutput to return only noop outputs - mockLoadAgentOutput.mockReturnValue({ - success: true, + // Create agent output file with only noop outputs + const outputFile = path.join(tempDir, "agent_output.json"); + fs.writeFileSync(outputFile, JSON.stringify({ items: [{ type: "noop", message: "No updates needed" }], - }); + })); + process.env.GH_AW_AGENT_OUTPUT = outputFile; // Mock search to return no results mockGithub.rest.search.issuesAndPullRequests.mockResolvedValue({ @@ -176,11 +181,12 @@ describe("handle_noop_message", () => { process.env.GH_AW_NOOP_MESSAGE = "Everything is up to date"; process.env.GH_AW_AGENT_CONCLUSION = "success"; - // Mock loadAgentOutput to return only noop outputs - mockLoadAgentOutput.mockReturnValue({ - success: true, + // Create agent output file with only noop outputs + const outputFile = path.join(tempDir, "agent_output.json"); + fs.writeFileSync(outputFile, JSON.stringify({ items: [{ type: "noop", message: "Everything is up to date" }], - }); + })); + process.env.GH_AW_AGENT_OUTPUT = outputFile; // Mock search to return existing issue mockGithub.rest.search.issuesAndPullRequests.mockResolvedValue({ @@ -223,11 +229,12 @@ describe("handle_noop_message", () => { process.env.GH_AW_NOOP_MESSAGE = "No action required"; process.env.GH_AW_AGENT_CONCLUSION = "success"; - // Mock loadAgentOutput to return only noop outputs - mockLoadAgentOutput.mockReturnValue({ - success: true, + // Create agent output file with only noop outputs + const outputFile = path.join(tempDir, "agent_output.json"); + fs.writeFileSync(outputFile, JSON.stringify({ items: [{ type: "noop", message: "No action required" }], - }); + })); + process.env.GH_AW_AGENT_OUTPUT = outputFile; // Mock existing issue mockGithub.rest.search.issuesAndPullRequests.mockResolvedValue({ @@ -253,11 +260,12 @@ describe("handle_noop_message", () => { process.env.GH_AW_NOOP_MESSAGE = "All checks passed"; process.env.GH_AW_AGENT_CONCLUSION = "success"; - // Mock loadAgentOutput to return only noop outputs - mockLoadAgentOutput.mockReturnValue({ - success: true, + // Create agent output file with only noop outputs + const outputFile = path.join(tempDir, "agent_output.json"); + fs.writeFileSync(outputFile, JSON.stringify({ items: [{ type: "noop", message: "All checks passed" }], - }); + })); + process.env.GH_AW_AGENT_OUTPUT = outputFile; // Mock no existing issue mockGithub.rest.search.issuesAndPullRequests.mockResolvedValue({ @@ -280,11 +288,12 @@ describe("handle_noop_message", () => { process.env.GH_AW_NOOP_MESSAGE = "Done"; process.env.GH_AW_AGENT_CONCLUSION = "success"; - // Mock loadAgentOutput to return only noop outputs - mockLoadAgentOutput.mockReturnValue({ - success: true, + // Create agent output file with only noop outputs + const outputFile = path.join(tempDir, "agent_output.json"); + fs.writeFileSync(outputFile, JSON.stringify({ items: [{ type: "noop", message: "Done" }], - }); + })); + process.env.GH_AW_AGENT_OUTPUT = outputFile; mockGithub.rest.search.issuesAndPullRequests.mockResolvedValue({ data: { total_count: 1, items: [{ number: 1, node_id: "ID", html_url: "url" }] }, @@ -305,11 +314,12 @@ describe("handle_noop_message", () => { process.env.GH_AW_NOOP_MESSAGE = "Clean"; process.env.GH_AW_AGENT_CONCLUSION = "success"; - // Mock loadAgentOutput to return only noop outputs - mockLoadAgentOutput.mockReturnValue({ - success: true, + // Create agent output file with only noop outputs + const outputFile = path.join(tempDir, "agent_output.json"); + fs.writeFileSync(outputFile, JSON.stringify({ items: [{ type: "noop", message: "Clean" }], - }); + })); + process.env.GH_AW_AGENT_OUTPUT = outputFile; mockGithub.rest.search.issuesAndPullRequests.mockResolvedValue({ data: { total_count: 1, items: [{ number: 1, node_id: "ID", html_url: "url" }] }, From 2d2ba5cf34fc92311eb096883719952370ea068b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 05:05:37 +0000 Subject: [PATCH 3/3] Apply prettier formatting to handle_noop_message.test.cjs - Remove trailing whitespace - Format multiline JSON.stringify calls for better readability Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/handle_noop_message.test.cjs | 73 ++++++++++++------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/actions/setup/js/handle_noop_message.test.cjs b/actions/setup/js/handle_noop_message.test.cjs index 7e315243563..f8a4d24a685 100644 --- a/actions/setup/js/handle_noop_message.test.cjs +++ b/actions/setup/js/handle_noop_message.test.cjs @@ -56,12 +56,12 @@ describe("handle_noop_message", () => { afterEach(() => { // Restore environment process.env = originalEnv; - + // Clean up temp directory if (tempDir && fs.existsSync(tempDir)) { fs.rmSync(tempDir, { recursive: true, force: true }); } - + vi.clearAllMocks(); }); @@ -99,12 +99,15 @@ describe("handle_noop_message", () => { // Create agent output file with noop + other outputs const outputFile = path.join(tempDir, "agent_output.json"); - fs.writeFileSync(outputFile, JSON.stringify({ - items: [ - { type: "noop", message: "No action needed" }, - { type: "create_issue", title: "Some issue" }, - ], - })); + fs.writeFileSync( + outputFile, + JSON.stringify({ + items: [ + { type: "noop", message: "No action needed" }, + { type: "create_issue", title: "Some issue" }, + ], + }) + ); process.env.GH_AW_AGENT_OUTPUT = outputFile; const { main } = await import("./handle_noop_message.cjs?t=" + Date.now()); @@ -122,9 +125,12 @@ describe("handle_noop_message", () => { // Create agent output file with only noop outputs const outputFile = path.join(tempDir, "agent_output.json"); - fs.writeFileSync(outputFile, JSON.stringify({ - items: [{ type: "noop", message: "No updates needed" }], - })); + fs.writeFileSync( + outputFile, + JSON.stringify({ + items: [{ type: "noop", message: "No updates needed" }], + }) + ); process.env.GH_AW_AGENT_OUTPUT = outputFile; // Mock search to return no results @@ -183,9 +189,12 @@ describe("handle_noop_message", () => { // Create agent output file with only noop outputs const outputFile = path.join(tempDir, "agent_output.json"); - fs.writeFileSync(outputFile, JSON.stringify({ - items: [{ type: "noop", message: "Everything is up to date" }], - })); + fs.writeFileSync( + outputFile, + JSON.stringify({ + items: [{ type: "noop", message: "Everything is up to date" }], + }) + ); process.env.GH_AW_AGENT_OUTPUT = outputFile; // Mock search to return existing issue @@ -231,9 +240,12 @@ describe("handle_noop_message", () => { // Create agent output file with only noop outputs const outputFile = path.join(tempDir, "agent_output.json"); - fs.writeFileSync(outputFile, JSON.stringify({ - items: [{ type: "noop", message: "No action required" }], - })); + fs.writeFileSync( + outputFile, + JSON.stringify({ + items: [{ type: "noop", message: "No action required" }], + }) + ); process.env.GH_AW_AGENT_OUTPUT = outputFile; // Mock existing issue @@ -262,9 +274,12 @@ describe("handle_noop_message", () => { // Create agent output file with only noop outputs const outputFile = path.join(tempDir, "agent_output.json"); - fs.writeFileSync(outputFile, JSON.stringify({ - items: [{ type: "noop", message: "All checks passed" }], - })); + fs.writeFileSync( + outputFile, + JSON.stringify({ + items: [{ type: "noop", message: "All checks passed" }], + }) + ); process.env.GH_AW_AGENT_OUTPUT = outputFile; // Mock no existing issue @@ -290,9 +305,12 @@ describe("handle_noop_message", () => { // Create agent output file with only noop outputs const outputFile = path.join(tempDir, "agent_output.json"); - fs.writeFileSync(outputFile, JSON.stringify({ - items: [{ type: "noop", message: "Done" }], - })); + fs.writeFileSync( + outputFile, + JSON.stringify({ + items: [{ type: "noop", message: "Done" }], + }) + ); process.env.GH_AW_AGENT_OUTPUT = outputFile; mockGithub.rest.search.issuesAndPullRequests.mockResolvedValue({ @@ -316,9 +334,12 @@ describe("handle_noop_message", () => { // Create agent output file with only noop outputs const outputFile = path.join(tempDir, "agent_output.json"); - fs.writeFileSync(outputFile, JSON.stringify({ - items: [{ type: "noop", message: "Clean" }], - })); + fs.writeFileSync( + outputFile, + JSON.stringify({ + items: [{ type: "noop", message: "Clean" }], + }) + ); process.env.GH_AW_AGENT_OUTPUT = outputFile; mockGithub.rest.search.issuesAndPullRequests.mockResolvedValue({