@elisra-devops/docgen-data-provider 1.94.0 → 1.95.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.
@@ -277,6 +277,16 @@ describe('ResultDataProvider', () => {
277
277
  testCaseUrl: 'https://dev.azure.com/organization/test-project/_workitems/edit/1',
278
278
  });
279
279
  });
280
+ it('should include pointAsOfTimestamp when lastUpdatedDate is available', () => {
281
+ const testPoint = {
282
+ testCaseReference: { id: 1, name: 'Test Case 1' },
283
+ lastUpdatedDate: '2025-01-01T12:34:56Z',
284
+ };
285
+ const result = resultDataProvider.mapTestPoint(testPoint, mockProjectName);
286
+ expect(result).toEqual(expect.objectContaining({
287
+ pointAsOfTimestamp: '2025-01-01T12:34:56.000Z',
288
+ }));
289
+ });
280
290
  });
281
291
  describe('calculateGroupResultSummary', () => {
282
292
  it('should return empty strings when includeHardCopyRun is true', () => {
@@ -3233,13 +3243,116 @@ describe('ResultDataProvider', () => {
3233
3243
  },
3234
3244
  relations: null,
3235
3245
  });
3236
- const res = await resultDataProvider.fetchResultDataBasedOnWiBase(mockProjectName, '0', '0', true, [], false, point);
3246
+ const res = await resultDataProvider.fetchResultDataBasedOnWiBase(mockProjectName, '0', '0', true, [], false, point, false, true);
3237
3247
  expect(tfs_1.TFSServices.getItemContent).toHaveBeenCalledWith(expect.stringContaining('/_apis/wit/workItems/123/revisions/9?$expand=all'), mockToken);
3238
3248
  const calledUrls = tfs_1.TFSServices.getItemContent.mock.calls.map((args) => String(args[0]));
3239
3249
  expect(calledUrls.some((url) => url.includes('?asOf='))).toBe(false);
3240
3250
  expect(res).toEqual(expect.objectContaining({ testCaseRevision: 9 }));
3241
3251
  });
3252
+ it('should ignore point asOf timestamp when runless asOf mode is disabled', async () => {
3253
+ const point = {
3254
+ testCaseId: '123',
3255
+ testCaseName: 'TC 123',
3256
+ outcome: 'passed',
3257
+ pointAsOfTimestamp: '2025-01-01T12:34:56Z',
3258
+ suiteTestCase: {
3259
+ workItem: {
3260
+ id: 123,
3261
+ rev: 9,
3262
+ workItemFields: [{ key: 'Microsoft.VSTS.TCM.Steps', value: '<steps></steps>' }],
3263
+ },
3264
+ },
3265
+ testSuite: { id: '1', name: 'Suite' },
3266
+ };
3267
+ tfs_1.TFSServices.getItemContent.mockResolvedValueOnce({
3268
+ id: 123,
3269
+ rev: 9,
3270
+ fields: {
3271
+ 'System.State': 'Active',
3272
+ 'System.CreatedDate': '2024-01-01T00:00:00',
3273
+ 'Microsoft.VSTS.TCM.Priority': 1,
3274
+ 'System.Title': 'Title 123',
3275
+ 'Microsoft.VSTS.TCM.Steps': '<steps></steps>',
3276
+ },
3277
+ relations: null,
3278
+ });
3279
+ const res = await resultDataProvider.fetchResultDataBasedOnWiBase(mockProjectName, '0', '0', true, [], false, point);
3280
+ const calledUrls = tfs_1.TFSServices.getItemContent.mock.calls.map((args) => String(args[0]));
3281
+ expect(calledUrls.some((url) => url.includes('/_apis/wit/workItems/123?asOf='))).toBe(false);
3282
+ expect(calledUrls.some((url) => url.includes('/_apis/wit/workItems/123/revisions/9'))).toBe(true);
3283
+ expect(res).toEqual(expect.objectContaining({ testCaseRevision: 9 }));
3284
+ });
3285
+ it('should fetch no-run test case by asOf timestamp when pointAsOfTimestamp is available', async () => {
3286
+ tfs_1.TFSServices.getItemContent.mockReset();
3287
+ const point = {
3288
+ testCaseId: '123',
3289
+ testCaseName: 'TC 123',
3290
+ outcome: 'passed',
3291
+ pointAsOfTimestamp: '2025-01-01T12:34:56Z',
3292
+ suiteTestCase: {
3293
+ workItem: {
3294
+ id: 123,
3295
+ rev: 9,
3296
+ workItemFields: [{ key: 'Microsoft.VSTS.TCM.Steps', value: '<steps></steps>' }],
3297
+ },
3298
+ },
3299
+ testSuite: { id: '1', name: 'Suite' },
3300
+ };
3301
+ tfs_1.TFSServices.getItemContent.mockResolvedValueOnce({
3302
+ id: 123,
3303
+ rev: 6,
3304
+ fields: {
3305
+ 'System.State': 'Active',
3306
+ 'System.CreatedDate': '2024-01-01T00:00:00',
3307
+ 'Microsoft.VSTS.TCM.Priority': 1,
3308
+ 'System.Title': 'Title 123',
3309
+ 'Microsoft.VSTS.TCM.Steps': '<steps></steps>',
3310
+ },
3311
+ relations: null,
3312
+ });
3313
+ const res = await resultDataProvider.fetchResultDataBasedOnWiBase(mockProjectName, '0', '0', true, [], false, point, false, true);
3314
+ const calledUrls = tfs_1.TFSServices.getItemContent.mock.calls.map((args) => String(args[0]));
3315
+ expect(calledUrls.some((url) => url.includes('/_apis/wit/workItems/123?asOf='))).toBe(true);
3316
+ expect(calledUrls.some((url) => url.includes('/revisions/9'))).toBe(false);
3317
+ expect(res).toEqual(expect.objectContaining({ testCaseRevision: 6 }));
3318
+ });
3319
+ it('should fallback to suite revision when asOf fetch fails', async () => {
3320
+ tfs_1.TFSServices.getItemContent.mockReset();
3321
+ const point = {
3322
+ testCaseId: '456',
3323
+ testCaseName: 'TC 456',
3324
+ outcome: 'Not Run',
3325
+ pointAsOfTimestamp: '2025-02-01T00:00:00Z',
3326
+ suiteTestCase: {
3327
+ workItem: {
3328
+ id: 456,
3329
+ workItemFields: [{ key: 'System.Rev', value: '11' }],
3330
+ },
3331
+ },
3332
+ testSuite: { id: '1', name: 'Suite' },
3333
+ };
3334
+ tfs_1.TFSServices.getItemContent
3335
+ .mockRejectedValueOnce(new Error('asOf failed'))
3336
+ .mockResolvedValueOnce({
3337
+ id: 456,
3338
+ rev: 11,
3339
+ fields: {
3340
+ 'System.State': 'Active',
3341
+ 'System.CreatedDate': '2024-01-01T00:00:00',
3342
+ 'Microsoft.VSTS.TCM.Priority': 1,
3343
+ 'System.Title': 'Title 456',
3344
+ 'Microsoft.VSTS.TCM.Steps': '<steps></steps>',
3345
+ },
3346
+ relations: [],
3347
+ });
3348
+ const res = await resultDataProvider.fetchResultDataBasedOnWiBase(mockProjectName, '0', '0', true, [], false, point, false, true);
3349
+ const calledUrls = tfs_1.TFSServices.getItemContent.mock.calls.map((args) => String(args[0]));
3350
+ expect(calledUrls.some((url) => url.includes('/_apis/wit/workItems/456?asOf='))).toBe(true);
3351
+ expect(calledUrls.some((url) => url.includes('/_apis/wit/workItems/456/revisions/11'))).toBe(true);
3352
+ expect(res).toEqual(expect.objectContaining({ testCaseRevision: 11 }));
3353
+ });
3242
3354
  it('should resolve no-run revision from System.Rev in suite test-case fields', async () => {
3355
+ tfs_1.TFSServices.getItemContent.mockReset();
3243
3356
  const point = {
3244
3357
  testCaseId: '321',
3245
3358
  testCaseName: 'TC 321',