test(#1973): consolidate 48 workflow regression tests into workflow-aspect suites
Fold 48 issue-named workflow-markdown regression files into the canonical test that owns each workflow aspect (execute-phase-*, plan-phase-*, quick-*, discuss-*, worktree-cleanup, secure-phase, verify, update, settings, etc.), across 32 existing suites. Verbatim block-scoped describe wrappers; 281 subtests conserved 1:1. No new test files. Host-env pre-check: only gsd-settings-advanced spawns CLI and it sets no GSD_WORKSTREAM/GSD_PROJECT value — no leak risk. Regenerates regression-name allowlist (222->181), ratchets file-count allowlist (verify 11->10), makes 30 relocated allow-test-rule exemptions issue-ref-compliant (ADR-456; prunes 30 stale ids). lint:ci green. Part of epic #1969. Closes #1973. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -514,3 +514,135 @@ describe('reapply-patches pristine baseline detection (#2424)', () => {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
// Folded from tests/bug-3516-reapply-patches-gsd-update-filter.test.cjs — consolidation epic #1969 (B4 #1973)
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
{
|
||||
const { describe: __foldDescribe } = require('node:test');
|
||||
__foldDescribe("folded:bug-3516-reapply-patches-gsd-update-filter (consolidation epic #1969 B4 #1973)", () => {
|
||||
// allow-test-rule: source-text-is-the-product (see #3516)
|
||||
// gsd-core/workflows/reapply-patches.md is the installed runtime workflow —
|
||||
// its text IS the deployed behavioral contract for the --reapply flag.
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Bug #3516: reapply-patches.md git-enhanced two-way merge filter misses
|
||||
* commits authored by the renamed `/gsd-update` flow.
|
||||
*
|
||||
* The `grep -v` alternation on line 231 only included the legacy `gsd:update`
|
||||
* marker. After the slash-command rename `/gsd:update` → `/gsd-update`, commits
|
||||
* authored by the current flow fall through the filter and are misclassified as
|
||||
* user customizations, prompting spurious merge conflicts during `--reapply`.
|
||||
*
|
||||
* Fix: add `gsd-update` arm to the alternation so both the legacy and current
|
||||
* commit-message prefixes are excluded. `GSD update` and `gsd-install`
|
||||
* exclusions are preserved.
|
||||
*
|
||||
* Per the repo's source-text-is-the-product exception: the workflow file's text
|
||||
* IS the deployed behavioral contract. Structural assertion against the parsed
|
||||
* shell command string is the correct test form here.
|
||||
*/
|
||||
|
||||
const { describe, test, before } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const WORKFLOW_PATH = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'gsd-core',
|
||||
'workflows',
|
||||
'reapply-patches.md',
|
||||
);
|
||||
|
||||
/**
|
||||
* Extract the git log filter command from the workflow.
|
||||
*
|
||||
* Looks for the `grep -v "..."` shell snippet inside the Git-enhanced two-way
|
||||
* merge section and returns the alternation string between the quotes.
|
||||
* Returns null if the snippet is absent (signals a structural regression).
|
||||
*/
|
||||
function extractFilterAlternation(content) {
|
||||
// Match the grep -v "..." line in the bash block
|
||||
const match = content.match(/grep\s+-v\s+"([^"]+)"/);
|
||||
if (!match) return null;
|
||||
return match[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the alternation string (pipe-delimited) into individual arms.
|
||||
* Handles escaped pipes produced by shell regex syntax (`\|`).
|
||||
*/
|
||||
function parseAlternationArms(alternation) {
|
||||
// Shell grep alternation uses \| (escaped pipe); split on that
|
||||
return alternation.split(/\\\|/).map((arm) => arm.trim());
|
||||
}
|
||||
|
||||
describe('Bug #3516: git-enhanced two-way merge filter includes gsd-update arm', () => {
|
||||
let content;
|
||||
let alternation;
|
||||
let arms;
|
||||
|
||||
before(() => {
|
||||
content = fs.readFileSync(WORKFLOW_PATH, 'utf8');
|
||||
alternation = extractFilterAlternation(content);
|
||||
arms = alternation ? parseAlternationArms(alternation) : [];
|
||||
});
|
||||
|
||||
test('workflow file exists', () => {
|
||||
assert.ok(
|
||||
fs.existsSync(WORKFLOW_PATH),
|
||||
'gsd-core/workflows/reapply-patches.md must exist',
|
||||
);
|
||||
});
|
||||
|
||||
test('git-enhanced two-way merge section contains a grep -v filter', () => {
|
||||
assert.ok(
|
||||
alternation !== null,
|
||||
'reapply-patches.md must contain a `grep -v "..."` filter in the git-enhanced two-way merge section',
|
||||
);
|
||||
});
|
||||
|
||||
test('filter excludes legacy gsd:update commits (back-compat)', () => {
|
||||
assert.ok(
|
||||
arms.some((arm) => arm === 'gsd:update'),
|
||||
`filter must include 'gsd:update' arm for back-compat; got arms: ${JSON.stringify(arms)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('filter excludes renamed gsd-update commits (primary fix)', () => {
|
||||
assert.ok(
|
||||
arms.some((arm) => arm === 'gsd-update'),
|
||||
`filter must include 'gsd-update' arm (renamed flow); got arms: ${JSON.stringify(arms)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('filter excludes GSD update commits (no regression)', () => {
|
||||
assert.ok(
|
||||
arms.some((arm) => arm === 'GSD update'),
|
||||
`filter must include 'GSD update' arm; got arms: ${JSON.stringify(arms)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('filter excludes gsd-install commits (no regression)', () => {
|
||||
assert.ok(
|
||||
arms.some((arm) => arm === 'gsd-install'),
|
||||
`filter must include 'gsd-install' arm; got arms: ${JSON.stringify(arms)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('all four expected exclusion patterns are present in the filter', () => {
|
||||
const required = ['gsd:update', 'gsd-update', 'GSD update', 'gsd-install'];
|
||||
const missing = required.filter((p) => !arms.some((arm) => arm === p));
|
||||
assert.deepEqual(
|
||||
missing,
|
||||
[],
|
||||
`filter is missing required exclusion patterns: ${JSON.stringify(missing)}; got arms: ${JSON.stringify(arms)}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user