Skip to content

[code-simplifier] refactor: add normalizeOutput/normalize helpers to consolidate normalization pipeline (#25750 follow-up)#25765

Merged
pelikhan merged 1 commit intomainfrom
code-simplifier/normalize-helpers-2026-04-11-c75de7458a7c389a
Apr 11, 2026
Merged

[code-simplifier] refactor: add normalizeOutput/normalize helpers to consolidate normalization pipeline (#25750 follow-up)#25765
pelikhan merged 1 commit intomainfrom
code-simplifier/normalize-helpers-2026-04-11-c75de7458a7c389a

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

This PR simplifies code from the last 24 hours, specifically from #25750 which added normalizeContainerPins().

Files Simplified

  • pkg/workflow/wasm_golden_test.go — extracted normalizeOutput() helper
  • scripts/test-wasm-golden.mjs — extracted normalize() helper

Improvements Made

Reduced Duplication

Both files called the two-step normalization chain in multiple places:

// Before
golden.RequireEqual(t, normalizeContainerPins(normalizeHeredocDelimiters(yamlOutput)))
// Before
const normalizedWasm = normalizeContainerPins(normalizeHeredocDelimiters(wasmYaml));
const normalizedGolden = normalizeContainerPins(normalizeHeredocDelimiters(goldenYaml));

After — composite helpers

// Go: wasm_golden_test.go
func normalizeOutput(content string) string {
    return normalizeContainerPins(normalizeHeredocDelimiters(content))
}

golden.RequireEqual(t, normalizeOutput(yamlOutput))
// JS: scripts/test-wasm-golden.mjs
function normalize(content) {
  return normalizeContainerPins(normalizeHeredocDelimiters(content));
}

const normalizedWasm = normalize(wasmYaml);
const normalizedGolden = normalize(goldenYaml);

Benefits:

  • Future normalization steps only need to be added in one place
  • The intent is clearer (normalizeOutput vs nested calls)
  • The two files mirror each other, documented with cross-references

Changes Based On

Testing

  • ✅ Tests pass: go test -run "TestWasmGolden_CompileFixtures" ./pkg/workflow/ — PASS
  • ✅ No functional changes — behavior is identical
  • go vet clean

Review Focus

Please verify:

  • Functionality is preserved (same normalization steps, same order)
  • The helpers correctly mirror each other between Go and JS

Automated by Code Simplifier Agent — analyzing code from the last 24 hours

Generated by Code Simplifier · ● 1.8M ·

  • expires on Apr 12, 2026, 6:04 AM UTC

…ization pipeline

Extract composite normalize helpers from the two-step
normalizeContainerPins(normalizeHeredocDelimiters(...)) calls introduced in #25750.

- Go: adds normalizeOutput(string) string in wasm_golden_test.go
- JS: adds normalize(content) in scripts/test-wasm-golden.mjs

Both helpers apply all normalization steps (heredoc delimiters + container
pins) in one place, making future additions easier and reducing duplication.

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

Refactors the WASM golden-test normalization pipeline by introducing small composite helpers that apply the existing normalization steps in one place, reducing duplication while preserving behavior.

Changes:

  • Add normalizeOutput() helper in Go WASM golden tests to compose heredoc + container-pin normalization.
  • Add normalize() helper in the Node.js WASM golden test script to compose the same normalization steps.
  • Update call sites to use the new helpers instead of nested normalization calls.
Show a summary per file
File Description
pkg/workflow/wasm_golden_test.go Introduces normalizeOutput() and uses it for golden comparisons to centralize normalization.
scripts/test-wasm-golden.mjs Introduces normalize() and uses it for comparing WASM output to Go-generated goldens.

Copilot's findings

Tip

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

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

@github-actions github-actions Bot mentioned this pull request Apr 11, 2026
@pelikhan pelikhan merged commit c24ba14 into main Apr 11, 2026
73 of 77 checks passed
@pelikhan pelikhan deleted the code-simplifier/normalize-helpers-2026-04-11-c75de7458a7c389a branch April 11, 2026 09:11
@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 1 (modified)
✅ Design tests (behavioral contracts) 1 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 1 (100%)
Duplicate test clusters 0
Test inflation detected No
🚨 Coding-guideline violations None

Test Classification Details

Test File Classification Issues Detected
TestWasmGolden_CompileFixtures pkg/workflow/wasm_golden_test.go:89 ✅ Design None — pure refactoring of call site

Analysis Summary

This PR is a pure refactoring — no new test functions were added. The changes consolidate repeated normalization pipelines into helper functions:

  • Go: Added normalizeOutput() in wasm_golden_test.go that composes normalizeContainerPins + normalizeHeredocDelimiters; the existing TestWasmGolden_CompileFixtures call site was simplified to use it.
  • JavaScript: Added normalize() in scripts/test-wasm-golden.mjs (parallel helper); two call sites updated.

The modified TestWasmGolden_CompileFixtures is a high-value design test — it compiles real workflow fixtures and performs golden-file comparison against expected YAML output, catching behavioral regressions in the compilation pipeline. It includes require.NoError guards and uses a table-driven subtest loop over fixture files.

No new test functions → no regressions introduced. Build tag //go:build !integration is present on the Go file. No mock libraries detected.


Language Support

Tests analyzed:

  • 🐹 Go (*_test.go): 1 test (unit — //go:build !integration)
  • 🟨 JavaScript (scripts/test-wasm-golden.mjs): Script file modified — not a vitest test file (no test()/it() blocks); helper function added only

Verdict

Check passed. 0% of modified tests are implementation tests (threshold: 30%). This is a clean refactoring with no behavioral changes to the test logic.


📖 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.

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

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 acceptable — 0% of modified tests are implementation tests (threshold: 30%). This is a pure refactoring PR that adds helper functions to consolidate the normalization pipeline; no behavioral changes to test logic.

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