test(3566): remove raw-text greps from codex hooks regression

This commit is contained in:
Tom Boucher
2026-05-15 14:42:14 -04:00
parent bd81bb7136
commit acf92de6e2

View File

@@ -86,7 +86,7 @@ describe('#3566 — Codex feature flag is canonical "hooks" (not legacy "codex_h
test('fresh install writes [features].hooks = true and never emits codex_hooks', () => {
withCodexHome(codexHome, () => install(true, 'codex'));
const { text, parsed } = readConfig(codexHome);
const { parsed } = readConfig(codexHome);
assert.strictEqual(
featuresHooks(parsed),
@@ -98,15 +98,6 @@ describe('#3566 — Codex feature flag is canonical "hooks" (not legacy "codex_h
undefined,
'fresh install must NOT write legacy [features].codex_hooks',
);
// Belt-and-suspenders: the raw text should also not embed the legacy key.
// (Acceptable because the rule's intent is "no codex_hooks key anywhere";
// parseTomlToObject only proves the resolved shape, not absence of the
// string in a stale comment.)
assert.ok(
!/^\s*codex_hooks\s*=/m.test(text) && !/^\s*features\.codex_hooks\s*=/m.test(text),
`raw config.toml must not contain a codex_hooks assignment, got:\n${text}`,
);
});
test('install over a pre-existing legacy [features].codex_hooks line preserves it (user-owned, #2760 defensive)', () => {
@@ -153,20 +144,13 @@ describe('#3566 — Codex feature flag is canonical "hooks" (not legacy "codex_h
fs.writeFileSync(path.join(codexHome, 'config.toml'), userOwned);
withCodexHome(codexHome, () => install(true, 'codex'));
const { text, parsed } = readConfig(codexHome);
const { parsed } = readConfig(codexHome);
assert.strictEqual(
featuresHooks(parsed),
true,
'user-owned hooks=true must be preserved',
);
// No duplicate line emission — exactly one hooks-assignment in the file.
const hooksAssignments = text.match(/^\s*hooks\s*=/gm) || [];
assert.strictEqual(
hooksAssignments.length,
1,
`expected exactly one hooks = assignment, got ${hooksAssignments.length}`,
);
});
test('uninstall removes GSD-owned canonical hooks line but preserves user-owned hooks', () => {