Skip to content

[jsweep] Clean allowed_extensions_helpers.cjs#28548

Merged
pelikhan merged 1 commit intomainfrom
jsweep/allowed-extensions-helpers-56f6fc11f1fee412
Apr 26, 2026
Merged

[jsweep] Clean allowed_extensions_helpers.cjs#28548
pelikhan merged 1 commit intomainfrom
jsweep/allowed-extensions-helpers-56f6fc11f1fee412

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Summary

Expanded test coverage for allowed_extensions_helpers.cjs, a Node.js utility (no github-script context) that normalizes file extension allow-lists in workflow configurations.

The source file was already clean and modern (@ts-check, optional chaining, functional patterns). This sweep focused on bringing test coverage up to a comprehensive level.

Changes

allowed_extensions_helpers.test.cjs

Grew from 5 → 21 test cases across all three exported functions:

Function Before After
isGitHubExpression 2 7
normalizeAllowedExtension 2 7
parseAllowedExtensionsEnv 3 7

New edge cases covered:

  • isGitHubExpression: surrounding whitespace trimming, expression with no inner spaces, empty string, plain extension, expression with trailing text
  • normalizeAllowedExtension: empty string input, already-dotted extension, GitHub expression passthrough (unchanged), mixed-case extension
  • parseAllowedExtensionsEnv: empty string returns null, single extension, expression-only input, blank values filtered from normalizedValues

Validation ✅

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: 21 passed ✓ (npx vitest run allowed_extensions_helpers)

Generated by jsweep - JavaScript Unbloater · ● 933.8K ·

  • expires on Apr 28, 2026, 5:00 AM UTC

Add 16 more test cases covering:
- isGitHubExpression: whitespace trimming, no-inner-space expr, empty/plain string, trailing text
- normalizeAllowedExtension: empty input, already-dotted ext, expression passthrough, mixed case
- parseAllowedExtensionsEnv: empty string, single ext, expression-only, blank-value filtering

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review April 26, 2026 10:01
Copilot AI review requested due to automatic review settings April 26, 2026 10:01
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

Expands unit test coverage for the allowed_extensions_helpers.cjs Node.js utility that detects GitHub Actions expressions and normalizes/parses extension allow-lists.

Changes:

  • Added additional isGitHubExpression cases (whitespace handling, no-inner-space expressions, empty/plain strings, trailing text).
  • Added additional normalizeAllowedExtension cases (empty input, already-dotted values, expression passthrough, mixed case).
  • Added additional parseAllowedExtensionsEnv cases (empty string handling, single value parsing, expression-only inputs, filtering blanks post-normalization).
Show a summary per file
File Description
actions/setup/js/allowed_extensions_helpers.test.cjs Adds comprehensive edge-case coverage across the three exported helper functions.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@github-actions github-actions Bot mentioned this pull request Apr 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

🧪 Test Quality Sentinel Report

Test Quality Score: 100/100

Excellent test quality

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

Test Classification Details

View all 14 test classifications
Test File Classification Notes
returns true for expression with surrounding whitespace allowed_extensions_helpers.test.cjs ✅ Design Edge case: whitespace tolerance
returns true for expression with no inner spaces allowed_extensions_helpers.test.cjs ✅ Design Edge case: compact expression format
returns false for plain extension allowed_extensions_helpers.test.cjs ✅ Design Boundary: non-expression input
returns false for empty string allowed_extensions_helpers.test.cjs ✅ Design Edge case: empty input
returns false for expression with trailing text allowed_extensions_helpers.test.cjs ✅ Design Boundary: partial match
returns empty string for empty input allowed_extensions_helpers.test.cjs ✅ Design Edge case: empty string
preserves existing leading dot and lowercases allowed_extensions_helpers.test.cjs ✅ Design Behavioral contract: case normalization
does not double-add dot when already present allowed_extensions_helpers.test.cjs ✅ Design Behavioral invariant: idempotent dot prefix
passes through GitHub expression unchanged allowed_extensions_helpers.test.cjs ✅ Design Behavioral contract: expression passthrough
handles mixed case extension without dot allowed_extensions_helpers.test.cjs ✅ Design Edge case: mixed case + dot insertion
returns null when env value is empty string allowed_extensions_helpers.test.cjs ✅ Design Edge case: empty env
parses single extension allowed_extensions_helpers.test.cjs ✅ Design Behavioral contract: minimal valid input
detects expression-only value allowed_extensions_helpers.test.cjs ✅ Design Behavioral contract: unresolved expression flag
filters out blank values after normalization allowed_extensions_helpers.test.cjs ✅ Design Edge case: whitespace-only entries filtered

Flagged Tests — Requires Review

None. All 14 new tests are clean.


Language Support

Tests analyzed:

  • 🟨 JavaScript (*.test.cjs): 14 tests (vitest)

Verdict

Check passed. 0% of new tests are implementation tests (threshold: 30%). All 14 new tests verify observable behavioral contracts with good edge-case coverage across three functions (isGitHubExpression, normalizeAllowedExtension, parseAllowedExtensionsEnv).


📖 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
  • Remain valid even after internal refactoring

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
  • Give false assurance: they pass even when the system is wrong

Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.

References: §24953920420

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

Copy link
Copy Markdown
Contributor Author

@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: 100/100. Test quality is excellent — 0% of new tests are implementation tests (threshold: 30%). All 14 new tests cover behavioral contracts with strong edge-case coverage.

@pelikhan pelikhan merged commit a3614da into main Apr 26, 2026
29 checks passed
@pelikhan pelikhan deleted the jsweep/allowed-extensions-helpers-56f6fc11f1fee412 branch April 26, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants