Files
msd-core/tests/ship-note.test.cjs
Tom Boucher a875372f18 test(#3335): fold the workflow-content & phase-lifecycle fix-* cluster — Wave 3 (#3373)
* test(#3335): fold the workflow-content & phase-lifecycle fix-* cluster — Wave 3

Folds 13 legacy fix-*.test.cjs regression files (131 test() blocks) into
their module's main suite, per H3 (#3315) of the test-hygiene epic (#3053):

- 6 files with no prior target coverage: renamed (git mv) into new suites
  (spike-manifest-scoping, ship-note, add-todo, workflow-jq-dependency,
  resolve-execution-dynamic-routing, clock)
- 7 files merged into 5 pre-existing suites (worktree-base-ref x2,
  model-resolver, phase-locator x2, frontmatter, verification-status),
  deduplicated against existing coverage

Zero net test-coverage loss: every source assertion preserved or verified
as a genuine pre-existing duplicate. No production code changed.

Last fix-* wave (Wave 1 #3341, Wave 2 #3342 already merged); 4 issue-*
waves remain in #3315.

* test(#3335): fix orthogonal-review findings — Wave 3 fold

Standards-axis review + Memtrace graph pass found real defects in the
just-folded suites, all fixed here:

- phase-locator.test.cjs: pinned an unseeded fast-check property test
  (CONTRIBUTING.md determinism requirement), matching the sibling test's
  seed:7 convention.
- phase-locator.test.cjs: added assert.ok() presence guards after 9
  data.plans.find() calls that were dereferenced unguarded, inconsistent
  with 5 sibling tests in the same file that already guard correctly.
  Latent robustness gap — an omitted plan would throw an opaque TypeError
  instead of a clear assertion failure.
- Standardized the fold-wrapper convention (block-scoped __foldDescribe)
  across worktree-base-ref.test.cjs, verification-status.test.cjs, and
  phase-locator.test.cjs to match the pattern already established in
  frontmatter.test.cjs and model-resolver.test.cjs from earlier folds.
- worktree-base-ref.test.cjs: moved a mid-file require to the top-of-file
  require block.
- Eliminated duplicated env-isolation helpers: model-resolver.test.cjs and
  phase-locator.test.cjs each reimplemented GSD_WORKSTREAM/GSD_PROJECT
  save-restore independently; factored a shared isolateWorkstreamEnv()/
  restoreWorkstreamEnv() into tests/helpers.cjs and pointed both call
  sites at it.

No test() count changed in any file. No production code touched.

---------

Co-authored-by: sim <sim@local>
2026-08-11 22:23:55 -04:00

71 lines
2.8 KiB
JavaScript

'use strict';
/**
* #2138 — track_shipping ship-note must be pushed onto the PR branch.
*
* ship.md's track_shipping step committed the STATE ship-note (Phase N shipped —
* PR #N) AFTER create_pr and never pushed it. The commit stayed local-only, so
* when the GitHub PR merged (especially fast/auto-merge) the ship-note was not in
* the source branch and never reached the default branch — STATE's ship-status
* was silently lost.
*
* The fix pushes the ship-note commit onto the PR branch with a `[ci skip]`
* trailer (honored by GitHub) so it lands on merge without triggering a redundant
* pipeline. This test is a source-text regression guard: ship.md IS the product
* the runtime loads, so asserting its track_shipping step pushes (with [ci skip])
* guards the deployed contract.
*/
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const SHIP_MD = path.join(__dirname, '..', 'gsd-core', 'workflows', 'ship.md');
function extractStep(name) {
const content = fs.readFileSync(SHIP_MD, 'utf8');
const open = `<step name="${name}">`;
const start = content.indexOf(open);
assert.notEqual(start, -1, `ship.md must contain a ${name} step`);
const end = content.indexOf('</step>', start);
assert.notEqual(end, -1, `${name} step must close`);
return content.slice(start, end);
}
describe('#2138 ship.md track_shipping pushes the ship-note onto the PR branch', () => {
const step = extractStep('track_shipping');
test('track_shipping pushes the committed ship-note (not local-only)', () => {
// The bug was that the ship-note commit was never pushed. The fix adds a
// `git push origin ${CURRENT_BRANCH}` inside track_shipping.
assert.ok(
/git push origin \$\{CURRENT_BRANCH\}/.test(step),
'track_shipping must push the ship-note commit onto the PR branch so it survives merge (#2138)',
);
});
test('the ship-note commit carries a [ci skip] trailer to avoid a redundant pipeline', () => {
// GitHub honors `[ci skip]` / `[skip ci]`; the trailer suppresses the second
// pipeline the post-create_pr push would otherwise trigger.
assert.ok(
/\[ci skip\]|\[skip ci\]/.test(step),
'track_shipping ship-note commit must include a [ci skip] trailer',
);
});
test('the ship-note step handles wedged PRs caused by skip-token or required status checks', () => {
assert.ok(
/mergeStateStatus|BLOCKED|trigger CI/.test(step),
'track_shipping must include self-healing or check handling for wedged PRs (#2783)',
);
});
test('the ship-note commit still records the phase + PR number in STATE', () => {
assert.ok(
/ship phase \$\{PHASE_NUMBER\}.*PR #\$\{PR_NUMBER\}/.test(step),
'track_shipping must still commit the phase + PR-number ship-note into STATE',
);
});
});