Skip to content

Commit c3975df

Browse files
committed
test: the Insight workspace path is retired, not an alias
Atlassian has removed /rest/servicedeskapi/insight/workspace from Cloud. It answers 403 with an HTML error page while /assets/workspace answers 200, so the assertion that the two paths behave identically has been failing on master since the removal. What is left worth testing is the deprecation itself, and one thing the pair used to hide: the retired path is the only live endpoint that refuses with a body that is not JSON, which makes it the only proof that such a response still arrives as a typed ForbiddenError carrying its status rather than failing inside the response parser.
1 parent e5d5fe7 commit c3975df

1 file changed

Lines changed: 21 additions & 13 deletions

File tree

tests/live/serviceDesk/assets.test.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import { getClient } from '../setup/client';
66
/**
77
* Live suite for the Service Management `assets` API (`getAssetsWorkspaces`, `getInsightWorkspaces`).
88
*
9-
* Two endpoints that do the same thing under two names — Insight was renamed Assets, and the older path is kept for
10-
* compatibility. That is the only thing worth asserting about them, and it is the kind of fact that is invisible in
11-
* the types: a caller reading the client sees two unrelated-looking methods.
9+
* Two endpoints that once did the same thing under two names — Insight was renamed Assets, and the older path was
10+
* kept for compatibility. It no longer is: on Cloud today `/assets/workspace` answers and `/insight/workspace` is
11+
* gone, so what used to be worth asserting about the pair — that they behave identically — is simply false, and the
12+
* suite pins the deprecation instead.
1213
*
13-
* Both are gated behind the same agent licence as the rest of the surface, so what is pinned is the typed refusal and
14-
* that the two paths behave identically.
14+
* Both are gated behind the same agent licence as the rest of the surface, so an instance without one refuses rather
15+
* than answers, and the suite accepts either.
1516
*/
1617
describe('Jira Service Management — assets (live)', () => {
1718
let serviceDesk: ServiceDeskClient;
@@ -38,17 +39,24 @@ describe('Jira Service Management — assets (live)', () => {
3839
}
3940
});
4041

41-
it('behaves identically through the older Insight path', async () => {
42-
const assets = await serviceDesk.assets.getAssetsWorkspaces({ limit: 1 }).catch((e: unknown) => e);
43-
const insight = await serviceDesk.assets.getInsightWorkspaces({ limit: 1 }).catch((e: unknown) => e);
42+
/**
43+
* The retired path answers `403` with an HTML error page rather than the JSON every other refusal on this surface
44+
* carries. That is the reason this test is worth keeping now that the paths have diverged: it is the only live
45+
* assertion that a non-JSON body still arrives as a typed error with its status intact, instead of failing inside
46+
* the response parser.
47+
*/
48+
it('refuses the retired Insight path with a typed error, whatever the body', async () => {
49+
const result = await serviceDesk.assets.getInsightWorkspaces({ limit: 1 }).catch((e: unknown) => e);
4450

45-
const assetsFailed = assets instanceof Error;
46-
const insightFailed = insight instanceof Error;
51+
if (!(result instanceof Error)) {
52+
const page = result as Awaited<ReturnType<typeof serviceDesk.assets.getInsightWorkspaces>>;
4753

48-
expect(assetsFailed).toBe(insightFailed);
54+
expect(Array.isArray(page.values)).toBe(true);
4955

50-
if (assetsFailed && insightFailed) {
51-
expect((assets as { status?: number }).status).toBe((insight as { status?: number }).status);
56+
return;
5257
}
58+
59+
expect(typeof (result as { status?: number }).status).toBe('number');
60+
expect(isForbiddenError(result) || (result as { status?: number }).status === 404).toBe(true);
5361
});
5462
});

0 commit comments

Comments
 (0)