Skip to content

Commit e5c1617

Browse files
committed
test(microsoft-foundry): cover UTF-16-safe connection errors
1 parent 21503e3 commit e5c1617

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

extensions/microsoft-foundry/onboard.connection.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,40 @@ describe("testFoundryConnection", () => {
7070
"Connection Test",
7171
);
7272
});
73+
74+
it.each([
75+
{
76+
status: 400,
77+
expectedPrefix:
78+
"Endpoint is reachable but returned 400 Bad Request - check your deployment name and API version.\n",
79+
expectedSuffix: "",
80+
},
81+
{
82+
status: 503,
83+
expectedPrefix: "Warning: test request returned 503. ",
84+
expectedSuffix: "\nProceeding anyway - you can fix the endpoint later.",
85+
},
86+
])(
87+
"keeps $status error-body previews UTF-16 safe",
88+
async ({ status, expectedPrefix, expectedSuffix }) => {
89+
const note = vi.fn();
90+
const prefix = "x".repeat(199);
91+
hoisted.fetchWithSsrFGuard.mockResolvedValue({
92+
response: new Response(`${prefix}😀tail`, { status }),
93+
release: async () => {},
94+
});
95+
96+
await testFoundryConnection({
97+
ctx: { prompter: { note } } as never,
98+
endpoint: "https://example.openai.azure.com",
99+
modelId: "gpt-4o",
100+
api: DEFAULT_API,
101+
});
102+
103+
expect(note).toHaveBeenCalledExactlyOnceWith(
104+
`${expectedPrefix}${prefix}${expectedSuffix}`,
105+
"Connection Test",
106+
);
107+
},
108+
);
73109
});

0 commit comments

Comments
 (0)