fix(#3309): applyRepairs risk-gating test used a fake, non-writable cwd
CI caught what the bench run didn't: "row 12" (every NONE-risk action
must actually apply) called applyRepairs('/fake/cwd', ...) — a literal
path that doesn't exist on disk. This was fine when applyRepairs's
handlers were stubs (pre-migration skeleton), but real handlers now
read/write actual files: createConfig writes config.json,
addNyquistKey/addAiIntegrationPhaseKey read it before patching. Against
a genuinely non-existent path these now correctly fail (ENOENT), and
an earlier fix in this same PR (applied only receives a code on real
success) correctly surfaces that as a failure instead of masking it —
so 3 of 4 codes stopped landing in `applied`, deterministically, on
any environment that actually enforces ENOENT against /fake/cwd.
Uses a real temp project (createTempProject + a valid config.json)
instead. Row 11 (DESTRUCTIVE refusal) and the ADVISE-skip test are
unaffected — both paths return before any handler touches the
filesystem, confirmed by reading applyRepairs's dispatch order.
This commit is contained in:
@@ -166,14 +166,26 @@ describe('applyRepairs — risk gating (hand-constructed diagnostics)', () => {
|
||||
assert.deepEqual(result.refused.sort(), ['E004', 'E005']);
|
||||
});
|
||||
|
||||
test('row 12: every other real action (NONE risk) is applied, not refused, when --repair is requested', () => {
|
||||
test('row 12: every other real action (NONE risk) is applied, not refused, when --repair is requested', (t) => {
|
||||
// Unlike the other tests in this block, these four codes now dispatch to
|
||||
// REAL handlers (runRepairAction, src/health-diagnostic.cts) that perform
|
||||
// real filesystem I/O — createConfig writes config.json, addNyquistKey /
|
||||
// addAiIntegrationPhaseKey read-then-patch it (throwing if absent). A
|
||||
// literal '/fake/cwd' makes every one of those genuinely fail (ENOENT),
|
||||
// which applyRepairs correctly reports as NOT applied. A real temp
|
||||
// project with a real, valid config.json already in place is required so
|
||||
// the read-then-patch handlers have something to read.
|
||||
const tmpDir = createTempProject();
|
||||
t.after(() => cleanup(tmpDir));
|
||||
writeValidConfigJson(tmpDir);
|
||||
|
||||
const diagnostics = [
|
||||
fakeDiagnostic('W003', REMEDY_ACTION.CREATE_CONFIG, REMEDY_RISK.NONE),
|
||||
fakeDiagnostic('W008', REMEDY_ACTION.ADD_NYQUIST_KEY, REMEDY_RISK.NONE),
|
||||
fakeDiagnostic('W016', REMEDY_ACTION.ADD_AI_INTEGRATION_PHASE_KEY, REMEDY_RISK.NONE),
|
||||
fakeDiagnostic('W018', REMEDY_ACTION.BACKFILL_MILESTONES, REMEDY_RISK.NONE),
|
||||
];
|
||||
const result = applyRepairs('/fake/cwd', diagnostics, true, false);
|
||||
const result = applyRepairs(tmpDir, diagnostics, true, false);
|
||||
assert.deepEqual(result.applied.sort(), ['W003', 'W008', 'W016', 'W018']);
|
||||
assert.deepEqual(result.refused, []);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user