@elisra-devops/docgen-data-provider 1.102.0 → 1.104.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.
@@ -894,6 +894,44 @@ describe('ResultDataProvider', () => {
894
894
  });
895
895
  });
896
896
  describe('getMewpL2CoverageFlatResults', () => {
897
+ it('should split SR prefix into SR # + L2 REQ Title while preserving full title', () => {
898
+ const row = resultDataProvider.createMewpCoverageRow({
899
+ workItemId: 5054,
900
+ requirementId: 'SR0054',
901
+ title: 'SR0054 - Engine startup coverage',
902
+ owner: 'ESUK',
903
+ subSystem: 'Propulsion',
904
+ responsibility: 'ESUK',
905
+ }, 'Pass', { id: '', title: '', responsibility: '' }, { l3Id: '', l3Title: '', l4Id: '', l4Title: '' });
906
+ expect(row).toEqual(expect.objectContaining({
907
+ 'L2 REQ ID': '5054',
908
+ 'SR #': 'SR0054',
909
+ 'L2 REQ Title': 'Engine startup coverage',
910
+ 'L2 REQ Full Title': 'SR0054 - Engine startup coverage',
911
+ 'L2 Owner': 'ESUK',
912
+ 'L2 SubSystem': 'Propulsion',
913
+ }));
914
+ });
915
+ it('should keep full title when title is only the SR token', () => {
916
+ const row = resultDataProvider.createMewpCoverageRow({
917
+ workItemId: 9999,
918
+ requirementId: 'SR9999',
919
+ title: 'SR9999',
920
+ owner: 'IL',
921
+ subSystem: '',
922
+ responsibility: 'IL',
923
+ }, 'Not Run', { id: '', title: '', responsibility: '' }, { l3Id: '', l3Title: '', l4Id: '', l4Title: '' });
924
+ expect(row['L2 REQ Title']).toBe('SR9999');
925
+ expect(row['L2 REQ Full Title']).toBe('SR9999');
926
+ expect(row['L2 Owner']).toBe('IL');
927
+ });
928
+ it('should resolve L2 run status precedence: Fail > Not Run > Pass', () => {
929
+ const resolve = resultDataProvider.resolveMewpL2RunStatus.bind(resultDataProvider);
930
+ expect(resolve({ passed: 2, failed: 1, notRun: 3, hasAnyTestCase: true })).toBe('Fail');
931
+ expect(resolve({ passed: 5, failed: 0, notRun: 1, hasAnyTestCase: true })).toBe('Not Run');
932
+ expect(resolve({ passed: 1, failed: 0, notRun: 0, hasAnyTestCase: true })).toBe('Pass');
933
+ expect(resolve({ passed: 0, failed: 0, notRun: 0, hasAnyTestCase: true })).toBe('Not Run');
934
+ });
897
935
  it('should fetch MEWP scoped test data from selected suites', async () => {
898
936
  jest.spyOn(resultDataProvider, 'fetchTestPlanName').mockResolvedValueOnce('Plan A');
899
937
  const scopedSpy = jest
@@ -987,7 +1025,7 @@ describe('ResultDataProvider', () => {
987
1025
  const result = await resultDataProvider.getMewpL2CoverageFlatResults('123', mockProjectName, [1]);
988
1026
  expect(result).toEqual(expect.objectContaining({
989
1027
  sheetName: expect.stringContaining('MEWP L2 Coverage'),
990
- columnOrder: expect.arrayContaining(['L2 REQ ID', 'L2 REQ Title', 'L2 Run Status']),
1028
+ columnOrder: expect.arrayContaining(['L2 REQ ID', 'SR #', 'L2 REQ Title', 'L2 Owner', 'L2 Run Status']),
991
1029
  }));
992
1030
  const covered = result.rows.find((row) => row['L2 REQ ID'] === '5001');
993
1031
  const inferredByStepText = result.rows.find((row) => row['L2 REQ ID'] === '5002');
@@ -2883,6 +2921,81 @@ describe('ResultDataProvider', () => {
2883
2921
  'Validation Status': 'Pass',
2884
2922
  }));
2885
2923
  });
2924
+ it('should prefer latest test-case revision fields (title/description/steps) in internal validation flow', async () => {
2925
+ jest.spyOn(resultDataProvider, 'fetchTestPlanName').mockResolvedValueOnce('Plan A');
2926
+ jest.spyOn(resultDataProvider, 'fetchMewpScopedTestData').mockResolvedValueOnce([
2927
+ {
2928
+ testPointsItems: [{ testCaseId: 777, testCaseName: 'TC 777 (snapshot)' }],
2929
+ testCasesItems: [
2930
+ {
2931
+ workItem: {
2932
+ id: 777,
2933
+ workItemFields: [
2934
+ { key: 'System.Title', value: 'TC 777 (snapshot title)' },
2935
+ {
2936
+ key: 'Microsoft.VSTS.TCM.Steps',
2937
+ value: '<steps><step id="2" type="ActionStep"><parameterizedString isformatted="true">Action</parameterizedString><parameterizedString isformatted="true">SR0001</parameterizedString></step></steps>',
2938
+ },
2939
+ { key: 'System.Description', value: '<p>Snapshot description</p>' },
2940
+ ],
2941
+ },
2942
+ },
2943
+ ],
2944
+ },
2945
+ ]);
2946
+ jest.spyOn(resultDataProvider, 'fetchMewpL2Requirements').mockResolvedValueOnce([
2947
+ {
2948
+ workItemId: 9777,
2949
+ requirementId: 'SR7777',
2950
+ baseKey: 'SR7777',
2951
+ title: 'Req 7777',
2952
+ responsibility: 'ESUK',
2953
+ linkedTestCaseIds: [777],
2954
+ areaPath: 'MEWP\\Customer Requirements\\Level 2',
2955
+ },
2956
+ ]);
2957
+ jest.spyOn(resultDataProvider, 'buildLinkedRequirementsByTestCase').mockResolvedValueOnce(new Map([
2958
+ [
2959
+ 777,
2960
+ {
2961
+ baseKeys: new Set(['SR7777']),
2962
+ fullCodes: new Set(['SR7777']),
2963
+ },
2964
+ ],
2965
+ ]));
2966
+ const fetchWorkItemsByIdsSpy = jest
2967
+ .spyOn(resultDataProvider, 'fetchWorkItemsByIds')
2968
+ .mockResolvedValueOnce([
2969
+ {
2970
+ id: 777,
2971
+ fields: {
2972
+ 'System.Title': 'TC 777 (latest title)',
2973
+ 'System.Description': '<p><b><u>Trial specific assumptions, constraints, dependencies and requirements</u></b></p><p>SR7777</p>',
2974
+ 'Microsoft.VSTS.TCM.Steps': '<steps><step id="2" type="ActionStep"><parameterizedString isformatted="true">Action</parameterizedString><parameterizedString isformatted="true">SR7777</parameterizedString></step></steps>',
2975
+ },
2976
+ },
2977
+ ]);
2978
+ jest.spyOn(resultDataProvider.testStepParserHelper, 'parseTestSteps').mockImplementation(async (...args) => [
2979
+ {
2980
+ stepId: '1',
2981
+ stepPosition: '1',
2982
+ action: 'Action',
2983
+ expected: String((args === null || args === void 0 ? void 0 : args[0]) || '').includes('SR7777') ? 'SR7777' : 'SR0001',
2984
+ isSharedStepTitle: false,
2985
+ },
2986
+ ]);
2987
+ const result = await resultDataProvider.getMewpInternalValidationFlatResults('123', mockProjectName, [1]);
2988
+ expect(fetchWorkItemsByIdsSpy).toHaveBeenCalledWith(mockProjectName, [777], false);
2989
+ expect(resultDataProvider.testStepParserHelper.parseTestSteps).toHaveBeenCalledWith(expect.stringContaining('SR7777'), expect.any(Map));
2990
+ expect(result.rows).toHaveLength(1);
2991
+ expect(result.rows[0]).toEqual(expect.objectContaining({
2992
+ 'Test Case ID': 777,
2993
+ 'Test Case Title': 'TC 777 (latest title)',
2994
+ 'Mentioned but Not Linked': '',
2995
+ 'Linked but Not Mentioned': '',
2996
+ 'Validation Status': 'Pass',
2997
+ }));
2998
+ });
2886
2999
  });
2887
3000
  describe('buildLinkedRequirementsByTestCase', () => {
2888
3001
  it('should map linked requirements only for supported test-case requirement relation types', async () => {