Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/issue-triage-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { buildMaintainerHandoffBrief } from "./issue-handoff-brief.ts";
export function parseIssueBody(body: string | null): ParsedIssueBody {
const sections: Record<string, string> = {};
const rawBody = body ?? "";
const headingMatches = [...rawBody.matchAll(/^###\s+(.+)$/gm)];
const headingMatches = [...rawBody.matchAll(/^#{2,3}\s+(.+)$/gm)];

for (let index = 0; index < headingMatches.length; index += 1) {
const current = headingMatches[index];
Expand Down
67 changes: 67 additions & 0 deletions .github/scripts/issue-triage-lib_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import type { GitHubIssue } from "./github.ts";
import { analyzeIssue, parseIssueBody } from "./issue-triage-lib.ts";

function assertEquals(actual: unknown, expected: unknown) {
const actualJson = JSON.stringify(actual);
const expectedJson = JSON.stringify(expected);

if (actualJson !== expectedJson) {
throw new Error(`Expected ${expectedJson}, received ${actualJson}`);
}
}

function featureIssue(body: string): GitHubIssue {
return {
number: 1,
title: "[Feature] Improve issue triage",
body,
state: "open",
labels: [{ name: "enhancement" }],
comments: 0,
created_at: "2026-10-01T00:00:00Z",
updated_at: "2026-10-01T00:00:00Z",
user: { login: "contributor" },
html_url: "https://github.com/iflytek/skillhub/issues/1",
};
}

Deno.test("level-2 headings satisfy required feature sections", () => {
const result = analyzeIssue(
featureIssue(`## Problem
Filled issues are marked as incomplete.

## Proposed solution
Recognize level-2 headings during triage.`),
[],
new Date("2026-10-01T00:00:00Z"),
);

assertEquals(result.missingFields, []);
assertEquals(result.route === "needs-info", false);
});

Deno.test("level-3 Issue Form headings keep their existing behavior", () => {
const parsed = parseIssueBody(`### Problem
Filled issues are marked as incomplete.

### Proposed Solution
Recognize headings generated by Issue Forms.`);

assertEquals(parsed.sections, {
problem: "Filled issues are marked as incomplete.",
"proposed solution": "Recognize headings generated by Issue Forms.",
});
});

Deno.test("mixed level-2 and level-3 headings are parsed together", () => {
const parsed = parseIssueBody(`## Problem
Filled issues are marked as incomplete.

### Proposed Solution
Recognize both supported heading levels.`);

assertEquals(parsed.sections, {
problem: "Filled issues are marked as incomplete.",
"proposed solution": "Recognize both supported heading levels.",
});
});
Loading