Skip to content

Commit 8406f88

Browse files
Feat: Enhance listTestCases utility to handle error responses and update tests
1 parent 204e996 commit 8406f88

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,21 @@ export async function listTestCases(
7575
},
7676
});
7777

78-
const { test_cases, info } = resp.data;
78+
const resp_data = resp.data;
79+
if (!resp_data.success) {
80+
return {
81+
content: [
82+
{
83+
type: "text",
84+
text: `Failed to list test cases: ${JSON.stringify(resp_data)}`,
85+
isError: true,
86+
},
87+
],
88+
isError: true,
89+
};
90+
}
91+
92+
const { test_cases, info } = resp_data;
7993
const count = info?.count ?? test_cases.length;
8094

8195
// Summary for more focused output

tests/tools/testmanagement.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ describe('listTestCases util', () => {
173173
];
174174

175175
it('should return formatted summary and raw JSON on success', async () => {
176-
mockedAxios.get.mockResolvedValue({ data: { test_cases: mockCases, info: { count: 2 } } });
176+
mockedAxios.get.mockResolvedValue({ data: { success: true, test_cases: mockCases, info: { count: 2 } } });
177177

178178
const args = { project_identifier: 'PR-1', status: 'active', p: 1 };
179179
const result = await listTestCases(args as any);

0 commit comments

Comments
 (0)