@elisra-devops/docgen-data-provider 1.80.0 → 1.82.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,7 +1078,7 @@ describe('ResultDataProvider', () => {
1078
1078
  expect(esuk).toBe('ESUK');
1079
1079
  expect(il).toBe('IL');
1080
1080
  });
1081
- it('should emit additive rows for bugs and L3/L4 links without bug duplication', () => {
1081
+ it('should zip bug rows with L3/L4 pairs and avoid cross-product duplication', () => {
1082
1082
  const requirements = [
1083
1083
  {
1084
1084
  requirementId: 'SR5303',
@@ -1130,22 +1130,81 @@ describe('ResultDataProvider', () => {
1130
1130
  [
1131
1131
  'SR5303',
1132
1132
  [
1133
- { id: '9003', title: 'L3 9003', level: 'L3' },
1134
- { id: '9103', title: 'L4 9103', level: 'L4' },
1133
+ { l3Id: '9003', l3Title: 'L3 9003', l4Id: '9103', l4Title: 'L4 9103' },
1135
1134
  ],
1136
1135
  ],
1137
1136
  ]);
1138
1137
  const rows = resultDataProvider.buildMewpCoverageRows(requirements, requirementIndex, observedTestCaseIdsByRequirement, linkedRequirementsByTestCase, l3l4ByBaseKey, externalBugsByTestCase);
1139
- expect(rows).toHaveLength(4);
1140
- expect(rows.map((row) => row['Bug ID'])).toEqual([10003, 20003, '', '']);
1141
- expect(rows[2]).toEqual(expect.objectContaining({
1138
+ expect(rows).toHaveLength(2);
1139
+ expect(rows.map((row) => row['Bug ID'])).toEqual([10003, 20003]);
1140
+ expect(rows[0]).toEqual(expect.objectContaining({
1142
1141
  'L3 REQ ID': '9003',
1143
- 'L4 REQ ID': '',
1142
+ 'L4 REQ ID': '9103',
1144
1143
  }));
1145
- expect(rows[3]).toEqual(expect.objectContaining({
1144
+ expect(rows[1]).toEqual(expect.objectContaining({
1146
1145
  'L3 REQ ID': '',
1146
+ 'L4 REQ ID': '',
1147
+ }));
1148
+ });
1149
+ it('should drop standalone L3 row when same L3 has one or more L4 links', () => {
1150
+ const requirements = [
1151
+ {
1152
+ requirementId: 'SR5310',
1153
+ baseKey: 'SR5310',
1154
+ title: 'Req 5310',
1155
+ subSystem: 'Power',
1156
+ responsibility: 'ESUK',
1157
+ linkedTestCaseIds: [111],
1158
+ },
1159
+ ];
1160
+ const requirementIndex = new Map([
1161
+ [
1162
+ 'SR5310',
1163
+ new Map([
1164
+ [
1165
+ 111,
1166
+ {
1167
+ passed: 1,
1168
+ failed: 0,
1169
+ notRun: 0,
1170
+ },
1171
+ ],
1172
+ ]),
1173
+ ],
1174
+ ]);
1175
+ const observedTestCaseIdsByRequirement = new Map([
1176
+ ['SR5310', new Set([111])],
1177
+ ]);
1178
+ const linkedRequirementsByTestCase = new Map([
1179
+ [
1180
+ 111,
1181
+ {
1182
+ baseKeys: new Set(['SR5310']),
1183
+ fullCodes: new Set(['SR5310']),
1184
+ bugIds: new Set(),
1185
+ },
1186
+ ],
1187
+ ]);
1188
+ const l3l4ByBaseKey = new Map([
1189
+ [
1190
+ 'SR5310',
1191
+ [
1192
+ { l3Id: '9003', l3Title: 'L3 9003', l4Id: '', l4Title: '' },
1193
+ { l3Id: '9003', l3Title: 'L3 9003', l4Id: '9103', l4Title: 'L4 9103' },
1194
+ { l3Id: '9003', l3Title: 'L3 9003', l4Id: '9104', l4Title: 'L4 9104' },
1195
+ ],
1196
+ ],
1197
+ ]);
1198
+ const rows = resultDataProvider.buildMewpCoverageRows(requirements, requirementIndex, observedTestCaseIdsByRequirement, linkedRequirementsByTestCase, l3l4ByBaseKey, new Map());
1199
+ expect(rows).toHaveLength(2);
1200
+ expect(rows[0]).toEqual(expect.objectContaining({
1201
+ 'L3 REQ ID': '9003',
1147
1202
  'L4 REQ ID': '9103',
1148
1203
  }));
1204
+ expect(rows[1]).toEqual(expect.objectContaining({
1205
+ 'L3 REQ ID': '9003',
1206
+ 'L4 REQ ID': '9104',
1207
+ }));
1149
1208
  });
1150
1209
  it('should not emit bug rows from ADO-linked bug ids when external bugs source is empty', () => {
1151
1210
  const requirements = [
@@ -2142,8 +2201,27 @@ describe('ResultDataProvider', () => {
2142
2201
  ]);
2143
2202
  const map = await resultDataProvider.loadExternalL3L4ByBaseKey(validL3L4Source);
2144
2203
  expect(map.get('SR0001')).toEqual([
2145
- { id: '7002', title: 'L3 Requirement', level: 'L3' },
2146
- { id: '7001', title: 'L4 From Level3 Column', level: 'L4' },
2204
+ { l3Id: '', l3Title: '', l4Id: '7001', l4Title: 'L4 From Level3 Column' },
2205
+ { l3Id: '7002', l3Title: 'L3 Requirement', l4Id: '', l4Title: '' },
2206
+ ]);
2207
+ });
2208
+ it('should emit paired L3+L4 when AREA 34 is Level 4 and both level columns are present', async () => {
2209
+ const mewpExternalTableUtils = resultDataProvider.mewpExternalTableUtils;
2210
+ jest.spyOn(mewpExternalTableUtils, 'loadExternalTableRows').mockResolvedValueOnce([
2211
+ {
2212
+ SR: 'SR0001',
2213
+ 'AREA 34': 'Level 4',
2214
+ 'TargetWorkItemId Level 3': '7401',
2215
+ TargetTitleLevel3: 'L3 In Level4 Row',
2216
+ 'TargetStateLevel 3': 'Active',
2217
+ 'TargetWorkItemIdLevel 4': '8401',
2218
+ TargetTitleLevel4: 'L4 In Level4 Row',
2219
+ 'TargetStateLevel 4': 'Active',
2220
+ },
2221
+ ]);
2222
+ const map = await resultDataProvider.loadExternalL3L4ByBaseKey(validL3L4Source);
2223
+ expect(map.get('SR0001')).toEqual([
2224
+ { l3Id: '7401', l3Title: 'L3 In Level4 Row', l4Id: '8401', l4Title: 'L4 In Level4 Row' },
2147
2225
  ]);
2148
2226
  });
2149
2227
  it('should exclude external open L3/L4 rows when SAPWBS resolves to ESUK', async () => {
@@ -2172,8 +2250,8 @@ describe('ResultDataProvider', () => {
2172
2250
  ]);
2173
2251
  const map = await resultDataProvider.loadExternalL3L4ByBaseKey(validL3L4Source);
2174
2252
  expect(map.get('SR0001')).toEqual([
2175
- { id: '7102', title: 'L3 IL', level: 'L3' },
2176
- { id: '7201', title: 'L4 IL', level: 'L4' },
2253
+ { l3Id: '', l3Title: '', l4Id: '7201', l4Title: 'L4 IL' },
2254
+ { l3Id: '7102', l3Title: 'L3 IL', l4Id: '', l4Title: '' },
2177
2255
  ]);
2178
2256
  });
2179
2257
  it('should fallback L3/L4 SAPWBS exclusion from SR-mapped requirement when row SAPWBS is empty', async () => {
@@ -2201,7 +2279,9 @@ describe('ResultDataProvider', () => {
2201
2279
  ['SR0002', 'IL'],
2202
2280
  ]));
2203
2281
  expect(map.has('SR0001')).toBe(false);
2204
- expect(map.get('SR0002')).toEqual([{ id: '7302', title: 'L3 From IL Requirement', level: 'L3' }]);
2282
+ expect(map.get('SR0002')).toEqual([
2283
+ { l3Id: '7302', l3Title: 'L3 From IL Requirement', l4Id: '', l4Title: '' },
2284
+ ]);
2205
2285
  });
2206
2286
  it('should resolve bug responsibility from AreaPath when SAPWBS is empty', () => {
2207
2287
  const fromEsukAreaPath = resultDataProvider.resolveBugResponsibility({