test(summary-helpers): add regression tests for extractSliceExecutionExcerpt
Verifies the function handles null/undefined content gracefully and correctly extracts goal, demo, verification, and observability sections from slice plan content. Addresses sf-mozutl5d-ei3ec6 by ensuring the function is importable and behaves correctly end-to-end.
This commit is contained in:
parent
924383b6f7
commit
37ebfcf53a
1 changed files with 72 additions and 0 deletions
72
src/resources/extensions/sf/tests/summary-helpers.test.mjs
Normal file
72
src/resources/extensions/sf/tests/summary-helpers.test.mjs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { test } from "vitest";
|
||||
import {
|
||||
extractSliceExecutionExcerpt,
|
||||
} from "../summary-helpers.js";
|
||||
|
||||
test("extractSliceExecutionExcerpt when content is null returns fallback", () => {
|
||||
const result = extractSliceExecutionExcerpt(null, "S01/PLAN.md");
|
||||
assert.ok(result.includes("## Slice Plan Excerpt"));
|
||||
assert.ok(result.includes("Slice plan not found"));
|
||||
assert.ok(result.includes("S01/PLAN.md"));
|
||||
});
|
||||
|
||||
test("extractSliceExecutionExcerpt when content is undefined returns fallback", () => {
|
||||
const result = extractSliceExecutionExcerpt(undefined, "S02/PLAN.md");
|
||||
assert.ok(result.includes("## Slice Plan Excerpt"));
|
||||
assert.ok(result.includes("Slice plan not found"));
|
||||
assert.ok(result.includes("S02/PLAN.md"));
|
||||
});
|
||||
|
||||
test("extractSliceExecutionExcerpt extracts goal and demo lines", () => {
|
||||
const content = [
|
||||
"# Slice Plan",
|
||||
"",
|
||||
"**Goal:** This slice delivers X",
|
||||
"",
|
||||
"**Demo:** After this, you can Y",
|
||||
"",
|
||||
"## Verification",
|
||||
"Run npm test",
|
||||
].join("\n");
|
||||
|
||||
const result = extractSliceExecutionExcerpt(content, "S01/PLAN.md");
|
||||
assert.ok(result.includes("**Goal:** This slice delivers X"));
|
||||
assert.ok(result.includes("**Demo:** After this, you can Y"));
|
||||
assert.ok(result.includes("Source: `S01/PLAN.md`"));
|
||||
});
|
||||
|
||||
test("extractSliceExecutionExcerpt extracts verification section", () => {
|
||||
const content = [
|
||||
"# Slice Plan",
|
||||
"",
|
||||
"**Goal:** Test goal",
|
||||
"",
|
||||
"## Verification",
|
||||
"Run the integration suite",
|
||||
"Check exit code is 0",
|
||||
"",
|
||||
"## Observability / Diagnostics",
|
||||
"Metrics at /metrics",
|
||||
].join("\n");
|
||||
|
||||
const result = extractSliceExecutionExcerpt(content, "S01/PLAN.md");
|
||||
assert.ok(result.includes("### Slice Verification"));
|
||||
assert.ok(result.includes("Run the integration suite"));
|
||||
assert.ok(result.includes("Check exit code is 0"));
|
||||
assert.ok(result.includes("### Slice Observability / Diagnostics"));
|
||||
assert.ok(result.includes("Metrics at /metrics"));
|
||||
});
|
||||
|
||||
test("extractSliceExecutionExcerpt omits missing sections gracefully", () => {
|
||||
const content = [
|
||||
"# Slice Plan",
|
||||
"",
|
||||
"**Goal:** Minimal slice",
|
||||
].join("\n");
|
||||
|
||||
const result = extractSliceExecutionExcerpt(content, "S01/PLAN.md");
|
||||
assert.ok(result.includes("**Goal:** Minimal slice"));
|
||||
assert.ok(!result.includes("### Slice Verification"));
|
||||
assert.ok(!result.includes("### Slice Observability"));
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue