Skip to content

fix: add missing debug mock to test files for core.debug calls in sanitize_content_core#28824

Merged
pelikhan merged 5 commits intomainfrom
copilot/fix-js-tests-shard-1-4
Apr 28, 2026
Merged

fix: add missing debug mock to test files for core.debug calls in sanitize_content_core#28824
pelikhan merged 5 commits intomainfrom
copilot/fix-js-tests-shard-1-4

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

sanitize_content_core.cjs recently gained core.debug() calls to log redacted URL details, but several test mocks only stub info/warning/error/setOutput — omitting debug. This caused TypeError: core.debug is not a function across multiple test files when URL redaction code paths were hit.

Changes

  • create_discussion_sanitization.test.cjs — Added missing debug: vi.fn() to mockCore
  • add_comment.test.cjs — Added missing debug: () => {} to mockCore
  • add_workflow_run_comment.test.cjs — Added missing debug: vi.fn() to mockCore

All three mocks now align with the full @actions/core interface that sanitize_content_core.cjs relies on.

Copilot AI changed the title [WIP] Fix failing GitHub Actions job JS Tests (shard 1/4) fix: use optional chaining for core.debug calls in sanitize_content_core Apr 28, 2026
Copilot AI requested a review from pelikhan April 28, 2026 00:26
// Extract domain for http/ftp/file/ssh/git protocols
if (domain) {
const domainLower = domain.toLowerCase();
const sanitized = sanitizeDomainName(domainLower);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot revert changes in this file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 1c0bac3 — reverted sanitize_content_core.cjs to its original state and fixed the failures by adding debug: vi.fn() / debug: () => {} to the mockCore objects in the three affected test files (add_comment.test.cjs, add_workflow_run_comment.test.cjs, create_discussion_sanitization.test.cjs).

Copilot AI and others added 2 commits April 28, 2026 00:52
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

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:

  • invalid.example.invalid
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin https://invalid.example.invalid/nonexistent-repo.git git conf�� user.name lure ode_modules/.bin/git --bare .diff.tmp odules/npm/node_-b git init�� --bare iff.tmp option-test -b main n-dir/git git (dns block)
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin https://invalid.example.invalid/nonexistent-repo.git git conf�� user.email test@example.com 64/bin/git -M .diff.tmp unning-branch git init�� --bare --initial-branch=main ache/go/1.25.8/x64/bin/git -b terations tions/setup/node-m git (dns block)

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

Copilot AI changed the title fix: use optional chaining for core.debug calls in sanitize_content_core fix: add missing debug mock to test files for core.debug calls in sanitize_content_core Apr 28, 2026
Copilot AI requested a review from pelikhan April 28, 2026 00:55
@pelikhan pelikhan marked this pull request as ready for review April 28, 2026 00:57
Copilot AI review requested due to automatic review settings April 28, 2026 00:57
@pelikhan pelikhan merged commit 0317247 into main Apr 28, 2026
24 checks passed
@pelikhan pelikhan deleted the copilot/fix-js-tests-shard-1-4 branch April 28, 2026 00:57
Copy link
Copy Markdown
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 Vitest failures caused by newly added core.debug() calls in sanitize_content_core.cjs by adding debug to several @actions/core mocks; also updates pinned ruby/setup-ruby action versions.

Changes:

  • Add debug to core mocks in multiple JS action tests to prevent TypeError: core.debug is not a function.
  • Bump ruby/setup-ruby pin from v1.305.0 to v1.306.0 (with updated SHA) in two action pin data files.
Show a summary per file
File Description
pkg/workflow/data/action_pins.json Updates the pinned ruby/setup-ruby version/SHA.
pkg/actionpins/data/action_pins.json Mirrors the pinned ruby/setup-ruby version/SHA update.
actions/setup/js/create_discussion_sanitization.test.cjs Adds debug to the core mock via vi.fn().
actions/setup/js/add_workflow_run_comment.test.cjs Adds debug to the global core mock via vi.fn().
actions/setup/js/add_comment.test.cjs Adds debug to the core mock (no-op function).

Copilot's findings

Tip

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

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment on lines +171 to 175
"ruby/setup-ruby@v1.306.0": {
"repo": "ruby/setup-ruby",
"version": "v1.305.0",
"sha": "0cb964fd540e0a24c900370abf38a33466142735"
"version": "v1.306.0",
"sha": "c4e5b1316158f92e3d49443a9d58b31d25ac0f8f"
},
Comment on lines +171 to 175
"ruby/setup-ruby@v1.306.0": {
"repo": "ruby/setup-ruby",
"version": "v1.305.0",
"sha": "0cb964fd540e0a24c900370abf38a33466142735"
"version": "v1.306.0",
"sha": "c4e5b1316158f92e3d49443a9d58b31d25ac0f8f"
},
@github-actions github-actions Bot mentioned this pull request Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: N/A (Infrastructure Fix)

No new test functions — mock setup patched

Metric Value
New/modified tests analyzed 0
✅ Design tests (behavioral contracts) 0 (N/A)
⚠️ Implementation tests (low value) 0 (N/A)
Tests with error/edge cases 0 (N/A)
Duplicate test clusters 0
Test inflation detected No
🚨 Coding-guideline violations None

Change Summary

This PR makes a 1-line fix to three JavaScript test files, adding the missing debug property to the mockCore stub objects in their beforeEach setup:

File Change
actions/setup/js/add_comment.test.cjs Added debug: () => {} to mockCore
actions/setup/js/add_workflow_run_comment.test.cjs Added debug: vi.fn() to mockCore
actions/setup/js/create_discussion_sanitization.test.cjs Added debug: vi.fn() to mockCore

No new test functions were added; the fix prevents crashes in existing behavioral tests caused by core.debug() being called without a corresponding mock stub. The existing tests themselves are behavioral (asserting on outputs, side-effects, and error paths) — this fix restores their ability to run correctly.


Language Support

Tests analyzed:

  • 🟨 JavaScript (*.test.cjs): 0 new test functions (vitest) — 3 files patched at mock setup level

Verdict

Check passed. No new test functions to evaluate; the change is a targeted infrastructure fix that correctly adds missing mock stubs required for existing tests.


📖 Understanding Test Classifications

Design Tests (High Value) verify what the system does:

  • Assert on observable outputs, return values, or state changes
  • Cover error paths and boundary conditions
  • Would catch a behavioral regression if deleted

Implementation Tests (Low Value) verify how the system does it:

  • Assert on internal function calls (mocking internals)
  • Only test the happy path with typical inputs
  • Break during legitimate refactoring even when behavior is correct

References:

🧪 Test quality analysis by Test Quality Sentinel · ● 795.3K ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

✅ Test Quality Sentinel: N/A. No new test functions — this PR is a targeted infrastructure fix adding missing debug mock stubs to 3 test files. Existing behavioral tests are unaffected in quality. Check passed.

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.

3 participants