Skip to content

Commit 0f094a5

Browse files
committed
fix: guard malformed linked issues in listTestCases
1 parent be9bbb2 commit 0f094a5

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/tools/testmanagement-utils/list-testcases.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export async function listTestCases(
8787
const summary = test_cases
8888
.map((tc: any) => {
8989
const links = (tc.issues ?? [])
90+
.filter((i: any) => i?.issue_type && i?.jira_id)
9091
.map((i: any) => `${i.issue_type}:${i.jira_id}`)
9192
.join(", ");
9293
return `• ${tc.identifier}: ${tc.title} [${tc.case_type} | ${tc.priority}]${

tests/tools/list-testcases.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,30 @@ describe("listTestCases — linked issues in summary", () => {
8484
);
8585
expect(result.content?.[0]?.text).not.toContain("{linked:");
8686
});
87+
88+
it("skips malformed issue entries instead of rendering undefined", async () => {
89+
(apiClient.get as any).mockResolvedValue({
90+
data: {
91+
success: true,
92+
info: { count: 1 },
93+
test_cases: [
94+
{
95+
identifier: "TC-3",
96+
title: "Malformed link",
97+
case_type: "Functional",
98+
priority: "Medium",
99+
issues: [{}, { jira_id: "TES-9", issue_type: "linear" }],
100+
},
101+
],
102+
},
103+
});
104+
105+
const result = await listTestCases(
106+
{ project_identifier: "PR-1" },
107+
mockConfig,
108+
);
109+
110+
expect(result.content?.[0]?.text).toContain("{linked: linear:TES-9}");
111+
expect(result.content?.[0]?.text).not.toContain("undefined");
112+
});
87113
});

0 commit comments

Comments
 (0)