Skip to content

Commit ca2309d

Browse files
committed
test: the Assets Cloud suite, written to stand down
Assets needs Jira Service Management Premium, and jirajs-dev has no Service Management licence at all — the workspace list comes back empty and there is nothing to point a client at. So this reports itself skipped rather than failing five times over a plan, the shape tests/live/setup/entitlement.ts established for the same reason, and comes back the moment the site is on Premium without an edit here. It deliberately builds its own client rather than taking the shared one. That it has to is the thing worth showing: Assets is the one surface that does not answer on the site's own host.
1 parent 9eb7c67 commit ca2309d

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

tests/live/assets/assets.test.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { beforeAll, describe, expect, it } from 'vitest';
2+
import { createAssetsClient, type AssetsClient } from '#/assets/createAssetsClient';
3+
import { createServiceDeskClient } from '#/serviceDesk/createServiceDeskClient';
4+
import { getClient } from '../setup/client';
5+
import { requireLiveEnv } from '../setup/env';
6+
7+
/**
8+
* Live suite for the Assets Cloud API.
9+
*
10+
* Assets needs Jira Service Management Premium. On a site without it `getAssetsWorkspaces` answers with an empty
11+
* list, and there is nothing to point a client at — so this stands down, visibly, rather than failing sixty times
12+
* over a plan. That is the shape `tests/live/setup/entitlement.ts` established for the Cloud suites, and for the same
13+
* reason: a suite that fails over an entitlement buries the signal it exists to carry.
14+
*
15+
* It comes back the moment the site is on Premium, without an edit here.
16+
*
17+
* The client is deliberately not `getClient()`. Assets is the one surface that does not answer on the site's own
18+
* host, so it is built from its own configuration — and that this suite has to do so is itself the thing worth
19+
* showing a reader.
20+
*/
21+
async function findWorkspace(): Promise<string | undefined> {
22+
const serviceDesk = createServiceDeskClient(getClient());
23+
24+
try {
25+
const page = await serviceDesk.assets.getAssetsWorkspaces({ limit: 1 });
26+
27+
return page.values?.[0]?.workspaceId;
28+
} catch {
29+
// A site with no Service Management at all refuses the lookup rather than answering it empty. Either way there
30+
// is no workspace, which is the only thing this needs to know.
31+
return undefined;
32+
}
33+
}
34+
35+
const workspaceId = await findWorkspace();
36+
37+
describe.skipIf(workspaceId === undefined)('Assets — Cloud (live)', () => {
38+
let assets: AssetsClient;
39+
40+
beforeAll(() => {
41+
const { email, apiToken } = requireLiveEnv();
42+
43+
assets = createAssetsClient({ workspaceId: workspaceId!, auth: { type: 'basic', email, apiToken } });
44+
});
45+
46+
it('lists the object schemas of the workspace', async () => {
47+
const schemas = await assets.objectSchemas.findSchemas({ maxResults: 5 });
48+
49+
expect(Array.isArray(schemas.values)).toBe(true);
50+
});
51+
52+
it('lists the global icons', async () => {
53+
const icons = await assets.icons.findGlobalIcons();
54+
55+
expect(Array.isArray(icons)).toBe(true);
56+
});
57+
58+
it('lists the status types', async () => {
59+
const statuses = await assets.statusTypes.findStatusTypes();
60+
61+
expect(Array.isArray(statuses)).toBe(true);
62+
});
63+
64+
it('reports what the tenant is using', async () => {
65+
const usage = await assets.usage.getTenantUsageInfo();
66+
67+
expect(usage).toBeTypeOf('object');
68+
});
69+
70+
it('counts objects by AQL', async () => {
71+
const count = await assets.objects.countObjectsByAql({ qlQuery: 'objectType is not empty' });
72+
73+
expect(count.totalCount).toBeTypeOf('number');
74+
});
75+
});
76+
77+
describe.runIf(workspaceId === undefined)('Assets — Cloud (live)', () => {
78+
it('stands down: the site has no Assets workspace', () => {
79+
expect(workspaceId).toBeUndefined();
80+
});
81+
});

0 commit comments

Comments
 (0)