@rbaileysr/zephyr-managed-api 1.0.0
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 +618 -0
- package/dist/error-strategy.d.ts +69 -0
- package/dist/error-strategy.d.ts.map +1 -0
- package/dist/error-strategy.js +125 -0
- package/dist/groups/All.d.ts +90 -0
- package/dist/groups/All.d.ts.map +1 -0
- package/dist/groups/All.js +236 -0
- package/dist/groups/Automation.d.ts +75 -0
- package/dist/groups/Automation.d.ts.map +1 -0
- package/dist/groups/Automation.js +133 -0
- package/dist/groups/Environment.d.ts +73 -0
- package/dist/groups/Environment.d.ts.map +1 -0
- package/dist/groups/Environment.js +93 -0
- package/dist/groups/Folder.d.ts +55 -0
- package/dist/groups/Folder.d.ts.map +1 -0
- package/dist/groups/Folder.js +68 -0
- package/dist/groups/IssueLink.d.ts +59 -0
- package/dist/groups/IssueLink.d.ts.map +1 -0
- package/dist/groups/IssueLink.js +70 -0
- package/dist/groups/Link.d.ts +23 -0
- package/dist/groups/Link.d.ts.map +1 -0
- package/dist/groups/Link.js +34 -0
- package/dist/groups/Priority.d.ts +77 -0
- package/dist/groups/Priority.d.ts.map +1 -0
- package/dist/groups/Priority.js +97 -0
- package/dist/groups/Project.d.ts +36 -0
- package/dist/groups/Project.d.ts.map +1 -0
- package/dist/groups/Project.js +42 -0
- package/dist/groups/Status.d.ts +82 -0
- package/dist/groups/Status.d.ts.map +1 -0
- package/dist/groups/Status.js +102 -0
- package/dist/groups/TestCase.d.ts +254 -0
- package/dist/groups/TestCase.d.ts.map +1 -0
- package/dist/groups/TestCase.js +327 -0
- package/dist/groups/TestCycle.d.ts +127 -0
- package/dist/groups/TestCycle.d.ts.map +1 -0
- package/dist/groups/TestCycle.js +166 -0
- package/dist/groups/TestExecution.d.ts +176 -0
- package/dist/groups/TestExecution.d.ts.map +1 -0
- package/dist/groups/TestExecution.js +239 -0
- package/dist/groups/TestPlan.d.ts +103 -0
- package/dist/groups/TestPlan.d.ts.map +1 -0
- package/dist/groups/TestPlan.js +137 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +124 -0
- package/dist/types.d.ts +1353 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/utils-api-call.d.ts +22 -0
- package/dist/utils-api-call.d.ts.map +1 -0
- package/dist/utils-api-call.js +80 -0
- package/dist/utils.d.ts +144 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +432 -0
- package/package.json +54 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Case API group
|
|
3
|
+
* Handles test case-related operations
|
|
4
|
+
*/
|
|
5
|
+
import type { TestCase, TestCaseList, CursorPagedTestCaseList, ListTestCasesOptions, GetTestCaseOptions, CreateTestCaseRequest, UpdateTestCaseRequest, TestCaseLinkList, CreateTestCaseIssueLinkRequest, CreateTestCaseWebLinkRequest, TestCaseVersionLinkList, ListTestCaseVersionsOptions, GetTestCaseVersionOptions, CreateTestCaseTestScriptRequest, TestScript, TestStepsList, CreateTestCaseTestStepsRequest, KeyedCreatedResource, CreatedResource } from '../types';
|
|
6
|
+
import type { ZephyrApiConnection } from '../index';
|
|
7
|
+
import type { ErrorStrategyHandlers } from '../error-strategy';
|
|
8
|
+
export declare class TestCaseGroup {
|
|
9
|
+
private api;
|
|
10
|
+
constructor(api: ZephyrApiConnection);
|
|
11
|
+
/**
|
|
12
|
+
* List all test cases
|
|
13
|
+
*
|
|
14
|
+
* Retrieves a paginated list of test cases. Supports filtering by project key and folder ID.
|
|
15
|
+
* Automatically retries on rate limiting (429) with exponential backoff.
|
|
16
|
+
*
|
|
17
|
+
* @param options - Optional query parameters for filtering and pagination
|
|
18
|
+
* @param options.projectKey - Filter test cases by Jira project key
|
|
19
|
+
* @param options.folderId - Filter test cases by folder ID
|
|
20
|
+
* @param options.maxResults - Maximum number of results to return (default: 50)
|
|
21
|
+
* @param options.startAt - Zero-indexed starting position (must be multiple of maxResults)
|
|
22
|
+
* @returns Paginated list of test cases with metadata (total, isLast, etc.)
|
|
23
|
+
*
|
|
24
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/listTestCases Official API Documentation}
|
|
25
|
+
*/
|
|
26
|
+
listTestCases(options?: ListTestCasesOptions): Promise<TestCaseList>;
|
|
27
|
+
/**
|
|
28
|
+
* List all test cases (NextGen - cursor-based pagination)
|
|
29
|
+
*
|
|
30
|
+
* Retrieves test cases using cursor-based pagination. Use this endpoint for retrieving large volumes of test cases
|
|
31
|
+
* as it provides better performance than offset-based pagination.
|
|
32
|
+
* Automatically retries on rate limiting (429) with exponential backoff.
|
|
33
|
+
*
|
|
34
|
+
* @param options - Optional query parameters for filtering and pagination
|
|
35
|
+
* @param options.projectKey - Filter test cases by Jira project key
|
|
36
|
+
* @param options.folderId - Filter test cases by folder ID
|
|
37
|
+
* @param options.limit - Maximum number of results to return per page (default: 100)
|
|
38
|
+
* @param options.startAtId - Starting ID for cursor-based pagination (use null for first page)
|
|
39
|
+
* @returns Cursor-paginated list of test cases with nextStartAtId for pagination
|
|
40
|
+
*
|
|
41
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/listTestCasesNextgen Official API Documentation}
|
|
42
|
+
*/
|
|
43
|
+
listTestCasesCursorPaginated(options?: ListTestCasesOptions): Promise<CursorPagedTestCaseList>;
|
|
44
|
+
/**
|
|
45
|
+
* Get a specific test case
|
|
46
|
+
*
|
|
47
|
+
* Retrieves detailed information about a specific test case by its key (e.g., 'PROJ-T1').
|
|
48
|
+
* Automatically retries on rate limiting (429) with exponential backoff.
|
|
49
|
+
*
|
|
50
|
+
* @param options - Get test case options
|
|
51
|
+
* @param options.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
52
|
+
* @param errorStrategy - Optional error strategy for custom error handling (e.g., return null on 404)
|
|
53
|
+
* @returns Test case object with all fields, or value specified by error strategy
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // Return null if not found instead of throwing
|
|
58
|
+
* const testCase = await Zephyr.TestCase.getTestCase(
|
|
59
|
+
* { testCaseKey: 'PROJ-T1' },
|
|
60
|
+
* {
|
|
61
|
+
* handleHttp404Error: () => ({ type: 'return', value: null })
|
|
62
|
+
* }
|
|
63
|
+
* );
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/getTestCase Official API Documentation}
|
|
67
|
+
*/
|
|
68
|
+
getTestCase(options: GetTestCaseOptions, errorStrategy?: ErrorStrategyHandlers<TestCase | null>): Promise<TestCase | null>;
|
|
69
|
+
/**
|
|
70
|
+
* Create a new test case
|
|
71
|
+
*
|
|
72
|
+
* Creates a new test case in the specified project. Required fields include projectKey and name.
|
|
73
|
+
* Optional fields include objective, precondition, estimatedTime, priority, status, folder, owner, labels, and customFields.
|
|
74
|
+
* Automatically retries on rate limiting (429) with exponential backoff.
|
|
75
|
+
*
|
|
76
|
+
* @param request - Create test case request
|
|
77
|
+
* @param request.body - Test case data
|
|
78
|
+
* @param request.body.projectKey - Jira project key (required)
|
|
79
|
+
* @param request.body.name - Test case name (required)
|
|
80
|
+
* @param request.body.objective - Test case objective (optional)
|
|
81
|
+
* @param request.body.precondition - Test case precondition (optional)
|
|
82
|
+
* @param request.body.estimatedTime - Estimated execution time in milliseconds (optional)
|
|
83
|
+
* @param request.body.priorityName - Priority name (optional)
|
|
84
|
+
* @param request.body.statusName - Status name (optional)
|
|
85
|
+
* @param request.body.folderId - Folder ID (optional)
|
|
86
|
+
* @param request.body.ownerId - Owner account ID (optional)
|
|
87
|
+
* @param request.body.labels - Array of labels (optional)
|
|
88
|
+
* @param request.body.customFields - Custom field values (optional)
|
|
89
|
+
* @returns Created test case with key, id, and self link
|
|
90
|
+
*
|
|
91
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/createTestCase Official API Documentation}
|
|
92
|
+
*/
|
|
93
|
+
createTestCase(request: CreateTestCaseRequest): Promise<KeyedCreatedResource>;
|
|
94
|
+
/**
|
|
95
|
+
* Update an existing test case
|
|
96
|
+
*
|
|
97
|
+
* Updates an existing test case. For each non-specified field the value will be cleared.
|
|
98
|
+
* If the project has test case custom fields, all custom fields should be present in the request.
|
|
99
|
+
* Automatically retries on rate limiting (429) with exponential backoff.
|
|
100
|
+
*
|
|
101
|
+
* @param request - Update test case request
|
|
102
|
+
* @param request.testCaseKey - The test case key to update (e.g., 'PROJ-T1')
|
|
103
|
+
* @param request.body - Test case data to update (all fields optional, but unspecified fields will be cleared)
|
|
104
|
+
* @param request.body.name - Test case name (optional)
|
|
105
|
+
* @param request.body.objective - Test case objective (optional)
|
|
106
|
+
* @param request.body.precondition - Test case precondition (optional)
|
|
107
|
+
* @param request.body.estimatedTime - Estimated execution time in milliseconds (optional)
|
|
108
|
+
* @param request.body.priorityName - Priority name (optional)
|
|
109
|
+
* @param request.body.statusName - Status name (optional)
|
|
110
|
+
* @param request.body.folderId - Folder ID (optional)
|
|
111
|
+
* @param request.body.ownerId - Owner account ID (optional)
|
|
112
|
+
* @param request.body.labels - Array of labels (optional)
|
|
113
|
+
* @param request.body.customFields - Custom field values (optional, but all custom fields must be present if any are included)
|
|
114
|
+
* @returns Promise that resolves when update is complete
|
|
115
|
+
*
|
|
116
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/updateTestCase Official API Documentation}
|
|
117
|
+
*/
|
|
118
|
+
updateTestCase(request: UpdateTestCaseRequest): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Get links for a test case
|
|
121
|
+
*
|
|
122
|
+
* Retrieves all links associated with a test case, including issue links and web links.
|
|
123
|
+
*
|
|
124
|
+
* @param testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
125
|
+
* @returns List of links including issues and webLinks arrays
|
|
126
|
+
*
|
|
127
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/getTestCaseLinks Official API Documentation}
|
|
128
|
+
*/
|
|
129
|
+
getTestCaseLinks(testCaseKey: string): Promise<TestCaseLinkList>;
|
|
130
|
+
/**
|
|
131
|
+
* Create a link between a test case and a Jira issue
|
|
132
|
+
*
|
|
133
|
+
* Creates a link between a test case and a Jira issue. The link type can be COVERAGE, BLOCKS, or RELATED.
|
|
134
|
+
*
|
|
135
|
+
* @param request - Create issue link request
|
|
136
|
+
* @param request.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
137
|
+
* @param request.body - Link data
|
|
138
|
+
* @param request.body.issueId - Jira issue ID (required)
|
|
139
|
+
* @param request.body.type - Link type: 'COVERAGE', 'BLOCKS', or 'RELATED' (optional, defaults to 'COVERAGE')
|
|
140
|
+
* @returns Created link resource with id and self link
|
|
141
|
+
*
|
|
142
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/createTestCaseIssueLink Official API Documentation}
|
|
143
|
+
*/
|
|
144
|
+
createTestCaseIssueLink(request: CreateTestCaseIssueLinkRequest): Promise<CreatedResource>;
|
|
145
|
+
/**
|
|
146
|
+
* Create a link between a test case and a generic URL
|
|
147
|
+
*
|
|
148
|
+
* Creates a web link between a test case and an external URL. Useful for linking to documentation, requirements, or other resources.
|
|
149
|
+
*
|
|
150
|
+
* @param request - Create web link request
|
|
151
|
+
* @param request.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
152
|
+
* @param request.body - Web link data
|
|
153
|
+
* @param request.body.url - The URL to link to (required)
|
|
154
|
+
* @param request.body.description - Link description (optional)
|
|
155
|
+
* @param request.body.type - Link type: 'COVERAGE', 'BLOCKS', or 'RELATED' (optional, defaults to 'COVERAGE')
|
|
156
|
+
* @returns Created link resource with id and self link
|
|
157
|
+
*
|
|
158
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/createTestCaseWebLink Official API Documentation}
|
|
159
|
+
*/
|
|
160
|
+
createTestCaseWebLink(request: CreateTestCaseWebLinkRequest): Promise<CreatedResource>;
|
|
161
|
+
/**
|
|
162
|
+
* List all test case versions
|
|
163
|
+
*
|
|
164
|
+
* Retrieves a paginated list of all versions of a test case. Response is ordered by most recent first.
|
|
165
|
+
* Useful for tracking changes to test cases over time.
|
|
166
|
+
*
|
|
167
|
+
* @param options - List versions options
|
|
168
|
+
* @param options.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
169
|
+
* @param options.maxResults - Maximum number of results to return (default: 50)
|
|
170
|
+
* @param options.startAt - Zero-indexed starting position (must be multiple of maxResults)
|
|
171
|
+
* @returns Paginated list of test case version links
|
|
172
|
+
*
|
|
173
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/listTestCaseVersions Official API Documentation}
|
|
174
|
+
*/
|
|
175
|
+
listTestCaseVersions(options: ListTestCaseVersionsOptions): Promise<TestCaseVersionLinkList>;
|
|
176
|
+
/**
|
|
177
|
+
* Get a specific version of a test case
|
|
178
|
+
*
|
|
179
|
+
* Retrieves a specific version of a test case. Use this to view historical data or compare different versions.
|
|
180
|
+
*
|
|
181
|
+
* @param options - Get version options
|
|
182
|
+
* @param options.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
183
|
+
* @param options.version - The version number (1-based, where 1 is the current version)
|
|
184
|
+
* @returns Test case object for the specified version
|
|
185
|
+
*
|
|
186
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/getTestCaseVersion Official API Documentation}
|
|
187
|
+
*/
|
|
188
|
+
getTestCaseVersion(options: GetTestCaseVersionOptions): Promise<TestCase>;
|
|
189
|
+
/**
|
|
190
|
+
* Get the test script for a test case
|
|
191
|
+
*
|
|
192
|
+
* Retrieves the test script associated with a test case. Test scripts can be plain text or BDD format.
|
|
193
|
+
*
|
|
194
|
+
* @param testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
195
|
+
* @returns Test script object with type and text/content
|
|
196
|
+
*
|
|
197
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/getTestCaseTestScript Official API Documentation}
|
|
198
|
+
*/
|
|
199
|
+
getTestCaseTestScript(testCaseKey: string): Promise<TestScript>;
|
|
200
|
+
/**
|
|
201
|
+
* Create or update the test script for a test case
|
|
202
|
+
*
|
|
203
|
+
* Creates or updates the test script for a test case. Test scripts can be plain text or BDD format.
|
|
204
|
+
* If the test case currently has a sequence of test steps assigned to it, these will be implicitly removed.
|
|
205
|
+
*
|
|
206
|
+
* @param request - Create test script request
|
|
207
|
+
* @param request.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
208
|
+
* @param request.body - Test script data
|
|
209
|
+
* @param request.body.type - Script type: 'plain' or 'bdd' (required)
|
|
210
|
+
* @param request.body.text - Script text for plain type (required for plain type)
|
|
211
|
+
* @param request.body.content - Script content for BDD type (required for BDD type)
|
|
212
|
+
* @returns Created resource with id and self link
|
|
213
|
+
*
|
|
214
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/createTestCaseTestScript Official API Documentation}
|
|
215
|
+
*/
|
|
216
|
+
createTestCaseTestScript(request: CreateTestCaseTestScriptRequest): Promise<CreatedResource>;
|
|
217
|
+
/**
|
|
218
|
+
* Get test steps for a test case
|
|
219
|
+
*
|
|
220
|
+
* Retrieves the test steps associated with a test case. Provides a paged response, with 100 items per page by default.
|
|
221
|
+
* Test steps are used for structured test case definitions with step-by-step instructions.
|
|
222
|
+
*
|
|
223
|
+
* @param testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
224
|
+
* @param options - Optional pagination parameters
|
|
225
|
+
* @param options.maxResults - Maximum number of results to return (default: 100)
|
|
226
|
+
* @param options.startAt - Zero-indexed starting position (must be multiple of maxResults)
|
|
227
|
+
* @returns Paginated list of test steps
|
|
228
|
+
*
|
|
229
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/getTestCaseTestSteps Official API Documentation}
|
|
230
|
+
*/
|
|
231
|
+
getTestCaseTestSteps(testCaseKey: string, options?: {
|
|
232
|
+
maxResults?: number;
|
|
233
|
+
startAt?: number;
|
|
234
|
+
}): Promise<TestStepsList>;
|
|
235
|
+
/**
|
|
236
|
+
* Assign a series of test steps to a test case
|
|
237
|
+
*
|
|
238
|
+
* Creates or updates test steps for a test case. A maximum of 100 steps can be posted per request.
|
|
239
|
+
* If this endpoint is called on a test case that already has a plain text or BDD test script, that test script will implicitly be removed.
|
|
240
|
+
* Use mode 'OVERWRITE' to replace all existing steps, or 'APPEND' to add steps to existing ones.
|
|
241
|
+
*
|
|
242
|
+
* @param request - Create test steps request
|
|
243
|
+
* @param request.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
244
|
+
* @param request.body - Test steps data
|
|
245
|
+
* @param request.body.mode - Operation mode: 'OVERWRITE' to replace all steps, 'APPEND' to add steps (required)
|
|
246
|
+
* @param request.body.items - Array of test step items (maximum 100 per request)
|
|
247
|
+
* @param request.body.items[].inline - Inline test step with description, testData, and expectedResult
|
|
248
|
+
* @returns Created resource with id and self link
|
|
249
|
+
*
|
|
250
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/createTestCaseTestSteps Official API Documentation}
|
|
251
|
+
*/
|
|
252
|
+
createTestCaseTestSteps(request: CreateTestCaseTestStepsRequest): Promise<CreatedResource>;
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=TestCase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestCase.d.ts","sourceRoot":"","sources":["../../groups/TestCase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,QAAQ,EACR,YAAY,EACZ,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,8BAA8B,EAC9B,4BAA4B,EAC5B,uBAAuB,EACvB,2BAA2B,EAC3B,yBAAyB,EACzB,+BAA+B,EAC/B,UAAU,EACV,aAAa,EACb,8BAA8B,EAC9B,oBAAoB,EACpB,eAAe,EACf,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,qBAAa,aAAa;IACb,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,mBAAmB;IAE5C;;;;;;;;;;;;;;OAcG;IACG,aAAa,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC;IAK1E;;;;;;;;;;;;;;;OAeG;IACG,4BAA4B,CACjC,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,uBAAuB,CAAC;IAKnC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,WAAW,CAChB,OAAO,EAAE,kBAAkB,EAC3B,aAAa,CAAC,EAAE,qBAAqB,CAAC,QAAQ,GAAG,IAAI,CAAC,GACpD,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAQ3B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAUnF;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBnE;;;;;;;;;OASG;IACG,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAKtE;;;;;;;;;;;;;OAaG;IACG,uBAAuB,CAC5B,OAAO,EAAE,8BAA8B,GACrC,OAAO,CAAC,eAAe,CAAC;IAY3B;;;;;;;;;;;;;;OAcG;IACG,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,eAAe,CAAC;IAS5F;;;;;;;;;;;;;OAaG;IACG,oBAAoB,CACzB,OAAO,EAAE,2BAA2B,GAClC,OAAO,CAAC,uBAAuB,CAAC;IAQnC;;;;;;;;;;;OAWG;IACG,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAO/E;;;;;;;;;OASG;IACG,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAKrE;;;;;;;;;;;;;;;OAeG;IACG,wBAAwB,CAC7B,OAAO,EAAE,+BAA+B,GACtC,OAAO,CAAC,eAAe,CAAC;IAS3B;;;;;;;;;;;;;OAaG;IACG,oBAAoB,CACzB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GACjD,OAAO,CAAC,aAAa,CAAC;IAMzB;;;;;;;;;;;;;;;;OAgBG;IACG,uBAAuB,CAC5B,OAAO,EAAE,8BAA8B,GACrC,OAAO,CAAC,eAAe,CAAC;CAQ3B"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Case API group
|
|
3
|
+
* Handles test case-related operations
|
|
4
|
+
*/
|
|
5
|
+
import { buildQueryString, parseResponse, buildRequestBody, executeWithRetry } from '../utils';
|
|
6
|
+
export class TestCaseGroup {
|
|
7
|
+
constructor(api) {
|
|
8
|
+
this.api = api;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* List all test cases
|
|
12
|
+
*
|
|
13
|
+
* Retrieves a paginated list of test cases. Supports filtering by project key and folder ID.
|
|
14
|
+
* Automatically retries on rate limiting (429) with exponential backoff.
|
|
15
|
+
*
|
|
16
|
+
* @param options - Optional query parameters for filtering and pagination
|
|
17
|
+
* @param options.projectKey - Filter test cases by Jira project key
|
|
18
|
+
* @param options.folderId - Filter test cases by folder ID
|
|
19
|
+
* @param options.maxResults - Maximum number of results to return (default: 50)
|
|
20
|
+
* @param options.startAt - Zero-indexed starting position (must be multiple of maxResults)
|
|
21
|
+
* @returns Paginated list of test cases with metadata (total, isLast, etc.)
|
|
22
|
+
*
|
|
23
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/listTestCases Official API Documentation}
|
|
24
|
+
*/
|
|
25
|
+
async listTestCases(options) {
|
|
26
|
+
const queryString = buildQueryString(options);
|
|
27
|
+
return executeWithRetry(() => this.api.fetch(`/testcases${queryString}`));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* List all test cases (NextGen - cursor-based pagination)
|
|
31
|
+
*
|
|
32
|
+
* Retrieves test cases using cursor-based pagination. Use this endpoint for retrieving large volumes of test cases
|
|
33
|
+
* as it provides better performance than offset-based pagination.
|
|
34
|
+
* Automatically retries on rate limiting (429) with exponential backoff.
|
|
35
|
+
*
|
|
36
|
+
* @param options - Optional query parameters for filtering and pagination
|
|
37
|
+
* @param options.projectKey - Filter test cases by Jira project key
|
|
38
|
+
* @param options.folderId - Filter test cases by folder ID
|
|
39
|
+
* @param options.limit - Maximum number of results to return per page (default: 100)
|
|
40
|
+
* @param options.startAtId - Starting ID for cursor-based pagination (use null for first page)
|
|
41
|
+
* @returns Cursor-paginated list of test cases with nextStartAtId for pagination
|
|
42
|
+
*
|
|
43
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/listTestCasesNextgen Official API Documentation}
|
|
44
|
+
*/
|
|
45
|
+
async listTestCasesCursorPaginated(options) {
|
|
46
|
+
const queryString = buildQueryString(options);
|
|
47
|
+
return executeWithRetry(() => this.api.fetch(`/testcases/nextgen${queryString}`));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get a specific test case
|
|
51
|
+
*
|
|
52
|
+
* Retrieves detailed information about a specific test case by its key (e.g., 'PROJ-T1').
|
|
53
|
+
* Automatically retries on rate limiting (429) with exponential backoff.
|
|
54
|
+
*
|
|
55
|
+
* @param options - Get test case options
|
|
56
|
+
* @param options.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
57
|
+
* @param errorStrategy - Optional error strategy for custom error handling (e.g., return null on 404)
|
|
58
|
+
* @returns Test case object with all fields, or value specified by error strategy
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Return null if not found instead of throwing
|
|
63
|
+
* const testCase = await Zephyr.TestCase.getTestCase(
|
|
64
|
+
* { testCaseKey: 'PROJ-T1' },
|
|
65
|
+
* {
|
|
66
|
+
* handleHttp404Error: () => ({ type: 'return', value: null })
|
|
67
|
+
* }
|
|
68
|
+
* );
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/getTestCase Official API Documentation}
|
|
72
|
+
*/
|
|
73
|
+
async getTestCase(options, errorStrategy) {
|
|
74
|
+
return executeWithRetry(() => this.api.fetch(`/testcases/${options.testCaseKey}`), {}, errorStrategy);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a new test case
|
|
78
|
+
*
|
|
79
|
+
* Creates a new test case in the specified project. Required fields include projectKey and name.
|
|
80
|
+
* Optional fields include objective, precondition, estimatedTime, priority, status, folder, owner, labels, and customFields.
|
|
81
|
+
* Automatically retries on rate limiting (429) with exponential backoff.
|
|
82
|
+
*
|
|
83
|
+
* @param request - Create test case request
|
|
84
|
+
* @param request.body - Test case data
|
|
85
|
+
* @param request.body.projectKey - Jira project key (required)
|
|
86
|
+
* @param request.body.name - Test case name (required)
|
|
87
|
+
* @param request.body.objective - Test case objective (optional)
|
|
88
|
+
* @param request.body.precondition - Test case precondition (optional)
|
|
89
|
+
* @param request.body.estimatedTime - Estimated execution time in milliseconds (optional)
|
|
90
|
+
* @param request.body.priorityName - Priority name (optional)
|
|
91
|
+
* @param request.body.statusName - Status name (optional)
|
|
92
|
+
* @param request.body.folderId - Folder ID (optional)
|
|
93
|
+
* @param request.body.ownerId - Owner account ID (optional)
|
|
94
|
+
* @param request.body.labels - Array of labels (optional)
|
|
95
|
+
* @param request.body.customFields - Custom field values (optional)
|
|
96
|
+
* @returns Created test case with key, id, and self link
|
|
97
|
+
*
|
|
98
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/createTestCase Official API Documentation}
|
|
99
|
+
*/
|
|
100
|
+
async createTestCase(request) {
|
|
101
|
+
return executeWithRetry(() => this.api.fetch('/testcases', {
|
|
102
|
+
method: 'POST',
|
|
103
|
+
headers: { 'Content-Type': 'application/json' },
|
|
104
|
+
body: buildRequestBody(request.body),
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Update an existing test case
|
|
109
|
+
*
|
|
110
|
+
* Updates an existing test case. For each non-specified field the value will be cleared.
|
|
111
|
+
* If the project has test case custom fields, all custom fields should be present in the request.
|
|
112
|
+
* Automatically retries on rate limiting (429) with exponential backoff.
|
|
113
|
+
*
|
|
114
|
+
* @param request - Update test case request
|
|
115
|
+
* @param request.testCaseKey - The test case key to update (e.g., 'PROJ-T1')
|
|
116
|
+
* @param request.body - Test case data to update (all fields optional, but unspecified fields will be cleared)
|
|
117
|
+
* @param request.body.name - Test case name (optional)
|
|
118
|
+
* @param request.body.objective - Test case objective (optional)
|
|
119
|
+
* @param request.body.precondition - Test case precondition (optional)
|
|
120
|
+
* @param request.body.estimatedTime - Estimated execution time in milliseconds (optional)
|
|
121
|
+
* @param request.body.priorityName - Priority name (optional)
|
|
122
|
+
* @param request.body.statusName - Status name (optional)
|
|
123
|
+
* @param request.body.folderId - Folder ID (optional)
|
|
124
|
+
* @param request.body.ownerId - Owner account ID (optional)
|
|
125
|
+
* @param request.body.labels - Array of labels (optional)
|
|
126
|
+
* @param request.body.customFields - Custom field values (optional, but all custom fields must be present if any are included)
|
|
127
|
+
* @returns Promise that resolves when update is complete
|
|
128
|
+
*
|
|
129
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/updateTestCase Official API Documentation}
|
|
130
|
+
*/
|
|
131
|
+
async updateTestCase(request) {
|
|
132
|
+
await executeWithRetry(async () => {
|
|
133
|
+
const response = await this.api.fetch(`/testcases/${request.testCaseKey}`, {
|
|
134
|
+
method: 'PUT',
|
|
135
|
+
headers: { 'Content-Type': 'application/json' },
|
|
136
|
+
body: buildRequestBody(request.body),
|
|
137
|
+
});
|
|
138
|
+
if (!response.ok) {
|
|
139
|
+
await parseResponse(response);
|
|
140
|
+
}
|
|
141
|
+
// Return a mock response for void returns
|
|
142
|
+
return {
|
|
143
|
+
ok: true,
|
|
144
|
+
status: 200,
|
|
145
|
+
statusText: 'OK',
|
|
146
|
+
json: async () => ({ ok: true }),
|
|
147
|
+
headers: { get: () => null },
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get links for a test case
|
|
153
|
+
*
|
|
154
|
+
* Retrieves all links associated with a test case, including issue links and web links.
|
|
155
|
+
*
|
|
156
|
+
* @param testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
157
|
+
* @returns List of links including issues and webLinks arrays
|
|
158
|
+
*
|
|
159
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/getTestCaseLinks Official API Documentation}
|
|
160
|
+
*/
|
|
161
|
+
async getTestCaseLinks(testCaseKey) {
|
|
162
|
+
const response = await this.api.fetch(`/testcases/${testCaseKey}/links`);
|
|
163
|
+
return parseResponse(response);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create a link between a test case and a Jira issue
|
|
167
|
+
*
|
|
168
|
+
* Creates a link between a test case and a Jira issue. The link type can be COVERAGE, BLOCKS, or RELATED.
|
|
169
|
+
*
|
|
170
|
+
* @param request - Create issue link request
|
|
171
|
+
* @param request.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
172
|
+
* @param request.body - Link data
|
|
173
|
+
* @param request.body.issueId - Jira issue ID (required)
|
|
174
|
+
* @param request.body.type - Link type: 'COVERAGE', 'BLOCKS', or 'RELATED' (optional, defaults to 'COVERAGE')
|
|
175
|
+
* @returns Created link resource with id and self link
|
|
176
|
+
*
|
|
177
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/createTestCaseIssueLink Official API Documentation}
|
|
178
|
+
*/
|
|
179
|
+
async createTestCaseIssueLink(request) {
|
|
180
|
+
const response = await this.api.fetch(`/testcases/${request.testCaseKey}/links/issues`, {
|
|
181
|
+
method: 'POST',
|
|
182
|
+
headers: { 'Content-Type': 'application/json' },
|
|
183
|
+
body: buildRequestBody(request.body),
|
|
184
|
+
});
|
|
185
|
+
return parseResponse(response);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Create a link between a test case and a generic URL
|
|
189
|
+
*
|
|
190
|
+
* Creates a web link between a test case and an external URL. Useful for linking to documentation, requirements, or other resources.
|
|
191
|
+
*
|
|
192
|
+
* @param request - Create web link request
|
|
193
|
+
* @param request.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
194
|
+
* @param request.body - Web link data
|
|
195
|
+
* @param request.body.url - The URL to link to (required)
|
|
196
|
+
* @param request.body.description - Link description (optional)
|
|
197
|
+
* @param request.body.type - Link type: 'COVERAGE', 'BLOCKS', or 'RELATED' (optional, defaults to 'COVERAGE')
|
|
198
|
+
* @returns Created link resource with id and self link
|
|
199
|
+
*
|
|
200
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/createTestCaseWebLink Official API Documentation}
|
|
201
|
+
*/
|
|
202
|
+
async createTestCaseWebLink(request) {
|
|
203
|
+
const response = await this.api.fetch(`/testcases/${request.testCaseKey}/links/weblinks`, {
|
|
204
|
+
method: 'POST',
|
|
205
|
+
headers: { 'Content-Type': 'application/json' },
|
|
206
|
+
body: buildRequestBody(request.body),
|
|
207
|
+
});
|
|
208
|
+
return parseResponse(response);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* List all test case versions
|
|
212
|
+
*
|
|
213
|
+
* Retrieves a paginated list of all versions of a test case. Response is ordered by most recent first.
|
|
214
|
+
* Useful for tracking changes to test cases over time.
|
|
215
|
+
*
|
|
216
|
+
* @param options - List versions options
|
|
217
|
+
* @param options.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
218
|
+
* @param options.maxResults - Maximum number of results to return (default: 50)
|
|
219
|
+
* @param options.startAt - Zero-indexed starting position (must be multiple of maxResults)
|
|
220
|
+
* @returns Paginated list of test case version links
|
|
221
|
+
*
|
|
222
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/listTestCaseVersions Official API Documentation}
|
|
223
|
+
*/
|
|
224
|
+
async listTestCaseVersions(options) {
|
|
225
|
+
const queryString = buildQueryString(options);
|
|
226
|
+
const response = await this.api.fetch(`/testcases/${options.testCaseKey}/versions${queryString}`);
|
|
227
|
+
return parseResponse(response);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Get a specific version of a test case
|
|
231
|
+
*
|
|
232
|
+
* Retrieves a specific version of a test case. Use this to view historical data or compare different versions.
|
|
233
|
+
*
|
|
234
|
+
* @param options - Get version options
|
|
235
|
+
* @param options.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
236
|
+
* @param options.version - The version number (1-based, where 1 is the current version)
|
|
237
|
+
* @returns Test case object for the specified version
|
|
238
|
+
*
|
|
239
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/getTestCaseVersion Official API Documentation}
|
|
240
|
+
*/
|
|
241
|
+
async getTestCaseVersion(options) {
|
|
242
|
+
const response = await this.api.fetch(`/testcases/${options.testCaseKey}/versions/${options.version}`);
|
|
243
|
+
return parseResponse(response);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Get the test script for a test case
|
|
247
|
+
*
|
|
248
|
+
* Retrieves the test script associated with a test case. Test scripts can be plain text or BDD format.
|
|
249
|
+
*
|
|
250
|
+
* @param testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
251
|
+
* @returns Test script object with type and text/content
|
|
252
|
+
*
|
|
253
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/getTestCaseTestScript Official API Documentation}
|
|
254
|
+
*/
|
|
255
|
+
async getTestCaseTestScript(testCaseKey) {
|
|
256
|
+
const response = await this.api.fetch(`/testcases/${testCaseKey}/testscript`);
|
|
257
|
+
return parseResponse(response);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Create or update the test script for a test case
|
|
261
|
+
*
|
|
262
|
+
* Creates or updates the test script for a test case. Test scripts can be plain text or BDD format.
|
|
263
|
+
* If the test case currently has a sequence of test steps assigned to it, these will be implicitly removed.
|
|
264
|
+
*
|
|
265
|
+
* @param request - Create test script request
|
|
266
|
+
* @param request.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
267
|
+
* @param request.body - Test script data
|
|
268
|
+
* @param request.body.type - Script type: 'plain' or 'bdd' (required)
|
|
269
|
+
* @param request.body.text - Script text for plain type (required for plain type)
|
|
270
|
+
* @param request.body.content - Script content for BDD type (required for BDD type)
|
|
271
|
+
* @returns Created resource with id and self link
|
|
272
|
+
*
|
|
273
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/createTestCaseTestScript Official API Documentation}
|
|
274
|
+
*/
|
|
275
|
+
async createTestCaseTestScript(request) {
|
|
276
|
+
const response = await this.api.fetch(`/testcases/${request.testCaseKey}/testscript`, {
|
|
277
|
+
method: 'POST',
|
|
278
|
+
headers: { 'Content-Type': 'application/json' },
|
|
279
|
+
body: buildRequestBody(request.body),
|
|
280
|
+
});
|
|
281
|
+
return parseResponse(response);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Get test steps for a test case
|
|
285
|
+
*
|
|
286
|
+
* Retrieves the test steps associated with a test case. Provides a paged response, with 100 items per page by default.
|
|
287
|
+
* Test steps are used for structured test case definitions with step-by-step instructions.
|
|
288
|
+
*
|
|
289
|
+
* @param testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
290
|
+
* @param options - Optional pagination parameters
|
|
291
|
+
* @param options.maxResults - Maximum number of results to return (default: 100)
|
|
292
|
+
* @param options.startAt - Zero-indexed starting position (must be multiple of maxResults)
|
|
293
|
+
* @returns Paginated list of test steps
|
|
294
|
+
*
|
|
295
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/getTestCaseTestSteps Official API Documentation}
|
|
296
|
+
*/
|
|
297
|
+
async getTestCaseTestSteps(testCaseKey, options) {
|
|
298
|
+
const queryString = buildQueryString(options);
|
|
299
|
+
const response = await this.api.fetch(`/testcases/${testCaseKey}/teststeps${queryString}`);
|
|
300
|
+
return parseResponse(response);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Assign a series of test steps to a test case
|
|
304
|
+
*
|
|
305
|
+
* Creates or updates test steps for a test case. A maximum of 100 steps can be posted per request.
|
|
306
|
+
* If this endpoint is called on a test case that already has a plain text or BDD test script, that test script will implicitly be removed.
|
|
307
|
+
* Use mode 'OVERWRITE' to replace all existing steps, or 'APPEND' to add steps to existing ones.
|
|
308
|
+
*
|
|
309
|
+
* @param request - Create test steps request
|
|
310
|
+
* @param request.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
311
|
+
* @param request.body - Test steps data
|
|
312
|
+
* @param request.body.mode - Operation mode: 'OVERWRITE' to replace all steps, 'APPEND' to add steps (required)
|
|
313
|
+
* @param request.body.items - Array of test step items (maximum 100 per request)
|
|
314
|
+
* @param request.body.items[].inline - Inline test step with description, testData, and expectedResult
|
|
315
|
+
* @returns Created resource with id and self link
|
|
316
|
+
*
|
|
317
|
+
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/#operation/createTestCaseTestSteps Official API Documentation}
|
|
318
|
+
*/
|
|
319
|
+
async createTestCaseTestSteps(request) {
|
|
320
|
+
const response = await this.api.fetch(`/testcases/${request.testCaseKey}/teststeps`, {
|
|
321
|
+
method: 'POST',
|
|
322
|
+
headers: { 'Content-Type': 'application/json' },
|
|
323
|
+
body: buildRequestBody(request.body),
|
|
324
|
+
});
|
|
325
|
+
return parseResponse(response);
|
|
326
|
+
}
|
|
327
|
+
}
|