Skip to content

Commit 2d33279

Browse files
committed
fix(tests): add /users/me/regions/ mock to resolveOrgAndIssueId tests
The tests mocked globalThis.fetch for /organizations/ and /projects/ endpoints but not /users/me/regions/. When getUserRegions() got a 404 from the mock, ky threw an HTTPError which listOrganizations caught and fell back to the non-region path. On certain CI runner images, this error-fallback code path fails. Adding an explicit regions mock avoids the error path entirely and makes the tests deterministic.
1 parent 3a4cfaf commit 2d33279

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/commands/issue/utils.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,14 @@ describe("resolveOrgAndIssueId", () => {
311311
const req = new Request(input, init);
312312
const url = req.url;
313313

314+
// getUserRegions - return empty regions to use fallback path
315+
if (url.includes("/users/me/regions/")) {
316+
return new Response(JSON.stringify({ regions: [] }), {
317+
status: 200,
318+
headers: { "Content-Type": "application/json" },
319+
});
320+
}
321+
314322
// listOrganizations call
315323
if (
316324
url.includes("/organizations/") &&
@@ -390,6 +398,14 @@ describe("resolveOrgAndIssueId", () => {
390398
const req = new Request(input, init);
391399
const url = req.url;
392400

401+
// getUserRegions - return empty regions to use fallback path
402+
if (url.includes("/users/me/regions/")) {
403+
return new Response(JSON.stringify({ regions: [] }), {
404+
status: 200,
405+
headers: { "Content-Type": "application/json" },
406+
});
407+
}
408+
393409
// listOrganizations call
394410
if (
395411
url.includes("/organizations/") &&
@@ -450,6 +466,14 @@ describe("resolveOrgAndIssueId", () => {
450466
const req = new Request(input, init);
451467
const url = req.url;
452468

469+
// getUserRegions - return empty regions to use fallback path
470+
if (url.includes("/users/me/regions/")) {
471+
return new Response(JSON.stringify({ regions: [] }), {
472+
status: 200,
473+
headers: { "Content-Type": "application/json" },
474+
});
475+
}
476+
453477
// listOrganizations call
454478
if (
455479
url.includes("/organizations/") &&

0 commit comments

Comments
 (0)