@rbaileysr/zephyr-managed-api 1.4.0 → 1.4.1

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 CHANGED
@@ -181,11 +181,12 @@ Response Details: {
181
181
  - **Archiving**: `getArchivedTestCases`, `archiveTestCases`, `unarchiveTestCases`
182
182
  - **TestScriptData**: `setTestCaseParamTypeToParameter`, `setTestCaseParameters`, `setTestCaseParamTypeToTestData`, `setTestCaseTestData`, `getTestCaseTestData`, `hasTestCaseTestData`
183
183
  - **Versions**: `createTestCaseVersion`
184
+ - **Methods**: `getTestCaseTestStepsWithIds`, `createTestCaseTestStepsWithVersion`
184
185
  - ### TestCycle (entity-based group - v1.4.0+)
185
186
  - **ExtendedData**: `getTestCycleIteration`, `updateTestCycleIteration`
186
187
  - ### TestExecution (entity-based group - v1.4.0+)
187
188
  - **ExtendedData**: `getTestExecutionIteration`, `updateTestExecutionIteration`, `getTestExecutionVersion`, `updateTestExecutionVersion`
188
- - **Methods**: `createTestExecutionWithTestData`, `createTestExecutionWithVersion`, `updateTestExecution`, `getTestExecutionSteps`, `updateTestExecutionStepStatus`, `updateTestExecutionStepComment`, `getTestCycleItems`
189
+ - **Methods**: `listAllTestExecutionsForTestCase`, `createTestExecutionWithTestData`, `createTestExecutionWithVersion`, `updateTestExecution`, `getTestExecutionSteps`, `updateTestExecutionStepStatus`, `updateTestExecutionStepComment`, `getTestCycleItems`
189
190
  - ### Versions (deprecated - use `Private.TestCase.Versions` instead)
190
191
  - **createTestCaseVersion** - Create a new test case version
191
192
  - ### Attachments
@@ -215,8 +216,9 @@ Private API methods require Jira user credentials (email and API token) rather t
215
216
 
216
217
  ### Get Context JWT
217
218
 
218
- The Context JWT is a short-lived token (15 minutes) required for all private API calls:
219
+ The Context JWT is a short-lived token (15 minutes) required for all private API calls. See [`examples.ts`](./examples.ts) for comprehensive usage examples.
219
220
 
221
+ **Basic Usage:**
220
222
  ```typescript
221
223
  import { createZephyrApi } from '@rbaileysr/zephyr-managed-api';
222
224
  import ZephyrApiConnection from '../api/zephyr';
@@ -232,369 +234,41 @@ const credentials = {
232
234
 
233
235
  // Get Context JWT token
234
236
  const contextJwt = await api.Private.Authentication.getContextJwt(credentials);
235
-
236
- // Check if Zephyr is enabled for a project
237
- const status = await api.Private.Authentication.isZephyrEnabledForProject(credentials, {
238
- projectId: 10349
239
- });
240
- // Returns: { id: 10349, key: 'D1', permissionSystemEnabled: false, kanoahTestsEnabled: true, active: 1 }
241
-
242
- // Enable Zephyr for a project
243
- await api.Private.Authentication.enableZephyrForProject(credentials, {
244
- projectId: 10349
245
- });
246
- ```
247
-
248
- ### Example: Config Operations
249
-
250
- ```typescript
251
- // Create custom field
252
- const customField = await api.Private.Config.CustomFields.createCustomField(
253
- credentials, 'TEST_CASE', {
254
- projectId: 10017,
255
- name: 'Build Number',
256
- type: 'SINGLE_LINE_TEXT',
257
- required: false
258
- }
259
- );
260
-
261
- // Create label
262
- await api.Private.Config.Labels.createLabel(credentials, {
263
- projectId: 10233,
264
- name: 'automated'
265
- });
266
-
267
- // Create iteration
268
- const iteration = await api.Private.Config.Iterations.createIteration(credentials, {
269
- projectId: 10233,
270
- name: 'Sprint 1',
271
- description: 'First sprint of Q1'
272
- });
273
-
274
- // Create and update data set
275
- const dataSet = await api.Private.Config.DataSets.createDataSet(credentials, {
276
- projectId: 10233,
277
- name: 'Environment'
278
- });
279
- await api.Private.Config.DataSets.updateDataSet(credentials, {
280
- id: dataSet.id,
281
- projectId: 10233,
282
- items: [
283
- { name: 'Production', index: 0, archived: false },
284
- { name: 'Staging', index: 1, archived: false }
285
- ]
286
- });
287
- ```
288
-
289
- ### Example: Archive and Unarchive Config Items
290
-
291
- ```typescript
292
- // Archive an environment or iteration
293
- await api.Private.Config.archiveConfig(credentials, {
294
- type: 'Environment',
295
- id: 10873400,
296
- projectId: 10233
297
- });
298
-
299
- // Archive statuses (supports: TestCaseStatus, TestPlanStatus, TestCycleStatus, TestExecutionStatus)
300
- await api.Private.Config.archiveConfig(credentials, {
301
- type: 'TestCaseStatus',
302
- id: 10952238,
303
- projectId: 10313
304
- });
305
-
306
- // Unarchive any config item (same types supported)
307
- await api.Private.Config.unarchiveConfig(credentials, {
308
- type: 'Iteration',
309
- id: 10909775,
310
- projectId: 10233
311
- });
312
- ```
313
-
314
- ### Example: Create Test Case Version
315
-
316
- ```typescript
317
- // Create a new version of an existing test case (v1.4.0+)
318
- const newVersion = await api.Private.TestCase.Versions.createTestCaseVersion(
319
- credentials,
320
- {
321
- testCaseKey: 'PROJ-T1', // Uses key, looks up ID automatically
322
- projectId: 10017 // Numeric project ID
323
- }
324
- );
325
- ```
326
-
327
- **Note:** The old path (`Private.Versions.createTestCaseVersion`) still works but is deprecated. Use `Private.TestCase.Versions.createTestCaseVersion` for better organization.
328
-
329
- ### Example: Upload Attachment
330
-
331
- ```typescript
332
- // Upload an attachment to a test case
333
- const file = new Blob(['file content'], { type: 'text/plain' });
334
-
335
- const attachment = await api.Private.Attachments.createTestCaseAttachment(
336
- credentials,
337
- {
338
- testCaseKey: 'PROJ-T1',
339
- projectId: 10233,
340
- file: file,
341
- fileName: 'test-file.txt',
342
- userAccountId: '5d6fdc98dc6e480dbc021aae' // Atlassian account ID
343
- }
344
- );
345
- ```
346
-
347
- ### Example: Version-Specific Data
348
-
349
- ```typescript
350
- // Get version-specific data for test cases (version parameter is optional, defaults to latest)
351
- const issueLinks = await api.Private.VersionControl.getTestCaseIssueLinks(credentials, {
352
- testCaseKey: 'PROJ-T1',
353
- projectId: 10233,
354
- version: 2 // Get links for version 2
355
- });
356
-
357
- const testScript = await api.Private.VersionControl.getTestCaseTestScript(credentials, {
358
- testCaseKey: 'PROJ-T1',
359
- projectId: 10233,
360
- version: 3
361
- });
362
-
363
- // Test execution step issue links
364
- const stepLinks = await api.Private.VersionControl.getTestExecutionStepIssueLinks(credentials, {
365
- testExecutionKey: 'PROJ-E1',
366
- stepIndex: 0,
367
- projectId: 10233
368
- });
369
-
370
- await api.Private.VersionControl.createTestExecutionStepIssueLink(credentials, {
371
- testExecutionKey: 'PROJ-E1',
372
- stepIndex: 0,
373
- issueId: 66019,
374
- projectId: 10233
375
- });
376
- // Note: Link type is always 'RELATED' (typeId 3) - the API does not support choosing link types
377
237
  ```
378
238
 
379
- ### Example: Extended Data (Supplements Public API)
380
-
381
- The public API does not support iterations for Test Cycles/Executions or Jira version IDs for Test Executions. Use entity-based groups (v1.4.0+) to supplement public API calls.
382
-
383
- ```typescript
384
- // Test Cycle: Set/get iteration (v1.4.0+)
385
- const testCycle = await api.TestCycle.createTestCycle({
386
- projectKey: 'M12',
387
- name: 'Sprint 1 Testing'
388
- });
389
- await api.Private.TestCycle.ExtendedData.updateTestCycleIteration(credentials, {
390
- testCycleKey: testCycle.key,
391
- projectId: 10313,
392
- iterationId: 10952254
393
- });
394
- const cycleIteration = await api.Private.TestCycle.ExtendedData.getTestCycleIteration(credentials, {
395
- testCycleKey: 'M12-R1',
396
- projectId: 10313
397
- });
398
-
399
- // Test Execution: Set/get iteration and version (v1.4.0+)
400
- await api.TestExecution.createTestExecution({
401
- projectKey: 'M12',
402
- testCaseKey: 'M12-T1',
403
- testCycleKey: 'M12-R1',
404
- statusName: 'Pass'
405
- });
406
- // Note: createTestExecution returns void - use known key or look up via listTestExecutions()
407
- await api.Private.TestExecution.ExtendedData.updateTestExecutionIteration(credentials, {
408
- testExecutionKey: 'M12-E1',
409
- projectId: 10313,
410
- iterationId: 10952254
411
- });
412
- await api.Private.TestExecution.ExtendedData.updateTestExecutionVersion(credentials, {
413
- testExecutionKey: 'M15-E3',
414
- projectId: 10316,
415
- jiraVersionId: 10102
416
- });
417
-
418
- // Clear by setting to null
419
- await api.Private.TestCycle.ExtendedData.updateTestCycleIteration(credentials, {
420
- testCycleKey: 'M12-R1',
421
- projectId: 10313,
422
- iterationId: null
423
- });
424
- ```
425
-
426
- **Note:** The old paths (`Private.ExtendedData.*`) still work but are deprecated. Use the new entity-based paths (`Private.TestCycle.ExtendedData.*` and `Private.TestExecution.ExtendedData.*`) for better organization.
427
-
428
- ### Example: Test Case Archiving
429
-
430
- The public API does not expose the archived flag. Use `Private.TestCase.Archiving` (v1.4.0+) to list, archive, and unarchive test cases.
431
-
432
- ```typescript
433
- // Get archived test cases (paginated, optional query filter)
434
- const archived = await api.Private.TestCase.Archiving.getArchivedTestCases(credentials, {
435
- projectId: 10316,
436
- maxResults: 50,
437
- startAt: 0,
438
- query: "testCase.name CONTAINS 'migration'" // optional
439
- });
440
-
441
- // Archive test cases (single or multiple)
442
- await api.Private.TestCase.Archiving.archiveTestCases(credentials, {
443
- projectId: 10316,
444
- testCaseIds: [288004503, 288004504, 288004505]
445
- });
446
-
447
- // Unarchive test cases
448
- await api.Private.TestCase.Archiving.unarchiveTestCases(credentials, {
449
- projectId: 10316,
450
- testCaseIds: [288004503]
451
- });
452
- ```
453
-
454
- **Note:** The old path (`Private.TestCaseArchiving.*`) still works but is deprecated. Use `Private.TestCase.Archiving.*` for better organization.
455
-
456
- ### Test Script Data
457
-
458
- The public API does not expose test script data (Parameters and Test Data). Use `Private.TestCase.TestScriptData` (v1.4.0+) to manage this data.
459
-
460
- ```typescript
461
- // Check if test case has test script data
462
- const hasData = await api.Private.TestCase.TestScriptData.hasTestCaseTestData(credentials, {
463
- testCaseKey: 'M14-T6',
464
- projectId: 10315
465
- });
466
- // Returns: { hasData: true, type: 'PARAMETER' } or { hasData: false, type: null }
467
-
468
- // Get test script data
469
- const testData = await api.Private.TestCase.TestScriptData.getTestCaseTestData(credentials, {
470
- testCaseKey: 'M14-T6',
471
- projectId: 10315
472
- });
473
- // Returns: { paramType: 'PARAMETER' | 'TEST_DATA' | null, parameters: [...], testData: [...] }
474
-
475
- // Set test case to use Parameters
476
- await api.Private.TestCase.TestScriptData.setTestCaseParamTypeToParameter(credentials, {
477
- testCaseKey: 'M14-T6',
478
- projectId: 10315
479
- });
480
-
481
- // Set parameters
482
- await api.Private.TestCase.TestScriptData.setTestCaseParameters(credentials, {
483
- testCaseKey: 'M14-T6',
484
- projectId: 10315,
485
- parameters: [
486
- { index: 0, name: 'param1', defaultValue: 'value1' },
487
- { index: 1, name: 'param2', defaultValue: 'value2' }
488
- ]
489
- });
490
-
491
- // Set test case to use Test Data
492
- await api.Private.TestCase.TestScriptData.setTestCaseParamTypeToTestData(credentials, {
493
- testCaseKey: 'M14-T6',
494
- projectId: 10315
495
- });
496
-
497
- // Set test data (simplified array format)
498
- await api.Private.TestCase.TestScriptData.setTestCaseTestData(credentials, {
499
- testCaseKey: 'M14-T6',
500
- projectId: 10315,
501
- testData: [
502
- // Row 1
503
- [
504
- { columnName: 'Dataset Column', type: 'data_set', index: 0, dataSetItemId: 936037 },
505
- { columnName: 'Custom Column', type: 'free_text_input', index: 1, value: 'test value' }
506
- ]
507
- ]
508
- });
509
- ```
510
-
511
- **Note:** The old path (`Private.TestScriptData.*`) still works but is deprecated. Use `Private.TestCase.TestScriptData.*` for better organization.
512
-
513
- ### Test Executions with Test Data
514
-
515
- The public API does not correctly handle creating test executions for test cases with test data or test cases with "Call to Test" steps that reference test cases with test data. Use `Private.TestExecution` (v1.4.0+) to create and update these executions.
516
-
517
- ```typescript
518
- // Create test execution for test case with test data
519
- // This automatically handles the two-step process:
520
- // 1. Creates execution via public API
521
- // 2. Gets testRunItemId from private API
522
- // 3. Creates actual execution via private API
523
- const execution = await api.Private.TestExecution.createTestExecutionWithTestData(credentials, {
524
- testCaseKey: 'M14-T6',
525
- testCycleKey: 'M14-R1',
526
- assignedTo: '5d259f2e0b81c60c239bed83', // optional
527
- projectId: 10315
528
- });
529
- // Returns: { id: 2065132733, key: 'M14-E18' }
530
-
531
- // Create test execution for specific test case version (not just latest)
532
- // Unlike the public API which only creates executions against the latest version,
533
- // this allows creating executions against any version of a test case
534
- const executionWithVersion = await api.Private.TestExecution.createTestExecutionWithVersion(credentials, {
535
- body: {
536
- projectKey: 'M14',
537
- testCaseKey: 'M14-T6',
538
- testCycleKey: 'M14-R1',
539
- statusName: 'Not Executed',
540
- version: 2, // Create execution against version 2 of the test case
541
- environmentName: 'Production', // optional
542
- assignedToId: '5d259f2e0b81c60c239bed83', // optional
543
- comment: 'Testing version 2', // optional
544
- },
545
- projectId: 10315,
546
- assignedTo: '5d259f2e0b81c60c239bed83', // optional, can override body.assignedToId
547
- iterationId: 10966272, // optional
548
- jiraVersionId: 10206 // optional
549
- });
550
- // Returns: { id: 2068847141, key: 'M2-E13' }
551
-
552
- // Get test cycle items (to find testRunItemId for a test case)
553
- const items = await api.Private.TestExecution.getTestCycleItems(credentials, {
554
- testCycleKey: 'M14-R1',
555
- projectId: 10315
556
- });
557
-
558
- // Update parent test execution
559
- await api.Private.TestExecution.updateTestExecution(credentials, {
560
- testExecutionKey: 'M14-E18',
561
- id: 2065132733, // Optional if testExecutionKey is provided
562
- actualStartDate: '2025-12-24T13:02:50.233Z',
563
- executionDate: '2025-12-24T13:02:50.233Z',
564
- executionTime: 0,
565
- testResultStatusId: 10952941,
566
- projectId: 10315
567
- });
568
-
569
- // Get test execution steps (to get step IDs for updates)
570
- const steps = await api.Private.TestExecution.getTestExecutionSteps(credentials, {
571
- testCycleKey: 'M14-R1',
572
- testRunItemId: 1443476310, // From getTestCycleItems
573
- projectId: 10315
574
- });
575
-
576
- // Update test execution step status
577
- await api.Private.TestExecution.updateTestExecutionStepStatus(credentials, {
578
- id: 6287896613, // From getTestExecutionSteps
579
- testResultStatusId: 10952942,
580
- executionDate: '2025-12-24T13:02:50.232Z',
581
- projectId: 10315
582
- });
583
-
584
- // Update test execution step comment (actual result)
585
- await api.Private.TestExecution.updateTestExecutionStepComment(credentials, {
586
- id: 6287896613, // From getTestExecutionSteps
587
- comment: 'Test passed successfully',
588
- projectId: 10315
589
- });
590
- ```
591
-
592
- **Note:** The old path (`Private.TestExecutions.*`) still works but is deprecated. Use `Private.TestExecution.*` for better organization.
239
+ ## Private API Examples
240
+
241
+ Comprehensive examples for all private API methods are available in [`examples.ts`](./examples.ts). This file includes examples for:
242
+
243
+ - **Authentication**: Context JWT, project enablement checks
244
+ - **Config Operations**: Custom fields, labels, iterations, data sets, archiving
245
+ - **Test Case Operations**: Version creation, archiving, test script data management, test steps with version support
246
+ - **Test Cycle Operations**: Extended data (iterations)
247
+ - **Test Execution Operations**: Extended data (iterations, versions), test data handling, version-specific executions, listing all executions
248
+ - **Attachments**: Uploading and managing attachments
249
+ - **Version Control**: Version-specific data retrieval
250
+
251
+ **Quick Reference:**
252
+ - See `authenticationExamples()` for Context JWT and project enablement
253
+ - See `configOperationsExamples()` for custom fields, labels, iterations, and data sets
254
+ - See `archiveConfigExamples()` for archiving/unarchiving config items
255
+ - See `testCaseVersionExamples()` for creating test case versions
256
+ - See `attachmentExamples()` for uploading attachments
257
+ - See `versionSpecificDataExamples()` for version-specific data retrieval
258
+ - See `extendedDataExamples()` for supplementing public API with extended data
259
+ - See `testCaseArchivingExamples()` for test case archiving operations
260
+ - See `testScriptDataExamples()` for managing test script data (Parameters and Test Data)
261
+ - See `testStepsWithVersionExamples()` for test steps with version support
262
+ - See `testExecutionsWithTestDataExamples()` for advanced test execution operations
263
+ - See `listAllTestExecutionsExamples()` for listing all test executions across versions
593
264
 
594
265
  **Notes:**
595
266
  - Version numbers are absolute (1-based). Use `listTestCaseVersions()` to find available versions. If `version` is not provided, the latest version is used.
596
267
  - Private API methods require `PrivateApiCredentials` (`userEmail`, `apiToken`, `jiraInstanceUrl`). Context JWT tokens expire after 15 minutes and are automatically retrieved internally.
597
268
  - Methods accept keys (e.g., `testCaseKey`) and automatically look up numeric IDs when needed.
269
+ - Deprecated paths still work but will be removed in v2.0.0 - use the new entity-based paths for better organization.
270
+
271
+ ## Contact
598
272
 
599
273
  ## Contact
600
274
 
@@ -602,6 +276,14 @@ Feel free to drop ideas, suggestions or improvements into our [Community hub](ht
602
276
 
603
277
  ## Changelog
604
278
 
279
+ ### 1.4.1
280
+
281
+ - **Added**: `listAllTestExecutionsForTestCase()` - List all test executions for a test case across all versions. Unlike the public API which only returns executions for the latest version, this method returns executions from all test case versions. Returns minimal data (key and testCase info) - use the public API to get full execution details if needed.
282
+ - **Added**: `getTestCaseTestStepsWithIds()` - Get test case test steps with step IDs included. Unlike the public API which doesn't return step IDs, this method provides IDs needed for updating steps. Also includes call-to-test step information with test case IDs and versions.
283
+ - **Added**: `createTestCaseTestStepsWithVersion()` - Create or update test case test steps with version support for call-to-test steps. Unlike the public API which only allows test case keys (always uses latest version), this method allows specifying a version for call-to-test steps, enabling references to older test case versions.
284
+ - **Added**: Helper method `getFullTestCaseData()` in `PrivateBase` - Reusable method for fetching comprehensive test case data including all metadata, test script with step IDs, test data, parameters, and all other available fields. Used internally by multiple private API methods to ensure consistency and reduce code duplication.
285
+ - **Refactored**: Consolidated duplicate test case data fetching logic across `PrivateVersionControl`, `PrivateAttachments`, and `PrivateTestCase` methods to use the centralized `getFullTestCaseData()` helper method.
286
+
605
287
  ### 1.4.0
606
288
 
607
289
  - **Changed**: Major structural reorganization of Private API to follow entity-based grouping (mirrors public API organization)