Skip to content

Comments

Fix missing global.context setup in submit_pr_review.test.cjs#16633

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-github-actions-workflow-ab9ee377-38d2-4d55-83cc-3319e3ff0fe5
Feb 18, 2026
Merged

Fix missing global.context setup in submit_pr_review.test.cjs#16633
pelikhan merged 3 commits intomainfrom
copilot/fix-github-actions-workflow-ab9ee377-38d2-4d55-83cc-3319e3ff0fe5

Conversation

Copy link
Contributor

Copilot AI commented Feb 18, 2026

11 tests in submit_pr_review.test.cjs failed with ReferenceError: context is not defined at line 94 of submit_pr_review.cjs. The handler accesses context.repo, context.payload, and context.eventName when resolving PR targets, but the test environment lacked the global.

Changes

  • Added mockContext with eventName, repo, and payload.pull_request properties
  • Set global.context = mockContext before module import
  • Reset global.context in beforeEach() for test isolation

Follows the pattern established in add_reviewer.test.cjs, add_reaction.test.cjs, and other handler factory tests that access the GitHub Actions runtime context.

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;  // Required for resolveTarget() calls

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/github/gh-aw/contents/.github%2Fworkflows%2Faudit-workflows.md
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/dist/workers/forks.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Fix the failing GitHub Actions workflow js
Analyze the workflow logs, identify the root cause of the failure, and implement a fix.
Job ID: 64054037849
Job URL: https://github.com/github/gh-aw/actions/runs/22154355113/job/64054037849


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions workflow js Fix missing global.context setup in submit_pr_review.test.cjs Feb 18, 2026
@pelikhan pelikhan marked this pull request as ready for review February 18, 2026 19:51
Copilot AI review requested due to automatic review settings February 18, 2026 19:51
@pelikhan pelikhan merged commit 874bdd8 into main Feb 18, 2026
@pelikhan pelikhan deleted the copilot/fix-github-actions-workflow-ab9ee377-38d2-4d55-83cc-3319e3ff0fe5 branch February 18, 2026 19:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes failing submit_pr_review.test.cjs tests by ensuring the GitHub Actions context global is available during handler creation/execution.

Changes:

  • Added a mockContext object matching the properties used by submit_pr_review.cjs (eventName, repo, payload.pull_request).
  • Set global.context before requiring modules that depend on context.
  • Reset global.context in beforeEach() to keep tests isolated.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +42 to +55
// 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" },
},
},
};
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants