@elisra-devops/docgen-data-provider 1.88.0 → 1.90.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.
@@ -1083,6 +1083,23 @@ describe('ResultDataProvider', () => {
1083
1083
  });
1084
1084
 
1085
1085
  describe('getMewpL2CoverageFlatResults', () => {
1086
+ it('should fetch MEWP scoped test data from selected suites', async () => {
1087
+ jest.spyOn(resultDataProvider as any, 'fetchTestPlanName').mockResolvedValueOnce('Plan A');
1088
+ const scopedSpy = jest
1089
+ .spyOn(resultDataProvider as any, 'fetchMewpScopedTestData')
1090
+ .mockResolvedValueOnce([]);
1091
+ jest.spyOn(resultDataProvider as any, 'fetchMewpL2Requirements').mockResolvedValueOnce([]);
1092
+
1093
+ await (resultDataProvider as any).getMewpL2CoverageFlatResults(
1094
+ '123',
1095
+ mockProjectName,
1096
+ [1],
1097
+ undefined
1098
+ );
1099
+
1100
+ expect(scopedSpy).toHaveBeenCalledWith('123', mockProjectName, [1]);
1101
+ });
1102
+
1086
1103
  it('should map SR ids from steps and output requirement-test-case coverage rows', async () => {
1087
1104
  jest.spyOn(resultDataProvider as any, 'fetchTestPlanName').mockResolvedValueOnce('Plan A');
1088
1105
  jest.spyOn(resultDataProvider as any, 'fetchTestSuites').mockResolvedValueOnce([{ testSuiteId: 1 }]);
@@ -2545,7 +2562,7 @@ describe('ResultDataProvider', () => {
2545
2562
  expect(byTestCase.get(201)).toEqual(
2546
2563
  expect.objectContaining({
2547
2564
  'Test Case Title': 'TC 201 - Mixed discrepancies',
2548
- 'Mentioned but Not Linked': 'Step 1: SR0095-3; SR0511: SR0511-1, SR0511-2',
2565
+ 'Mentioned but Not Linked': 'Step 1: SR0095-3\nSR0511: SR0511-1, SR0511-2',
2549
2566
  'Linked but Not Mentioned': 'SR8888',
2550
2567
  'Validation Status': 'Fail',
2551
2568
  })
@@ -2799,7 +2816,7 @@ describe('ResultDataProvider', () => {
2799
2816
  'Test Case ID': 42,
2800
2817
  'Test Case Title': 'TC-0042',
2801
2818
  'Mentioned but Not Linked': 'Step 3: SR0027',
2802
- 'Linked but Not Mentioned': 'SR0817; SR0818; SR0859',
2819
+ 'Linked but Not Mentioned': 'SR0817\nSR0818\nSR0859',
2803
2820
  'Validation Status': 'Fail',
2804
2821
  })
2805
2822
  );
@@ -2991,16 +3008,12 @@ describe('ResultDataProvider', () => {
2991
3008
  });
2992
3009
  });
2993
3010
 
2994
- describe('MEWP rel fallback scoping', () => {
2995
- it('should fallback to previous Rel run when latest selected Rel has no run for a test case', async () => {
3011
+ describe('MEWP release snapshot scoping', () => {
3012
+ it('should scope only to selected suites and avoid cross-Rel fallback selection', async () => {
2996
3013
  const suites = [
2997
3014
  { testSuiteId: 10, suiteName: 'Rel10 / Validation' },
2998
3015
  { testSuiteId: 11, suiteName: 'Rel11 / Validation' },
2999
3016
  ];
3000
- const allSuites = [
3001
- { testSuiteId: 10, suiteName: 'Rel10 / Validation' },
3002
- { testSuiteId: 11, suiteName: 'Rel11 / Validation' },
3003
- ];
3004
3017
  const rawTestData = [
3005
3018
  {
3006
3019
  suiteName: 'Rel10 / Validation',
@@ -3022,8 +3035,7 @@ describe('ResultDataProvider', () => {
3022
3035
 
3023
3036
  const fetchSuitesSpy = jest
3024
3037
  .spyOn(resultDataProvider as any, 'fetchTestSuites')
3025
- .mockResolvedValueOnce(suites)
3026
- .mockResolvedValueOnce(allSuites);
3038
+ .mockResolvedValueOnce(suites);
3027
3039
  const fetchDataSpy = jest
3028
3040
  .spyOn(resultDataProvider as any, 'fetchTestData')
3029
3041
  .mockResolvedValueOnce(rawTestData);
@@ -3031,18 +3043,13 @@ describe('ResultDataProvider', () => {
3031
3043
  const scoped = await (resultDataProvider as any).fetchMewpScopedTestData(
3032
3044
  '123',
3033
3045
  mockProjectName,
3034
- [11],
3035
- true
3046
+ [11]
3036
3047
  );
3037
3048
 
3038
- expect(fetchSuitesSpy).toHaveBeenCalledTimes(2);
3049
+ expect(fetchSuitesSpy).toHaveBeenCalledTimes(1);
3050
+ expect(fetchSuitesSpy).toHaveBeenCalledWith('123', mockProjectName, [11], true);
3039
3051
  expect(fetchDataSpy).toHaveBeenCalledTimes(1);
3040
- expect(scoped).toHaveLength(1);
3041
- const selectedPoints = scoped[0].testPointsItems;
3042
- const tc501 = selectedPoints.find((item: any) => item.testCaseId === 501);
3043
- const tc502 = selectedPoints.find((item: any) => item.testCaseId === 502);
3044
- expect(tc501).toEqual(expect.objectContaining({ lastRunId: 100, lastResultId: 200 }));
3045
- expect(tc502).toEqual(expect.objectContaining({ lastRunId: 500, lastResultId: 600 }));
3052
+ expect(scoped).toEqual(rawTestData);
3046
3053
  });
3047
3054
  });
3048
3055
 
@@ -3643,6 +3650,53 @@ describe('ResultDataProvider', () => {
3643
3650
  );
3644
3651
  });
3645
3652
 
3653
+ it('should fetch no-run test case by suite test-case revision when provided', async () => {
3654
+ const point = {
3655
+ testCaseId: '123',
3656
+ testCaseName: 'TC 123',
3657
+ outcome: 'passed',
3658
+ suiteTestCase: {
3659
+ workItem: {
3660
+ id: 123,
3661
+ rev: 9,
3662
+ workItemFields: [{ key: 'Microsoft.VSTS.TCM.Steps', value: '<steps></steps>' }],
3663
+ },
3664
+ },
3665
+ testSuite: { id: '1', name: 'Suite' },
3666
+ };
3667
+
3668
+ (TFSServices.getItemContent as jest.Mock).mockResolvedValueOnce({
3669
+ id: 123,
3670
+ rev: 9,
3671
+ fields: {
3672
+ 'System.State': 'Active',
3673
+ 'System.CreatedDate': '2024-01-01T00:00:00',
3674
+ 'Microsoft.VSTS.TCM.Priority': 1,
3675
+ 'System.Title': 'Title 123',
3676
+ 'Microsoft.VSTS.TCM.Steps': '<steps></steps>',
3677
+ },
3678
+ relations: null,
3679
+ });
3680
+
3681
+ const res = await (resultDataProvider as any).fetchResultDataBasedOnWiBase(
3682
+ mockProjectName,
3683
+ '0',
3684
+ '0',
3685
+ true,
3686
+ [],
3687
+ false,
3688
+ point
3689
+ );
3690
+
3691
+ expect(TFSServices.getItemContent).toHaveBeenCalledWith(
3692
+ expect.stringContaining('/_apis/wit/workItems/123/revisions/9?$expand=all'),
3693
+ mockToken
3694
+ );
3695
+ const calledUrls = (TFSServices.getItemContent as jest.Mock).mock.calls.map((args: any[]) => String(args[0]));
3696
+ expect(calledUrls.some((url: string) => url.includes('?asOf='))).toBe(false);
3697
+ expect(res).toEqual(expect.objectContaining({ testCaseRevision: 9 }));
3698
+ });
3699
+
3646
3700
  it('should append linked relations and filter testCaseWorkItemField when isTestReporter=true and isQueryMode=false', async () => {
3647
3701
  (TFSServices.getItemContent as jest.Mock).mockReset();
3648
3702