feat(sdk): emit CASE_MISMATCH reason for non-canonical pass casing (#3184)
Cycle 10 of ~15: a captured 'result:' value that lowercases to 'pass' but isn't literally 'pass' now produces a CASE_MISMATCH reason rather than a generic NON_PASS_RESULT — so operators can distinguish a real non-pass from a likely typo.
This commit is contained in:
@@ -272,4 +272,34 @@ expected: thing
|
|||||||
await rm(localTmp, { recursive: true, force: true });
|
await rm(localTmp, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("emits CASE_MISMATCH reason when result value is \"PASS\" (uppercase variant of pass)", async () => {
|
||||||
|
const localTmp = await mkdtemp(join(tmpdir(), 'gsd-uat-c10-'));
|
||||||
|
try {
|
||||||
|
const phaseDir = join(localTmp, '.planning', 'phases', '05-case-mismatch');
|
||||||
|
await mkdir(phaseDir, { recursive: true });
|
||||||
|
const content = `---
|
||||||
|
status: complete
|
||||||
|
phase: 5
|
||||||
|
source: roadmap
|
||||||
|
started: 2026-05-18T00:00:00Z
|
||||||
|
updated: 2026-05-18T00:00:00Z
|
||||||
|
---
|
||||||
|
|
||||||
|
### 1. Uppercase pass item
|
||||||
|
expected: thing happens
|
||||||
|
result: PASS
|
||||||
|
`;
|
||||||
|
await writeFile(join(phaseDir, '05-HUMAN-UAT.md'), content);
|
||||||
|
|
||||||
|
const result = await isPhaseUatPassed(localTmp, '5');
|
||||||
|
expect(result.passed).toBe(false);
|
||||||
|
expect(result.items.length).toBe(1);
|
||||||
|
expect(result.reasons.length).toBe(1);
|
||||||
|
expect(result.reasons[0].code).toBe(REASON_CODE.CASE_MISMATCH);
|
||||||
|
expect(result.reasons[0].capturedValue).toBe('PASS');
|
||||||
|
} finally {
|
||||||
|
await rm(localTmp, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { resolvePhaseDir } from './phase-list-queries.js';
|
|||||||
|
|
||||||
export const REASON_CODE = Object.freeze({
|
export const REASON_CODE = Object.freeze({
|
||||||
NON_PASS_RESULT: 'non_pass_result',
|
NON_PASS_RESULT: 'non_pass_result',
|
||||||
|
CASE_MISMATCH: 'case_mismatch',
|
||||||
NO_PHASE_DIR: 'no_phase_dir',
|
NO_PHASE_DIR: 'no_phase_dir',
|
||||||
NO_UAT_FILES: 'no_uat_files',
|
NO_UAT_FILES: 'no_uat_files',
|
||||||
} as const);
|
} as const);
|
||||||
@@ -114,8 +115,12 @@ export async function isPhaseUatPassed(
|
|||||||
for (const item of parsed) {
|
for (const item of parsed) {
|
||||||
items.push(item);
|
items.push(item);
|
||||||
if (item.result !== 'pass') {
|
if (item.result !== 'pass') {
|
||||||
|
const code =
|
||||||
|
item.result.toLowerCase() === 'pass'
|
||||||
|
? REASON_CODE.CASE_MISMATCH
|
||||||
|
: REASON_CODE.NON_PASS_RESULT;
|
||||||
reasons.push({
|
reasons.push({
|
||||||
code: REASON_CODE.NON_PASS_RESULT,
|
code,
|
||||||
file: relFile,
|
file: relFile,
|
||||||
itemName: item.name,
|
itemName: item.name,
|
||||||
capturedValue: item.result,
|
capturedValue: item.result,
|
||||||
|
|||||||
Reference in New Issue
Block a user