@elisra-devops/docgen-data-provider 1.136.3 → 1.136.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elisra-devops/docgen-data-provider",
3
- "version": "1.136.3",
3
+ "version": "1.136.4",
4
4
  "description": "A document generator data provider, aimed to retrive data from azure devops",
5
5
  "repository": {
6
6
  "type": "git",
@@ -3747,6 +3747,11 @@ export default class ResultDataProvider {
3747
3747
  const testCaseId = Number(
3748
3748
  point?.testCaseId || suiteTestCaseItem?.workItem?.id || suiteTestCaseItem?.testCaseId || 0
3749
3749
  );
3750
+ if (useLatestTestCaseProperties) {
3751
+ logger.debug(
3752
+ `[TestReporter][LatestProperties] Fetching latest test case work item for testCaseId=${testCaseId}, runId=${runId}, resultId=${resultId}`
3753
+ );
3754
+ }
3750
3755
  const suiteTestCaseRevision = this.resolveSuiteTestCaseRevision(suiteTestCaseItem);
3751
3756
  const pointAsOfTimestamp = useRunlessAsOf
3752
3757
  ? String(point?.pointAsOfTimestamp || '').trim()
@@ -5826,7 +5831,7 @@ export default class ResultDataProvider {
5826
5831
  return null;
5827
5832
  }
5828
5833
  },
5829
- [selectedFields, isQueryMode, point, includeAllHistory, useRunlessAsOf]
5834
+ [selectedFields, isQueryMode, point, includeAllHistory, useRunlessAsOf, useLatestTestCaseProperties]
5830
5835
  );
5831
5836
  }
5832
5837
 
@@ -4300,6 +4300,32 @@ describe('ResultDataProvider', () => {
4300
4300
 
4301
4301
  expect(res.testCaseResult).toEqual(expect.objectContaining({ url: '' }));
4302
4302
  });
4303
+
4304
+ it('should pass latest test case properties flag to the point result fetch', async () => {
4305
+ const fetchResultDataBaseSpy = jest
4306
+ .spyOn(resultDataProvider as any, 'fetchResultDataBase')
4307
+ .mockResolvedValue({});
4308
+
4309
+ await (resultDataProvider as any).fetchResultDataForTestReporter(
4310
+ mockProjectName,
4311
+ 'suite1',
4312
+ { lastRunId: 456, lastResultId: 789, testCaseId: 123 },
4313
+ ['Custom.SortIndex@testCaseWorkItemField'],
4314
+ false,
4315
+ false,
4316
+ false,
4317
+ true
4318
+ );
4319
+
4320
+ expect(fetchResultDataBaseSpy.mock.calls[0][5]).toEqual([
4321
+ ['Custom.SortIndex@testCaseWorkItemField'],
4322
+ false,
4323
+ { lastRunId: 456, lastResultId: 789, testCaseId: 123 },
4324
+ false,
4325
+ false,
4326
+ true,
4327
+ ]);
4328
+ });
4303
4329
  });
4304
4330
 
4305
4331
  describe('fetchResultDataBasedOnWiBase', () => {
@@ -4352,6 +4378,95 @@ describe('ResultDataProvider', () => {
4352
4378
  );
4353
4379
  });
4354
4380
 
4381
+ it('should use latest test case fields for executed points when latest properties mode is enabled', async () => {
4382
+ const point = {
4383
+ testCaseId: '123',
4384
+ testCaseName: 'TC 123',
4385
+ outcome: 'passed',
4386
+ lastRunId: 456,
4387
+ lastResultId: 789,
4388
+ testSuite: { id: '1', name: 'Suite' },
4389
+ };
4390
+
4391
+ (TFSServices.getItemContent as jest.Mock).mockResolvedValueOnce({
4392
+ id: 123,
4393
+ rev: 10,
4394
+ fields: {
4395
+ 'System.State': 'Active',
4396
+ 'System.CreatedDate': '2024-01-01T00:00:00',
4397
+ 'Microsoft.VSTS.TCM.Priority': 1,
4398
+ 'Custom.SortIndex': 3,
4399
+ 'Microsoft.VSTS.TCM.Steps': '<steps></steps>',
4400
+ },
4401
+ relations: null,
4402
+ });
4403
+
4404
+ const selectedFields = ['Custom.SortIndex@testCaseWorkItemField'];
4405
+ const res = await (resultDataProvider as any).fetchResultDataBasedOnWiBase(
4406
+ mockProjectName,
4407
+ '456',
4408
+ '789',
4409
+ true,
4410
+ selectedFields,
4411
+ false,
4412
+ point,
4413
+ false,
4414
+ false,
4415
+ true
4416
+ );
4417
+
4418
+ const calledUrls = (TFSServices.getItemContent as jest.Mock).mock.calls.map((args: any[]) => String(args[0]));
4419
+ expect(calledUrls.some((url: string) => url.includes('/_apis/test/runs/456/results/789'))).toBe(false);
4420
+ expect(calledUrls.some((url: string) => url.includes('/_apis/wit/workItems/123?$expand=all'))).toBe(true);
4421
+ expect(res).toEqual(
4422
+ expect.objectContaining({
4423
+ testCaseRevision: 10,
4424
+ filteredFields: { 'Custom.SortIndex': 3 },
4425
+ })
4426
+ );
4427
+ });
4428
+
4429
+ it('should log latest properties mode when bypassing run revision data', async () => {
4430
+ const point = {
4431
+ testCaseId: '123',
4432
+ testCaseName: 'TC 123',
4433
+ outcome: 'passed',
4434
+ lastRunId: 456,
4435
+ lastResultId: 789,
4436
+ testSuite: { id: '1', name: 'Suite' },
4437
+ };
4438
+
4439
+ (TFSServices.getItemContent as jest.Mock).mockResolvedValueOnce({
4440
+ id: 123,
4441
+ rev: 10,
4442
+ fields: {
4443
+ 'System.State': 'Active',
4444
+ 'System.CreatedDate': '2024-01-01T00:00:00',
4445
+ 'Microsoft.VSTS.TCM.Priority': 1,
4446
+ 'Custom.SortIndex': 3,
4447
+ 'Microsoft.VSTS.TCM.Steps': '<steps></steps>',
4448
+ },
4449
+ relations: null,
4450
+ });
4451
+
4452
+ await (resultDataProvider as any).fetchResultDataBasedOnWiBase(
4453
+ mockProjectName,
4454
+ '456',
4455
+ '789',
4456
+ true,
4457
+ ['Custom.SortIndex@testCaseWorkItemField'],
4458
+ false,
4459
+ point,
4460
+ false,
4461
+ false,
4462
+ true
4463
+ );
4464
+
4465
+ expect(logger.debug).toHaveBeenCalledWith(
4466
+ expect.stringContaining('[TestReporter][LatestProperties] Fetching latest test case work item')
4467
+ );
4468
+ });
4469
+
4355
4470
  it('should fetch no-run test case by suite test-case revision when provided', async () => {
4356
4471
  const point = {
4357
4472
  testCaseId: '123',