@@ -6,13 +6,17 @@ import { getClient } from '../setup/client';
66/**
77 * Live suite for the Service Management `assets` API (`getAssetsWorkspaces`, `getInsightWorkspaces`).
88 *
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.
9+ * Two endpoints for one thing under two names — Insight was renamed Assets, and the older path is kept for
10+ * compatibility. The suite used to assert that the pair behaves identically, which stopped being true when
11+ * `/assets/workspace` began answering on this tenant while `/insight/workspace` did not.
1312 *
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.
13+ * That divergence is a licensing fact, not a retirement: the older path refuses with the same 403 as
14+ * `getServiceDesks`, `getCustomerRequests` and `getOrganizations`, all four carrying a byte-identical copy of Jira's
15+ * generic HTML error page. Atlassian has announced no removal, and both operations remain in the specification. So
16+ * each path is pinned on its own terms — answer or typed refusal — rather than against the other.
17+ *
18+ * What the refusal is worth asserting for is the body: an HTML page is the one response on any of the three surfaces
19+ * that the JSON parser has no way to read, and it still has to arrive as a typed error with its status intact.
1620 */
1721describe ( 'Jira Service Management — assets (live)' , ( ) => {
1822 let serviceDesk : ServiceDeskClient ;
@@ -21,11 +25,18 @@ describe('Jira Service Management — assets (live)', () => {
2125 serviceDesk = createServiceDeskClient ( getClient ( ) ) ;
2226 } ) ;
2327
24- it ( 'answers the assets workspace lookup, or refuses typed' , async ( ) => {
25- const result = await serviceDesk . assets . getAssetsWorkspaces ( { limit : 5 } ) . catch ( ( e : unknown ) => e ) ;
28+ /** Both names answer with the same page of workspace ids, so both are read the same way. */
29+ const lookups : [ string , ( ) => Promise < unknown > ] [ ] = [
30+ [ 'assets.getAssetsWorkspaces' , ( ) => serviceDesk . assets . getAssetsWorkspaces ( { limit : 5 } ) ] ,
31+ [ 'assets.getInsightWorkspaces' , ( ) => serviceDesk . assets . getInsightWorkspaces ( { limit : 5 } ) ] ,
32+ ] ;
33+
34+ it . each ( lookups ) ( 'answers the %s lookup, or refuses typed' , async ( _name , lookup ) => {
35+ const result = await lookup ( ) . catch ( ( e : unknown ) => e ) ;
2636
2737 if ( result instanceof Error ) {
28- expect ( isForbiddenError ( result ) || ( result as { status ?: number } ) . status === 404 ) . toBe ( true ) ;
38+ expect ( isForbiddenError ( result ) ) . toBe ( true ) ;
39+ expect ( ( result as { status ?: number } ) . status ) . toBe ( 403 ) ;
2940
3041 return ;
3142 }
@@ -38,25 +49,4 @@ describe('Jira Service Management — assets (live)', () => {
3849 expect ( typeof workspace . workspaceId ) . toBe ( 'string' ) ;
3950 }
4051 } ) ;
41-
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 ) ;
50-
51- if ( ! ( result instanceof Error ) ) {
52- const page = result as Awaited < ReturnType < typeof serviceDesk . assets . getInsightWorkspaces > > ;
53-
54- expect ( Array . isArray ( page . values ) ) . toBe ( true ) ;
55-
56- return ;
57- }
58-
59- expect ( typeof ( result as { status ?: number } ) . status ) . toBe ( 'number' ) ;
60- expect ( isForbiddenError ( result ) || ( result as { status ?: number } ) . status === 404 ) . toBe ( true ) ;
61- } ) ;
6252} ) ;
0 commit comments