@rbaileysr/zephyr-managed-api 1.3.6 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +215 -3
- package/dist/README.md +215 -3
- package/dist/groups/All.d.ts +1 -1
- package/dist/groups/All.d.ts.map +1 -1
- package/dist/groups/Private/PrivateConfig.d.ts +26 -10
- package/dist/groups/Private/PrivateConfig.d.ts.map +1 -1
- package/dist/groups/Private/PrivateConfig.js +36 -12
- package/dist/groups/Private/PrivateExtendedData.d.ts +229 -0
- package/dist/groups/Private/PrivateExtendedData.d.ts.map +1 -0
- package/dist/groups/Private/PrivateExtendedData.js +543 -0
- package/dist/groups/Private/PrivateTestCaseArchiving.d.ts +123 -0
- package/dist/groups/Private/PrivateTestCaseArchiving.d.ts.map +1 -0
- package/dist/groups/Private/PrivateTestCaseArchiving.js +265 -0
- package/dist/groups/Private.d.ts +12 -0
- package/dist/groups/Private.d.ts.map +1 -1
- package/dist/groups/Private.js +4 -0
- package/dist/groups/TestExecution.d.ts +4 -2
- package/dist/groups/TestExecution.d.ts.map +1 -1
- package/dist/groups/TestExecution.js +6 -2
- package/dist/package.json +1 -2
- package/dist/types.d.ts +263 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -2
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright Adaptavist 2025 (c) All rights reserved
|
|
3
|
+
*/
|
|
4
|
+
import { PrivateBase } from './PrivateBase';
|
|
5
|
+
import { BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ServerError, UnexpectedError, } from '../../utils';
|
|
6
|
+
export class PrivateExtendedData extends PrivateBase {
|
|
7
|
+
constructor(apiConnection) {
|
|
8
|
+
super(apiConnection);
|
|
9
|
+
}
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Test Cycle Iteration Methods
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Get test cycle iteration using private API
|
|
15
|
+
*
|
|
16
|
+
* Retrieves iteration data for a test cycle that is not available in the public API.
|
|
17
|
+
* Use this to supplement the public `getTestCycle()` response with iteration information.
|
|
18
|
+
*
|
|
19
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
20
|
+
* The endpoint may change or be removed at any time without notice.
|
|
21
|
+
*
|
|
22
|
+
* @param credentials - Private API credentials
|
|
23
|
+
* @param request - Get test cycle iteration request
|
|
24
|
+
* @param request.testCycleKey - Test cycle key (e.g., "M12-R1")
|
|
25
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
26
|
+
* @returns Test cycle iteration response with iterationId (null if not set)
|
|
27
|
+
* @throws {BadRequestError} If the request is invalid
|
|
28
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
29
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
30
|
+
* @throws {NotFoundError} If the test cycle is not found
|
|
31
|
+
* @throws {ServerError} If the server returns an error
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Get iteration for a test cycle (supplements public getTestCycle)
|
|
36
|
+
* const publicData = await api.TestCycle.getTestCycle({ key: 'M12-R1' });
|
|
37
|
+
* const iterationData = await api.Private.IterationData.getTestCycleIteration(credentials, {
|
|
38
|
+
* testCycleKey: 'M12-R1',
|
|
39
|
+
* projectId: 10313
|
|
40
|
+
* });
|
|
41
|
+
* console.log('Iteration ID:', iterationData.iterationId);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
async getTestCycleIteration(credentials, request) {
|
|
45
|
+
// Get Context JWT
|
|
46
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
47
|
+
// Build URL with minimal fields needed
|
|
48
|
+
const fields = 'id,key,iterationId';
|
|
49
|
+
const url = `${this.privateApiBaseUrl}/testrun/${request.testCycleKey}?fields=${encodeURIComponent(fields)}`;
|
|
50
|
+
const headers = {
|
|
51
|
+
accept: 'application/json',
|
|
52
|
+
authorization: `JWT ${contextJwt}`,
|
|
53
|
+
'jira-project-id': String(request.projectId),
|
|
54
|
+
};
|
|
55
|
+
try {
|
|
56
|
+
const response = await fetch(url, {
|
|
57
|
+
method: 'GET',
|
|
58
|
+
headers,
|
|
59
|
+
});
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
if (response.status === 400) {
|
|
62
|
+
throw new BadRequestError(`Invalid request parameters for getting test cycle iteration.`);
|
|
63
|
+
}
|
|
64
|
+
if (response.status === 401) {
|
|
65
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
66
|
+
}
|
|
67
|
+
if (response.status === 403) {
|
|
68
|
+
throw new ForbiddenError('Insufficient permissions to get test cycle iteration.');
|
|
69
|
+
}
|
|
70
|
+
if (response.status === 404) {
|
|
71
|
+
throw new NotFoundError(`Test cycle '${request.testCycleKey}' not found.`);
|
|
72
|
+
}
|
|
73
|
+
throw new ServerError(`Failed to get test cycle iteration. Status: ${response.status}`, response.status, response.statusText);
|
|
74
|
+
}
|
|
75
|
+
const data = (await response.json());
|
|
76
|
+
return {
|
|
77
|
+
id: data.id,
|
|
78
|
+
key: data.key,
|
|
79
|
+
iterationId: data.iterationId ?? null,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error instanceof BadRequestError ||
|
|
84
|
+
error instanceof UnauthorizedError ||
|
|
85
|
+
error instanceof ForbiddenError ||
|
|
86
|
+
error instanceof NotFoundError ||
|
|
87
|
+
error instanceof ServerError ||
|
|
88
|
+
error instanceof UnexpectedError) {
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
throw new UnexpectedError(`Unexpected error while getting test cycle iteration for '${request.testCycleKey}'`, error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Update test cycle iteration using private API
|
|
96
|
+
*
|
|
97
|
+
* Sets or clears the iteration for a test cycle. Use this to supplement
|
|
98
|
+
* a test cycle created via the public API with iteration data.
|
|
99
|
+
*
|
|
100
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
101
|
+
* The endpoint may change or be removed at any time without notice.
|
|
102
|
+
*
|
|
103
|
+
* @param credentials - Private API credentials
|
|
104
|
+
* @param request - Update test cycle iteration request
|
|
105
|
+
* @param request.testCycleKey - Test cycle key (e.g., "M12-R1")
|
|
106
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
107
|
+
* @param request.iterationId - Iteration ID to set, or null to clear
|
|
108
|
+
* @throws {BadRequestError} If the request is invalid
|
|
109
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
110
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
111
|
+
* @throws {NotFoundError} If the test cycle is not found
|
|
112
|
+
* @throws {ServerError} If the server returns an error
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* // Create test cycle with public API, then set iteration with private API
|
|
117
|
+
* const testCycle = await api.TestCycle.createTestCycle({
|
|
118
|
+
* projectKey: 'M12',
|
|
119
|
+
* name: 'Sprint 1 Testing'
|
|
120
|
+
* });
|
|
121
|
+
*
|
|
122
|
+
* // Set iteration using private API
|
|
123
|
+
* await api.Private.IterationData.updateTestCycleIteration(credentials, {
|
|
124
|
+
* testCycleKey: testCycle.key,
|
|
125
|
+
* projectId: 10313,
|
|
126
|
+
* iterationId: 10952254
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
async updateTestCycleIteration(credentials, request) {
|
|
131
|
+
// Get Context JWT
|
|
132
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
133
|
+
// First, get the numeric ID for the test cycle
|
|
134
|
+
const testCycleData = await this.getTestCycleIteration(credentials, {
|
|
135
|
+
testCycleKey: request.testCycleKey,
|
|
136
|
+
projectId: request.projectId,
|
|
137
|
+
});
|
|
138
|
+
// Build URL with numeric ID
|
|
139
|
+
const url = `${this.privateApiBaseUrl}/testrun/${testCycleData.id}`;
|
|
140
|
+
const headers = {
|
|
141
|
+
'Content-Type': 'application/json',
|
|
142
|
+
accept: 'application/json',
|
|
143
|
+
authorization: `JWT ${contextJwt}`,
|
|
144
|
+
'jira-project-id': String(request.projectId),
|
|
145
|
+
};
|
|
146
|
+
const requestBody = {
|
|
147
|
+
id: testCycleData.id,
|
|
148
|
+
projectId: request.projectId,
|
|
149
|
+
iterationId: request.iterationId,
|
|
150
|
+
};
|
|
151
|
+
try {
|
|
152
|
+
const response = await fetch(url, {
|
|
153
|
+
method: 'PUT',
|
|
154
|
+
headers,
|
|
155
|
+
body: JSON.stringify(requestBody),
|
|
156
|
+
});
|
|
157
|
+
if (!response.ok) {
|
|
158
|
+
if (response.status === 400) {
|
|
159
|
+
throw new BadRequestError(`Invalid request parameters for updating test cycle iteration.`);
|
|
160
|
+
}
|
|
161
|
+
if (response.status === 401) {
|
|
162
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
163
|
+
}
|
|
164
|
+
if (response.status === 403) {
|
|
165
|
+
throw new ForbiddenError('Insufficient permissions to update test cycle iteration.');
|
|
166
|
+
}
|
|
167
|
+
if (response.status === 404) {
|
|
168
|
+
throw new NotFoundError(`Test cycle '${request.testCycleKey}' not found.`);
|
|
169
|
+
}
|
|
170
|
+
throw new ServerError(`Failed to update test cycle iteration. Status: ${response.status}`, response.status, response.statusText);
|
|
171
|
+
}
|
|
172
|
+
// Response is empty on success
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
if (error instanceof BadRequestError ||
|
|
176
|
+
error instanceof UnauthorizedError ||
|
|
177
|
+
error instanceof ForbiddenError ||
|
|
178
|
+
error instanceof NotFoundError ||
|
|
179
|
+
error instanceof ServerError ||
|
|
180
|
+
error instanceof UnexpectedError) {
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
throw new UnexpectedError(`Unexpected error while updating test cycle iteration for '${request.testCycleKey}'`, error);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// ============================================================================
|
|
187
|
+
// Test Execution Iteration Methods
|
|
188
|
+
// ============================================================================
|
|
189
|
+
/**
|
|
190
|
+
* Get test execution iteration using private API
|
|
191
|
+
*
|
|
192
|
+
* Retrieves iteration data for a test execution that is not available in the public API.
|
|
193
|
+
* Use this to supplement the public `getTestExecution()` response with iteration information.
|
|
194
|
+
*
|
|
195
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
196
|
+
* The endpoint may change or be removed at any time without notice.
|
|
197
|
+
*
|
|
198
|
+
* @param credentials - Private API credentials
|
|
199
|
+
* @param request - Get test execution iteration request
|
|
200
|
+
* @param request.testExecutionKey - Test execution key (e.g., "M12-E1")
|
|
201
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
202
|
+
* @returns Test execution iteration response with iterationId (null if not set)
|
|
203
|
+
* @throws {BadRequestError} If the request is invalid
|
|
204
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
205
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
206
|
+
* @throws {NotFoundError} If the test execution is not found
|
|
207
|
+
* @throws {ServerError} If the server returns an error
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* // Get iteration for a test execution (supplements public getTestExecution)
|
|
212
|
+
* const publicData = await api.TestExecution.getTestExecution({ key: 'M12-E1' });
|
|
213
|
+
* const iterationData = await api.Private.IterationData.getTestExecutionIteration(credentials, {
|
|
214
|
+
* testExecutionKey: 'M12-E1',
|
|
215
|
+
* projectId: 10313
|
|
216
|
+
* });
|
|
217
|
+
* console.log('Iteration ID:', iterationData.iterationId);
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
async getTestExecutionIteration(credentials, request) {
|
|
221
|
+
// Get Context JWT
|
|
222
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
223
|
+
// Build URL with minimal fields needed
|
|
224
|
+
const fields = 'id,key,iterationId';
|
|
225
|
+
const url = `${this.privateApiBaseUrl}/testresult/${request.testExecutionKey}?fields=${encodeURIComponent(fields)}&itemId=${request.testExecutionKey}`;
|
|
226
|
+
const headers = {
|
|
227
|
+
accept: 'application/json',
|
|
228
|
+
authorization: `JWT ${contextJwt}`,
|
|
229
|
+
'jira-project-id': String(request.projectId),
|
|
230
|
+
};
|
|
231
|
+
try {
|
|
232
|
+
const response = await fetch(url, {
|
|
233
|
+
method: 'GET',
|
|
234
|
+
headers,
|
|
235
|
+
});
|
|
236
|
+
if (!response.ok) {
|
|
237
|
+
if (response.status === 400) {
|
|
238
|
+
throw new BadRequestError(`Invalid request parameters for getting test execution iteration.`);
|
|
239
|
+
}
|
|
240
|
+
if (response.status === 401) {
|
|
241
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
242
|
+
}
|
|
243
|
+
if (response.status === 403) {
|
|
244
|
+
throw new ForbiddenError('Insufficient permissions to get test execution iteration.');
|
|
245
|
+
}
|
|
246
|
+
if (response.status === 404) {
|
|
247
|
+
throw new NotFoundError(`Test execution '${request.testExecutionKey}' not found.`);
|
|
248
|
+
}
|
|
249
|
+
throw new ServerError(`Failed to get test execution iteration. Status: ${response.status}`, response.status, response.statusText);
|
|
250
|
+
}
|
|
251
|
+
const data = (await response.json());
|
|
252
|
+
return {
|
|
253
|
+
id: data.id,
|
|
254
|
+
key: data.key,
|
|
255
|
+
iterationId: data.iterationId ?? null,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
if (error instanceof BadRequestError ||
|
|
260
|
+
error instanceof UnauthorizedError ||
|
|
261
|
+
error instanceof ForbiddenError ||
|
|
262
|
+
error instanceof NotFoundError ||
|
|
263
|
+
error instanceof ServerError ||
|
|
264
|
+
error instanceof UnexpectedError) {
|
|
265
|
+
throw error;
|
|
266
|
+
}
|
|
267
|
+
throw new UnexpectedError(`Unexpected error while getting test execution iteration for '${request.testExecutionKey}'`, error);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Update test execution iteration using private API
|
|
272
|
+
*
|
|
273
|
+
* Sets or clears the iteration for a test execution. Use this to supplement
|
|
274
|
+
* a test execution created via the public API with iteration data.
|
|
275
|
+
*
|
|
276
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
277
|
+
* The endpoint may change or be removed at any time without notice.
|
|
278
|
+
*
|
|
279
|
+
* @param credentials - Private API credentials
|
|
280
|
+
* @param request - Update test execution iteration request
|
|
281
|
+
* @param request.testExecutionKey - Test execution key (e.g., "M12-E1")
|
|
282
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
283
|
+
* @param request.iterationId - Iteration ID to set, or null to clear
|
|
284
|
+
* @throws {BadRequestError} If the request is invalid
|
|
285
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
286
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
287
|
+
* @throws {NotFoundError} If the test execution is not found
|
|
288
|
+
* @throws {ServerError} If the server returns an error
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* // Create test execution with public API (returns void), then set iteration with private API
|
|
293
|
+
* await api.TestExecution.createTestExecution({
|
|
294
|
+
* projectKey: 'M12',
|
|
295
|
+
* testCaseKey: 'M12-T1',
|
|
296
|
+
* testCycleKey: 'M12-R1',
|
|
297
|
+
* statusName: 'Pass'
|
|
298
|
+
* });
|
|
299
|
+
*
|
|
300
|
+
* // Note: createTestExecution returns no data, so use known key or look up after creation
|
|
301
|
+
* // Set iteration using private API
|
|
302
|
+
* await api.Private.IterationData.updateTestExecutionIteration(credentials, {
|
|
303
|
+
* testExecutionKey: 'M12-E1', // Use known key or look up via listTestExecutions()
|
|
304
|
+
* projectId: 10313,
|
|
305
|
+
* iterationId: 10952254
|
|
306
|
+
* });
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
async updateTestExecutionIteration(credentials, request) {
|
|
310
|
+
// Get Context JWT
|
|
311
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
312
|
+
// First, get the numeric ID for the test execution
|
|
313
|
+
const testExecutionData = await this.getTestExecutionIteration(credentials, {
|
|
314
|
+
testExecutionKey: request.testExecutionKey,
|
|
315
|
+
projectId: request.projectId,
|
|
316
|
+
});
|
|
317
|
+
// Build URL with numeric ID
|
|
318
|
+
const url = `${this.privateApiBaseUrl}/testresult/${testExecutionData.id}`;
|
|
319
|
+
const headers = {
|
|
320
|
+
'Content-Type': 'application/json',
|
|
321
|
+
accept: 'application/json',
|
|
322
|
+
authorization: `JWT ${contextJwt}`,
|
|
323
|
+
'jira-project-id': String(request.projectId),
|
|
324
|
+
};
|
|
325
|
+
const requestBody = {
|
|
326
|
+
id: testExecutionData.id,
|
|
327
|
+
iterationId: request.iterationId,
|
|
328
|
+
};
|
|
329
|
+
try {
|
|
330
|
+
const response = await fetch(url, {
|
|
331
|
+
method: 'PUT',
|
|
332
|
+
headers,
|
|
333
|
+
body: JSON.stringify(requestBody),
|
|
334
|
+
});
|
|
335
|
+
if (!response.ok) {
|
|
336
|
+
if (response.status === 400) {
|
|
337
|
+
throw new BadRequestError(`Invalid request parameters for updating test execution iteration.`);
|
|
338
|
+
}
|
|
339
|
+
if (response.status === 401) {
|
|
340
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
341
|
+
}
|
|
342
|
+
if (response.status === 403) {
|
|
343
|
+
throw new ForbiddenError('Insufficient permissions to update test execution iteration.');
|
|
344
|
+
}
|
|
345
|
+
if (response.status === 404) {
|
|
346
|
+
throw new NotFoundError(`Test execution '${request.testExecutionKey}' not found.`);
|
|
347
|
+
}
|
|
348
|
+
throw new ServerError(`Failed to update test execution iteration. Status: ${response.status}`, response.status, response.statusText);
|
|
349
|
+
}
|
|
350
|
+
// Response is empty on success
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
if (error instanceof BadRequestError ||
|
|
354
|
+
error instanceof UnauthorizedError ||
|
|
355
|
+
error instanceof ForbiddenError ||
|
|
356
|
+
error instanceof NotFoundError ||
|
|
357
|
+
error instanceof ServerError ||
|
|
358
|
+
error instanceof UnexpectedError) {
|
|
359
|
+
throw error;
|
|
360
|
+
}
|
|
361
|
+
throw new UnexpectedError(`Unexpected error while updating test execution iteration for '${request.testExecutionKey}'`, error);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
// ============================================================================
|
|
365
|
+
// Test Execution Version Methods
|
|
366
|
+
// ============================================================================
|
|
367
|
+
/**
|
|
368
|
+
* Get test execution version using private API
|
|
369
|
+
*
|
|
370
|
+
* Retrieves Jira version ID (release version) for a test execution that is not available in the public API.
|
|
371
|
+
* Use this to supplement the public `getTestExecution()` response with version information.
|
|
372
|
+
*
|
|
373
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
374
|
+
* The endpoint may change or be removed at any time without notice.
|
|
375
|
+
*
|
|
376
|
+
* @param credentials - Private API credentials
|
|
377
|
+
* @param request - Get test execution version request
|
|
378
|
+
* @param request.testExecutionKey - Test execution key (e.g., "M15-E3")
|
|
379
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
380
|
+
* @returns Test execution version response with jiraVersionId (null if not set)
|
|
381
|
+
* @throws {BadRequestError} If the request is invalid
|
|
382
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
383
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
384
|
+
* @throws {NotFoundError} If the test execution is not found
|
|
385
|
+
* @throws {ServerError} If the server returns an error
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
389
|
+
* // Get version for a test execution (supplements public getTestExecution)
|
|
390
|
+
* const publicData = await api.TestExecution.getTestExecution({ key: 'M15-E3' });
|
|
391
|
+
* const versionData = await api.Private.IterationData.getTestExecutionVersion(credentials, {
|
|
392
|
+
* testExecutionKey: 'M15-E3',
|
|
393
|
+
* projectId: 10316
|
|
394
|
+
* });
|
|
395
|
+
* console.log('Jira Version ID:', versionData.jiraVersionId);
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
async getTestExecutionVersion(credentials, request) {
|
|
399
|
+
// Get Context JWT
|
|
400
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
401
|
+
// Build URL with minimal fields needed (jiraVersionId is included in the fields)
|
|
402
|
+
const fields = 'id,key,jiraVersionId';
|
|
403
|
+
const url = `${this.privateApiBaseUrl}/testresult/${request.testExecutionKey}?fields=${encodeURIComponent(fields)}&itemId=${request.testExecutionKey}`;
|
|
404
|
+
const headers = {
|
|
405
|
+
accept: 'application/json',
|
|
406
|
+
authorization: `JWT ${contextJwt}`,
|
|
407
|
+
'jira-project-id': String(request.projectId),
|
|
408
|
+
};
|
|
409
|
+
try {
|
|
410
|
+
const response = await fetch(url, {
|
|
411
|
+
method: 'GET',
|
|
412
|
+
headers,
|
|
413
|
+
});
|
|
414
|
+
if (!response.ok) {
|
|
415
|
+
if (response.status === 400) {
|
|
416
|
+
throw new BadRequestError(`Invalid request parameters for getting test execution version.`);
|
|
417
|
+
}
|
|
418
|
+
if (response.status === 401) {
|
|
419
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
420
|
+
}
|
|
421
|
+
if (response.status === 403) {
|
|
422
|
+
throw new ForbiddenError('Insufficient permissions to get test execution version.');
|
|
423
|
+
}
|
|
424
|
+
if (response.status === 404) {
|
|
425
|
+
throw new NotFoundError(`Test execution '${request.testExecutionKey}' not found.`);
|
|
426
|
+
}
|
|
427
|
+
throw new ServerError(`Failed to get test execution version. Status: ${response.status}`, response.status, response.statusText);
|
|
428
|
+
}
|
|
429
|
+
const data = (await response.json());
|
|
430
|
+
return {
|
|
431
|
+
id: data.id,
|
|
432
|
+
key: data.key,
|
|
433
|
+
// jiraVersionId is excluded from response if not set, so use null if undefined
|
|
434
|
+
jiraVersionId: data.jiraVersionId ?? null,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
if (error instanceof BadRequestError ||
|
|
439
|
+
error instanceof UnauthorizedError ||
|
|
440
|
+
error instanceof ForbiddenError ||
|
|
441
|
+
error instanceof NotFoundError ||
|
|
442
|
+
error instanceof ServerError ||
|
|
443
|
+
error instanceof UnexpectedError) {
|
|
444
|
+
throw error;
|
|
445
|
+
}
|
|
446
|
+
throw new UnexpectedError(`Unexpected error while getting test execution version for '${request.testExecutionKey}'`, error);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Update test execution version using private API
|
|
451
|
+
*
|
|
452
|
+
* Sets or clears the Jira version ID (release version) for a test execution. Use this to supplement
|
|
453
|
+
* a test execution created via the public API with version data.
|
|
454
|
+
*
|
|
455
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
456
|
+
* The endpoint may change or be removed at any time without notice.
|
|
457
|
+
*
|
|
458
|
+
* @param credentials - Private API credentials
|
|
459
|
+
* @param request - Update test execution version request
|
|
460
|
+
* @param request.testExecutionKey - Test execution key (e.g., "M15-E3")
|
|
461
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
462
|
+
* @param request.jiraVersionId - Jira version ID to set, or null to clear
|
|
463
|
+
* @throws {BadRequestError} If the request is invalid
|
|
464
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
465
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
466
|
+
* @throws {NotFoundError} If the test execution is not found
|
|
467
|
+
* @throws {ServerError} If the server returns an error
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```typescript
|
|
471
|
+
* // Create test execution with public API (returns void), then set version with private API
|
|
472
|
+
* await api.TestExecution.createTestExecution({
|
|
473
|
+
* projectKey: 'M15',
|
|
474
|
+
* testCaseKey: 'M15-T3',
|
|
475
|
+
* testCycleKey: 'M15-R1',
|
|
476
|
+
* statusName: 'Pass'
|
|
477
|
+
* });
|
|
478
|
+
*
|
|
479
|
+
* // Note: createTestExecution returns no data, so use known key or look up after creation
|
|
480
|
+
* // Set version using private API
|
|
481
|
+
* await api.Private.IterationData.updateTestExecutionVersion(credentials, {
|
|
482
|
+
* testExecutionKey: 'M15-E3', // Use known key or look up via listTestExecutions()
|
|
483
|
+
* projectId: 10316,
|
|
484
|
+
* jiraVersionId: 10102
|
|
485
|
+
* });
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
async updateTestExecutionVersion(credentials, request) {
|
|
489
|
+
// Get Context JWT
|
|
490
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
491
|
+
// First, get the numeric ID for the test execution
|
|
492
|
+
const testExecutionData = await this.getTestExecutionVersion(credentials, {
|
|
493
|
+
testExecutionKey: request.testExecutionKey,
|
|
494
|
+
projectId: request.projectId,
|
|
495
|
+
});
|
|
496
|
+
// Build URL with numeric ID
|
|
497
|
+
const url = `${this.privateApiBaseUrl}/testresult/${testExecutionData.id}`;
|
|
498
|
+
const headers = {
|
|
499
|
+
'Content-Type': 'application/json',
|
|
500
|
+
accept: 'application/json',
|
|
501
|
+
authorization: `JWT ${contextJwt}`,
|
|
502
|
+
'jira-project-id': String(request.projectId),
|
|
503
|
+
};
|
|
504
|
+
const requestBody = {
|
|
505
|
+
id: testExecutionData.id,
|
|
506
|
+
jiraVersionId: request.jiraVersionId,
|
|
507
|
+
};
|
|
508
|
+
try {
|
|
509
|
+
const response = await fetch(url, {
|
|
510
|
+
method: 'PUT',
|
|
511
|
+
headers,
|
|
512
|
+
body: JSON.stringify(requestBody),
|
|
513
|
+
});
|
|
514
|
+
if (!response.ok) {
|
|
515
|
+
if (response.status === 400) {
|
|
516
|
+
throw new BadRequestError(`Invalid request parameters for updating test execution version.`);
|
|
517
|
+
}
|
|
518
|
+
if (response.status === 401) {
|
|
519
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
520
|
+
}
|
|
521
|
+
if (response.status === 403) {
|
|
522
|
+
throw new ForbiddenError('Insufficient permissions to update test execution version.');
|
|
523
|
+
}
|
|
524
|
+
if (response.status === 404) {
|
|
525
|
+
throw new NotFoundError(`Test execution '${request.testExecutionKey}' not found.`);
|
|
526
|
+
}
|
|
527
|
+
throw new ServerError(`Failed to update test execution version. Status: ${response.status}`, response.status, response.statusText);
|
|
528
|
+
}
|
|
529
|
+
// Response is empty on success
|
|
530
|
+
}
|
|
531
|
+
catch (error) {
|
|
532
|
+
if (error instanceof BadRequestError ||
|
|
533
|
+
error instanceof UnauthorizedError ||
|
|
534
|
+
error instanceof ForbiddenError ||
|
|
535
|
+
error instanceof NotFoundError ||
|
|
536
|
+
error instanceof ServerError ||
|
|
537
|
+
error instanceof UnexpectedError) {
|
|
538
|
+
throw error;
|
|
539
|
+
}
|
|
540
|
+
throw new UnexpectedError(`Unexpected error while updating test execution version for '${request.testExecutionKey}'`, error);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright Adaptavist 2025 (c) All rights reserved
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Private API Test Case Archiving sub-group
|
|
6
|
+
* Provides functionality to list, archive, and unarchive test cases
|
|
7
|
+
*
|
|
8
|
+
* ⚠️ WARNING: These methods use private APIs that are not officially supported.
|
|
9
|
+
*/
|
|
10
|
+
import type { PrivateApiCredentials, GetArchivedTestCasesRequest, PrivateArchivedTestCaseSearchResponse, ArchiveTestCasesRequest, UnarchiveTestCasesRequest } from '../../types';
|
|
11
|
+
import type { ZephyrApiConnection } from '../../index';
|
|
12
|
+
import { PrivateBase } from './PrivateBase';
|
|
13
|
+
export declare class PrivateTestCaseArchiving extends PrivateBase {
|
|
14
|
+
constructor(apiConnection?: ZephyrApiConnection);
|
|
15
|
+
/**
|
|
16
|
+
* Get archived test cases using private API
|
|
17
|
+
*
|
|
18
|
+
* Retrieves a paginated list of archived test cases for a project.
|
|
19
|
+
* The archived flag is not available in the public API, so this method
|
|
20
|
+
* provides access to archived test cases.
|
|
21
|
+
*
|
|
22
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
23
|
+
* The endpoint may change or be removed at any time without notice.
|
|
24
|
+
*
|
|
25
|
+
* @param credentials - Private API credentials
|
|
26
|
+
* @param request - Get archived test cases request
|
|
27
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
28
|
+
* @param request.maxResults - Maximum number of results to return (default: 50)
|
|
29
|
+
* @param request.startAt - Zero-indexed starting position (default: 0)
|
|
30
|
+
* @param request.query - Optional query string for filtering (e.g., "testCase.name CONTAINS 'test'")
|
|
31
|
+
* @returns Paginated list of archived test cases
|
|
32
|
+
* @throws {BadRequestError} If the request is invalid
|
|
33
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
34
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
35
|
+
* @throws {ServerError} If the server returns an error
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // Get first page of archived test cases
|
|
40
|
+
* const archived = await api.Private.TestCaseArchiving.getArchivedTestCases(credentials, {
|
|
41
|
+
* projectId: 10316,
|
|
42
|
+
* maxResults: 50,
|
|
43
|
+
* startAt: 0
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Get archived test cases with custom query
|
|
47
|
+
* const filtered = await api.Private.TestCaseArchiving.getArchivedTestCases(credentials, {
|
|
48
|
+
* projectId: 10316,
|
|
49
|
+
* query: "testCase.name CONTAINS 'migration'"
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
getArchivedTestCases(credentials: PrivateApiCredentials, request: GetArchivedTestCasesRequest): Promise<PrivateArchivedTestCaseSearchResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Archive test cases using private API
|
|
56
|
+
*
|
|
57
|
+
* Archives one or more test cases. This is a bulk operation that accepts
|
|
58
|
+
* an array of test case IDs.
|
|
59
|
+
*
|
|
60
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
61
|
+
* The endpoint may change or be removed at any time without notice.
|
|
62
|
+
*
|
|
63
|
+
* @param credentials - Private API credentials
|
|
64
|
+
* @param request - Archive test cases request
|
|
65
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
66
|
+
* @param request.testCaseIds - Array of test case IDs to archive
|
|
67
|
+
* @throws {BadRequestError} If the request is invalid
|
|
68
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
69
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
70
|
+
* @throws {ServerError} If the server returns an error
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* // Archive a single test case
|
|
75
|
+
* await api.Private.TestCaseArchiving.archiveTestCases(credentials, {
|
|
76
|
+
* projectId: 10316,
|
|
77
|
+
* testCaseIds: [288004503]
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Archive multiple test cases
|
|
81
|
+
* await api.Private.TestCaseArchiving.archiveTestCases(credentials, {
|
|
82
|
+
* projectId: 10316,
|
|
83
|
+
* testCaseIds: [288004503, 288004504, 288004505]
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
archiveTestCases(credentials: PrivateApiCredentials, request: ArchiveTestCasesRequest): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Unarchive test cases using private API
|
|
90
|
+
*
|
|
91
|
+
* Unarchives one or more test cases. This is a bulk operation that accepts
|
|
92
|
+
* an array of test case IDs.
|
|
93
|
+
*
|
|
94
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
95
|
+
* The endpoint may change or be removed at any time without notice.
|
|
96
|
+
*
|
|
97
|
+
* @param credentials - Private API credentials
|
|
98
|
+
* @param request - Unarchive test cases request
|
|
99
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
100
|
+
* @param request.testCaseIds - Array of test case IDs to unarchive
|
|
101
|
+
* @throws {BadRequestError} If the request is invalid
|
|
102
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
103
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
104
|
+
* @throws {ServerError} If the server returns an error
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* // Unarchive a single test case
|
|
109
|
+
* await api.Private.TestCaseArchiving.unarchiveTestCases(credentials, {
|
|
110
|
+
* projectId: 10316,
|
|
111
|
+
* testCaseIds: [288004503]
|
|
112
|
+
* });
|
|
113
|
+
*
|
|
114
|
+
* // Unarchive multiple test cases
|
|
115
|
+
* await api.Private.TestCaseArchiving.unarchiveTestCases(credentials, {
|
|
116
|
+
* projectId: 10316,
|
|
117
|
+
* testCaseIds: [288004503, 288004504, 288004505]
|
|
118
|
+
* });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
unarchiveTestCases(credentials: PrivateApiCredentials, request: UnarchiveTestCasesRequest): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=PrivateTestCaseArchiving.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrivateTestCaseArchiving.d.ts","sourceRoot":"","sources":["../../../groups/Private/PrivateTestCaseArchiving.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EACX,qBAAqB,EACrB,2BAA2B,EAC3B,qCAAqC,EACrC,uBAAuB,EACvB,yBAAyB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAU5C,qBAAa,wBAAyB,SAAQ,WAAW;gBAC5C,aAAa,CAAC,EAAE,mBAAmB;IAI/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACG,oBAAoB,CACzB,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,2BAA2B,GAClC,OAAO,CAAC,qCAAqC,CAAC;IAyEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,gBAAgB,CACrB,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,uBAAuB,GAC9B,OAAO,CAAC,IAAI,CAAC;IAkEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,kBAAkB,CACvB,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,yBAAyB,GAChC,OAAO,CAAC,IAAI,CAAC;CAiEhB"}
|