@elisra-devops/docgen-data-provider 1.83.0 → 1.85.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.
@@ -1078,6 +1078,67 @@ describe('ResultDataProvider', () => {
1078
1078
  expect(esuk).toBe('ESUK');
1079
1079
  expect(il).toBe('IL');
1080
1080
  });
1081
+ it('should derive responsibility from Area Path alias when System.AreaPath is missing', () => {
1082
+ const esuk = resultDataProvider.deriveMewpResponsibility({
1083
+ 'Custom.SAPWBS': '',
1084
+ 'Area Path': 'MEWP\\Customer Requirements\\Level 2\\ATP\\ESUK',
1085
+ });
1086
+ const il = resultDataProvider.deriveMewpResponsibility({
1087
+ 'Custom.SAPWBS': '',
1088
+ 'Area Path': 'MEWP\\Customer Requirements\\Level 2\\ATP',
1089
+ });
1090
+ expect(esuk).toBe('ESUK');
1091
+ expect(il).toBe('IL');
1092
+ });
1093
+ it('should derive test-case responsibility from testCasesItems area-path fields', async () => {
1094
+ const fetchByIdsSpy = jest
1095
+ .spyOn(resultDataProvider, 'fetchWorkItemsByIds')
1096
+ .mockResolvedValue([]);
1097
+ const map = await resultDataProvider.buildMewpTestCaseResponsibilityMap([
1098
+ {
1099
+ testCasesItems: [
1100
+ {
1101
+ workItem: {
1102
+ id: 101,
1103
+ workItemFields: [{ name: 'Area Path', value: 'MEWP\\Customer Requirements\\Level 2\\ATP' }],
1104
+ },
1105
+ },
1106
+ {
1107
+ workItem: {
1108
+ id: 102,
1109
+ workItemFields: [
1110
+ { referenceName: 'System.AreaPath', value: 'MEWP\\Customer Requirements\\Level 2\\ATP\\ESUK' },
1111
+ ],
1112
+ },
1113
+ },
1114
+ ],
1115
+ testPointsItems: [],
1116
+ },
1117
+ ], mockProjectName);
1118
+ expect(map.get(101)).toBe('IL');
1119
+ expect(map.get(102)).toBe('ESUK');
1120
+ expect(fetchByIdsSpy).not.toHaveBeenCalled();
1121
+ });
1122
+ it('should derive test-case responsibility from AreaPath even when SAPWBS exists on test-case payload', async () => {
1123
+ jest.spyOn(resultDataProvider, 'fetchWorkItemsByIds').mockResolvedValue([]);
1124
+ const map = await resultDataProvider.buildMewpTestCaseResponsibilityMap([
1125
+ {
1126
+ testCasesItems: [
1127
+ {
1128
+ workItem: {
1129
+ id: 201,
1130
+ workItemFields: [
1131
+ { referenceName: 'Custom.SAPWBS', value: 'ESUK' },
1132
+ { referenceName: 'System.AreaPath', value: 'MEWP\\Customer Requirements\\Level 2\\ATP' },
1133
+ ],
1134
+ },
1135
+ },
1136
+ ],
1137
+ testPointsItems: [],
1138
+ },
1139
+ ], mockProjectName);
1140
+ expect(map.get(201)).toBe('IL');
1141
+ });
1081
1142
  it('should zip bug rows with L3/L4 pairs and avoid cross-product duplication', () => {
1082
1143
  const requirements = [
1083
1144
  {
@@ -1309,6 +1370,62 @@ describe('ResultDataProvider', () => {
1309
1370
  expect(rows[0]['Bug ID']).toBe(99001);
1310
1371
  expect(rows[0]['Bug Responsibility']).toBe('Elisra');
1311
1372
  });
1373
+ it('should fallback bug responsibility from test case mapping when external bug row is unknown', () => {
1374
+ const requirements = [
1375
+ {
1376
+ requirementId: 'SR5310',
1377
+ baseKey: 'SR5310',
1378
+ title: 'Req 5310',
1379
+ subSystem: 'Power',
1380
+ responsibility: '',
1381
+ linkedTestCaseIds: [101],
1382
+ },
1383
+ ];
1384
+ const requirementIndex = new Map([
1385
+ [
1386
+ 'SR5310',
1387
+ new Map([
1388
+ [
1389
+ 101,
1390
+ {
1391
+ passed: 0,
1392
+ failed: 1,
1393
+ notRun: 0,
1394
+ },
1395
+ ],
1396
+ ]),
1397
+ ],
1398
+ ]);
1399
+ const observedTestCaseIdsByRequirement = new Map([
1400
+ ['SR5310', new Set([101])],
1401
+ ]);
1402
+ const linkedRequirementsByTestCase = new Map([
1403
+ [
1404
+ 101,
1405
+ {
1406
+ baseKeys: new Set(['SR5310']),
1407
+ fullCodes: new Set(['SR5310']),
1408
+ bugIds: new Set([10003]),
1409
+ },
1410
+ ],
1411
+ ]);
1412
+ const externalBugsByTestCase = new Map([
1413
+ [
1414
+ 101,
1415
+ [
1416
+ {
1417
+ id: 10003,
1418
+ title: 'Bug 10003',
1419
+ responsibility: 'Unknown',
1420
+ requirementBaseKey: 'SR5310',
1421
+ },
1422
+ ],
1423
+ ],
1424
+ ]);
1425
+ const rows = resultDataProvider.buildMewpCoverageRows(requirements, requirementIndex, observedTestCaseIdsByRequirement, linkedRequirementsByTestCase, new Map(), externalBugsByTestCase, new Map(), new Map([[101, 'IL']]));
1426
+ expect(rows).toHaveLength(1);
1427
+ expect(rows[0]['Bug Responsibility']).toBe('Elisra');
1428
+ });
1312
1429
  });
1313
1430
  describe('getMewpInternalValidationFlatResults', () => {
1314
1431
  it('should skip test cases with no in-scope expected requirements and no linked requirements', async () => {
@@ -2028,6 +2145,68 @@ describe('ResultDataProvider', () => {
2028
2145
  expect(String(result.rows[0]['Mentioned but Not Linked'] || '')).not.toContain('VVRM');
2029
2146
  expect(String(result.rows[0]['Linked but Not Mentioned'] || '')).not.toContain('VVRM');
2030
2147
  });
2148
+ it('should fallback to work-item fields for steps XML when suite payload has no workItemFields', async () => {
2149
+ jest.spyOn(resultDataProvider, 'fetchTestPlanName').mockResolvedValueOnce('Plan A');
2150
+ jest.spyOn(resultDataProvider, 'fetchMewpScopedTestData').mockResolvedValueOnce([
2151
+ {
2152
+ testPointsItems: [{ testCaseId: 501, testCaseName: 'TC 501' }],
2153
+ testCasesItems: [
2154
+ {
2155
+ workItem: {
2156
+ id: 501,
2157
+ workItemFields: [],
2158
+ },
2159
+ },
2160
+ ],
2161
+ },
2162
+ ]);
2163
+ jest.spyOn(resultDataProvider, 'fetchMewpL2Requirements').mockResolvedValueOnce([
2164
+ {
2165
+ workItemId: 9001,
2166
+ requirementId: 'SR0501',
2167
+ baseKey: 'SR0501',
2168
+ title: 'Req 501',
2169
+ responsibility: 'ESUK',
2170
+ linkedTestCaseIds: [501],
2171
+ areaPath: 'MEWP\\Customer Requirements\\Level 2',
2172
+ },
2173
+ ]);
2174
+ jest.spyOn(resultDataProvider, 'buildLinkedRequirementsByTestCase').mockResolvedValueOnce(new Map([
2175
+ [
2176
+ 501,
2177
+ {
2178
+ baseKeys: new Set(['SR0501']),
2179
+ fullCodes: new Set(['SR0501']),
2180
+ },
2181
+ ],
2182
+ ]));
2183
+ jest.spyOn(resultDataProvider, 'fetchWorkItemsByIds').mockResolvedValueOnce([
2184
+ {
2185
+ id: 501,
2186
+ fields: {
2187
+ 'Microsoft.VSTS.TCM.Steps': '<steps><step id="2" type="ActionStep"><parameterizedString isformatted="true">Action</parameterizedString><parameterizedString isformatted="true">SR0501</parameterizedString></step></steps>',
2188
+ },
2189
+ },
2190
+ ]);
2191
+ jest.spyOn(resultDataProvider.testStepParserHelper, 'parseTestSteps').mockResolvedValueOnce([
2192
+ {
2193
+ stepId: '1',
2194
+ stepPosition: '1',
2195
+ action: 'Action',
2196
+ expected: 'SR0501',
2197
+ isSharedStepTitle: false,
2198
+ },
2199
+ ]);
2200
+ const result = await resultDataProvider.getMewpInternalValidationFlatResults('123', mockProjectName, [1]);
2201
+ expect(resultDataProvider.fetchWorkItemsByIds).toHaveBeenCalled();
2202
+ expect(result.rows).toHaveLength(1);
2203
+ expect(result.rows[0]).toEqual(expect.objectContaining({
2204
+ 'Test Case ID': 501,
2205
+ 'Mentioned but Not Linked': '',
2206
+ 'Linked but Not Mentioned': '',
2207
+ 'Validation Status': 'Pass',
2208
+ }));
2209
+ });
2031
2210
  });
2032
2211
  describe('MEWP rel fallback scoping', () => {
2033
2212
  it('should fallback to previous Rel run when latest selected Rel has no run for a test case', async () => {
@@ -2216,6 +2395,36 @@ describe('ResultDataProvider', () => {
2216
2395
  responsibility: 'ESUK',
2217
2396
  }));
2218
2397
  });
2398
+ it('should resolve external bug responsibility from AreaPath columns when SAPWBS is empty', async () => {
2399
+ const mewpExternalTableUtils = resultDataProvider.mewpExternalTableUtils;
2400
+ jest.spyOn(mewpExternalTableUtils, 'loadExternalTableRows').mockResolvedValueOnce([
2401
+ {
2402
+ Elisra_SortIndex: '101',
2403
+ SR: 'SR0001',
2404
+ TargetWorkItemId: '9011',
2405
+ Title: 'Bug from ATP\\ESUK path',
2406
+ TargetState: 'Active',
2407
+ SAPWBS: '',
2408
+ AreaPath: 'MEWP\\Customer Requirements\\Level 2\\ATP\\ESUK',
2409
+ },
2410
+ {
2411
+ Elisra_SortIndex: '102',
2412
+ SR: 'SR0002',
2413
+ TargetWorkItemId: '9012',
2414
+ Title: 'Bug from ATP path',
2415
+ TargetState: 'Active',
2416
+ SAPWBS: '',
2417
+ 'System.AreaPath': 'MEWP\\Customer Requirements\\Level 2\\ATP',
2418
+ },
2419
+ ]);
2420
+ const map = await resultDataProvider.loadExternalBugsByTestCase(validBugsSource);
2421
+ const bugs101 = map.get(101) || [];
2422
+ const bugs102 = map.get(102) || [];
2423
+ expect(bugs101).toHaveLength(1);
2424
+ expect(bugs102).toHaveLength(1);
2425
+ expect(bugs101[0].responsibility).toBe('ESUK');
2426
+ expect(bugs102[0].responsibility).toBe('Elisra');
2427
+ });
2219
2428
  it('should require Elisra_SortIndex and ignore rows that only provide WorkItemId', async () => {
2220
2429
  const mewpExternalTableUtils = resultDataProvider.mewpExternalTableUtils;
2221
2430
  jest.spyOn(mewpExternalTableUtils, 'loadExternalTableRows').mockResolvedValueOnce([