Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions actions/setup/js/submit_pr_review.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@ const mockCore = {
},
};

const mockContext = {
eventName: "pull_request",
repo: {
owner: "test-owner",
repo: "test-repo",
},
payload: {
pull_request: {
number: 123,
head: { sha: "test-sha" },
},
},
};

global.core = mockCore;
global.context = mockContext;

const { createReviewBuffer } = require("./pr_review_buffer.cjs");

Expand All @@ -24,6 +39,21 @@ describe("submit_pr_review (Handler Factory Architecture)", () => {
beforeEach(async () => {
vi.clearAllMocks();

// Reset context to default for each test
global.context = {
eventName: "pull_request",
repo: {
owner: "test-owner",
repo: "test-repo",
},
payload: {
pull_request: {
number: 123,
head: { sha: "test-sha" },
},
},
};
Comment on lines +42 to +55
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

beforeEach redefines the full global.context object literal even though mockContext is already defined above. This duplicates the default context shape/values in two places and can drift over time. Consider resetting via a single source of truth (e.g., clone mockContext each time, or use a createMockContext() helper) to keep the defaults consistent while preserving test isolation.

Copilot uses AI. Check for mistakes.

// Create a fresh buffer for each test (factory pattern, no global state)
buffer = createReviewBuffer();

Expand Down
Loading