@elisra-devops/docgen-data-provider 1.76.0 → 1.78.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.
@@ -288,7 +288,7 @@ class ResultDataProvider {
288
288
  * Rows are one Requirement-TestCase pair; uncovered requirements are emitted with empty test-case columns.
289
289
  */
290
290
  async getMewpL2CoverageFlatResults(testPlanId, projectName, selectedSuiteIds, linkedQueryRequest, options) {
291
- var _a;
291
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
292
292
  const defaultPayload = {
293
293
  sheetName: `MEWP L2 Coverage - Plan ${testPlanId}`,
294
294
  columnOrder: [...ResultDataProvider.MEWP_L2_COVERAGE_COLUMNS],
@@ -307,6 +307,29 @@ class ResultDataProvider {
307
307
  const requirementSapWbsByBaseKey = this.buildRequirementSapWbsByBaseKey(allRequirements);
308
308
  const externalBugsByTestCase = await this.loadExternalBugsByTestCase(options === null || options === void 0 ? void 0 : options.externalBugsFile);
309
309
  const externalL3L4ByBaseKey = await this.loadExternalL3L4ByBaseKey(options === null || options === void 0 ? void 0 : options.externalL3L4File, requirementSapWbsByBaseKey);
310
+ const hasExternalBugsFile = !!String(((_a = options === null || options === void 0 ? void 0 : options.externalBugsFile) === null || _a === void 0 ? void 0 : _a.name) ||
311
+ ((_b = options === null || options === void 0 ? void 0 : options.externalBugsFile) === null || _b === void 0 ? void 0 : _b.objectName) ||
312
+ ((_c = options === null || options === void 0 ? void 0 : options.externalBugsFile) === null || _c === void 0 ? void 0 : _c.text) ||
313
+ ((_d = options === null || options === void 0 ? void 0 : options.externalBugsFile) === null || _d === void 0 ? void 0 : _d.url) ||
314
+ '').trim();
315
+ const hasExternalL3L4File = !!String(((_e = options === null || options === void 0 ? void 0 : options.externalL3L4File) === null || _e === void 0 ? void 0 : _e.name) ||
316
+ ((_f = options === null || options === void 0 ? void 0 : options.externalL3L4File) === null || _f === void 0 ? void 0 : _f.objectName) ||
317
+ ((_g = options === null || options === void 0 ? void 0 : options.externalL3L4File) === null || _g === void 0 ? void 0 : _g.text) ||
318
+ ((_h = options === null || options === void 0 ? void 0 : options.externalL3L4File) === null || _h === void 0 ? void 0 : _h.url) ||
319
+ '').trim();
320
+ const externalBugLinksCount = [...externalBugsByTestCase.values()].reduce((sum, items) => sum + (Array.isArray(items) ? items.length : 0), 0);
321
+ const externalL3L4LinksCount = [...externalL3L4ByBaseKey.values()].reduce((sum, items) => sum + (Array.isArray(items) ? items.length : 0), 0);
322
+ logger_1.default.info(`MEWP coverage external ingestion summary: ` +
323
+ `bugsFileProvided=${hasExternalBugsFile} bugsTestCases=${externalBugsByTestCase.size} bugsLinks=${externalBugLinksCount}; ` +
324
+ `l3l4FileProvided=${hasExternalL3L4File} l3l4BaseKeys=${externalL3L4ByBaseKey.size} l3l4Links=${externalL3L4LinksCount}`);
325
+ if (hasExternalBugsFile && externalBugLinksCount === 0) {
326
+ logger_1.default.warn(`MEWP coverage: external bugs file was provided but produced 0 links. ` +
327
+ `Check SR/test-case/state values in ingestion logs.`);
328
+ }
329
+ if (hasExternalL3L4File && externalL3L4LinksCount === 0) {
330
+ logger_1.default.warn(`MEWP coverage: external L3/L4 file was provided but produced 0 links. ` +
331
+ `Check SR/AREA34/state/SAPWBS filters in ingestion logs.`);
332
+ }
310
333
  if (requirements.length === 0) {
311
334
  return Object.assign(Object.assign({}, defaultPayload), { sheetName: this.buildMewpCoverageSheetName(planName, testPlanId) });
312
335
  }
@@ -324,7 +347,7 @@ class ResultDataProvider {
324
347
  const runResults = await this.fetchAllResultDataTestReporter(testData, projectName, [], false, false);
325
348
  for (const runResult of runResults) {
326
349
  const testCaseId = this.extractMewpTestCaseId(runResult);
327
- const rawActionResults = Array.isArray((_a = runResult === null || runResult === void 0 ? void 0 : runResult.iteration) === null || _a === void 0 ? void 0 : _a.actionResults)
350
+ const rawActionResults = Array.isArray((_j = runResult === null || runResult === void 0 ? void 0 : runResult.iteration) === null || _j === void 0 ? void 0 : _j.actionResults)
328
351
  ? runResult.iteration.actionResults.filter((item) => !(item === null || item === void 0 ? void 0 : item.isSharedStepTitle))
329
352
  : [];
330
353
  const actionResults = rawActionResults.sort((a, b) => this.compareActionResults(String((a === null || a === void 0 ? void 0 : a.stepPosition) || (a === null || a === void 0 ? void 0 : a.stepIdentifier) || ''), String((b === null || b === void 0 ? void 0 : b.stepPosition) || (b === null || b === void 0 ? void 0 : b.stepIdentifier) || '')));
@@ -358,7 +381,71 @@ class ResultDataProvider {
358
381
  }));
359
382
  this.accumulateRequirementCountsFromActionResults(fallbackActionResults, testCaseId, requirementKeys, requirementIndex, observedTestCaseIdsByRequirement);
360
383
  }
384
+ const requirementBaseKeys = new Set(requirements.map((item) => String((item === null || item === void 0 ? void 0 : item.baseKey) || '').trim()).filter((item) => !!item));
385
+ const externalL3L4BaseKeys = new Set([...externalL3L4ByBaseKey.keys()]);
386
+ const externalL3L4OverlapKeys = [...externalL3L4BaseKeys].filter((key) => requirementBaseKeys.has(key));
387
+ const failedRequirementBaseKeys = new Set();
388
+ const failedTestCaseIds = new Set();
389
+ for (const [requirementBaseKey, byTestCase] of requirementIndex.entries()) {
390
+ for (const [testCaseId, counts] of byTestCase.entries()) {
391
+ if (Number((counts === null || counts === void 0 ? void 0 : counts.failed) || 0) > 0) {
392
+ failedRequirementBaseKeys.add(requirementBaseKey);
393
+ failedTestCaseIds.add(testCaseId);
394
+ }
395
+ }
396
+ }
397
+ const externalBugTestCaseIds = new Set([...externalBugsByTestCase.keys()]);
398
+ const externalBugFailedTestCaseOverlap = [...externalBugTestCaseIds].filter((id) => failedTestCaseIds.has(id));
399
+ const externalBugBaseKeys = new Set();
400
+ for (const bugs of externalBugsByTestCase.values()) {
401
+ for (const bug of bugs || []) {
402
+ const key = String((bug === null || bug === void 0 ? void 0 : bug.requirementBaseKey) || '').trim();
403
+ if (key)
404
+ externalBugBaseKeys.add(key);
405
+ }
406
+ }
407
+ const externalBugRequirementOverlap = [...externalBugBaseKeys].filter((key) => requirementBaseKeys.has(key));
408
+ const externalBugFailedRequirementOverlap = [...externalBugBaseKeys].filter((key) => failedRequirementBaseKeys.has(key));
409
+ logger_1.default.info(`MEWP coverage join diagnostics: requirementBaseKeys=${requirementBaseKeys.size} ` +
410
+ `failedRequirementBaseKeys=${failedRequirementBaseKeys.size} failedTestCases=${failedTestCaseIds.size}; ` +
411
+ `externalL3L4BaseKeys=${externalL3L4BaseKeys.size} externalL3L4Overlap=${externalL3L4OverlapKeys.length}; ` +
412
+ `externalBugTestCases=${externalBugTestCaseIds.size} externalBugFailedTestCaseOverlap=${externalBugFailedTestCaseOverlap.length}; ` +
413
+ `externalBugBaseKeys=${externalBugBaseKeys.size} externalBugRequirementOverlap=${externalBugRequirementOverlap.length} ` +
414
+ `externalBugFailedRequirementOverlap=${externalBugFailedRequirementOverlap.length}`);
415
+ if (externalL3L4BaseKeys.size > 0 && externalL3L4OverlapKeys.length === 0) {
416
+ const sampleReq = [...requirementBaseKeys].slice(0, 5);
417
+ const sampleExt = [...externalL3L4BaseKeys].slice(0, 5);
418
+ logger_1.default.warn(`MEWP coverage join diagnostics: no L3/L4 key overlap found. ` +
419
+ `sampleRequirementKeys=${sampleReq.join(', ')} sampleExternalL3L4Keys=${sampleExt.join(', ')}`);
420
+ }
421
+ if (externalBugBaseKeys.size > 0 && externalBugRequirementOverlap.length === 0) {
422
+ const sampleReq = [...requirementBaseKeys].slice(0, 5);
423
+ const sampleExt = [...externalBugBaseKeys].slice(0, 5);
424
+ logger_1.default.warn(`MEWP coverage join diagnostics: no bug requirement-key overlap found. ` +
425
+ `sampleRequirementKeys=${sampleReq.join(', ')} sampleExternalBugKeys=${sampleExt.join(', ')}`);
426
+ }
427
+ if (externalBugTestCaseIds.size > 0 && externalBugFailedTestCaseOverlap.length === 0) {
428
+ logger_1.default.warn(`MEWP coverage join diagnostics: no overlap between external bug test cases and failed test cases. ` +
429
+ `Bug rows remain empty because bugs are shown only for failed L2s.`);
430
+ }
361
431
  const rows = this.buildMewpCoverageRows(requirements, requirementIndex, observedTestCaseIdsByRequirement, linkedRequirementsByTestCase, externalL3L4ByBaseKey, externalBugsByTestCase);
432
+ const coverageRowStats = rows.reduce((acc, row) => {
433
+ const hasBug = Number((row === null || row === void 0 ? void 0 : row['Bug ID']) || 0) > 0;
434
+ const hasL3 = String((row === null || row === void 0 ? void 0 : row['L3 REQ ID']) || '').trim() !== '';
435
+ const hasL4 = String((row === null || row === void 0 ? void 0 : row['L4 REQ ID']) || '').trim() !== '';
436
+ if (hasBug)
437
+ acc.bugRows += 1;
438
+ if (hasL3)
439
+ acc.l3Rows += 1;
440
+ if (hasL4)
441
+ acc.l4Rows += 1;
442
+ if (!hasBug && !hasL3 && !hasL4)
443
+ acc.baseOnlyRows += 1;
444
+ return acc;
445
+ }, { bugRows: 0, l3Rows: 0, l4Rows: 0, baseOnlyRows: 0 });
446
+ logger_1.default.info(`MEWP coverage output summary: requirements=${requirements.length} rows=${rows.length} ` +
447
+ `bugRows=${coverageRowStats.bugRows} l3Rows=${coverageRowStats.l3Rows} ` +
448
+ `l4Rows=${coverageRowStats.l4Rows} baseOnlyRows=${coverageRowStats.baseOnlyRows}`);
362
449
  return {
363
450
  sheetName: this.buildMewpCoverageSheetName(planName, testPlanId),
364
451
  columnOrder: [...ResultDataProvider.MEWP_L2_COVERAGE_COLUMNS],