@elisra-devops/docgen-data-provider 1.80.0 → 1.81.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.
@@ -62,17 +62,18 @@ export interface MewpL3L4Link {
62
62
  title: string;
63
63
  level: 'L3' | 'L4';
64
64
  }
65
- export interface MewpCoverageBugCell {
66
- id: number | '';
67
- title: string;
68
- responsibility: string;
69
- }
70
- export interface MewpCoverageL3L4Cell {
65
+ export interface MewpL3L4Pair {
71
66
  l3Id: string;
72
67
  l3Title: string;
73
68
  l4Id: string;
74
69
  l4Title: string;
75
70
  }
71
+ export interface MewpCoverageBugCell {
72
+ id: number | '';
73
+ title: string;
74
+ responsibility: string;
75
+ }
76
+ export type MewpCoverageL3L4Cell = MewpL3L4Pair;
76
77
  export interface MewpCoverageRow {
77
78
  'L2 REQ ID': string;
78
79
  'L2 REQ Title': string;
@@ -761,38 +761,34 @@ class ResultDataProvider {
761
761
  createEmptyMewpCoverageL3L4Cell() {
762
762
  return { l3Id: '', l3Title: '', l4Id: '', l4Title: '' };
763
763
  }
764
- buildMewpCoverageL3L4Rows(links) {
764
+ buildMewpCoverageL3L4Rows(pairs) {
765
765
  const deduped = new Map();
766
- for (const item of links || []) {
767
- const level = (item === null || item === void 0 ? void 0 : item.level) === 'L4' ? 'L4' : 'L3';
768
- const id = String((item === null || item === void 0 ? void 0 : item.id) || '').trim();
769
- if (!id)
766
+ for (const pair of pairs || []) {
767
+ const l3Id = String((pair === null || pair === void 0 ? void 0 : pair.l3Id) || '').trim();
768
+ const l3Title = String((pair === null || pair === void 0 ? void 0 : pair.l3Title) || '').trim();
769
+ const l4Id = String((pair === null || pair === void 0 ? void 0 : pair.l4Id) || '').trim();
770
+ const l4Title = String((pair === null || pair === void 0 ? void 0 : pair.l4Title) || '').trim();
771
+ if (!l3Id && !l4Id)
772
+ continue;
773
+ const key = `${l3Id}|${l4Id}`;
774
+ const existing = deduped.get(key);
775
+ if (!existing) {
776
+ deduped.set(key, { l3Id, l3Title, l4Id, l4Title });
770
777
  continue;
771
- const key = `${level}:${id}`;
772
- if (!deduped.has(key)) {
773
- deduped.set(key, {
774
- id,
775
- level,
776
- title: String((item === null || item === void 0 ? void 0 : item.title) || '').trim(),
777
- });
778
778
  }
779
- }
780
- const sorted = [...deduped.values()].sort((a, b) => {
781
- if (a.level !== b.level)
782
- return a.level === 'L3' ? -1 : 1;
783
- return String(a.id || '').localeCompare(String(b.id || ''));
784
- });
785
- const rows = [];
786
- for (const item of sorted) {
787
- const isL3 = item.level === 'L3';
788
- rows.push({
789
- l3Id: isL3 ? String((item === null || item === void 0 ? void 0 : item.id) || '').trim() : '',
790
- l3Title: isL3 ? String((item === null || item === void 0 ? void 0 : item.title) || '').trim() : '',
791
- l4Id: isL3 ? '' : String((item === null || item === void 0 ? void 0 : item.id) || '').trim(),
792
- l4Title: isL3 ? '' : String((item === null || item === void 0 ? void 0 : item.title) || '').trim(),
779
+ deduped.set(key, {
780
+ l3Id: existing.l3Id || l3Id,
781
+ l3Title: existing.l3Title || l3Title,
782
+ l4Id: existing.l4Id || l4Id,
783
+ l4Title: existing.l4Title || l4Title,
793
784
  });
794
785
  }
795
- return rows;
786
+ return [...deduped.values()].sort((a, b) => {
787
+ const l3Compare = String((a === null || a === void 0 ? void 0 : a.l3Id) || '').localeCompare(String((b === null || b === void 0 ? void 0 : b.l3Id) || ''));
788
+ if (l3Compare !== 0)
789
+ return l3Compare;
790
+ return String((a === null || a === void 0 ? void 0 : a.l4Id) || '').localeCompare(String((b === null || b === void 0 ? void 0 : b.l4Id) || ''));
791
+ });
796
792
  }
797
793
  buildMewpCoverageRows(requirements, requirementIndex, observedTestCaseIdsByRequirement, linkedRequirementsByTestCase, l3l4ByBaseKey, externalBugsByTestCase, externalJoinKeysByL2) {
798
794
  var _a;
@@ -842,19 +838,15 @@ class ResultDataProvider {
842
838
  ? Array.from(aggregatedBugs.values()).sort((a, b) => a.id - b.id)
843
839
  : [];
844
840
  const l3l4ForRows = [...externalJoinKeys].flatMap((joinKey) => l3l4ByBaseKey.get(joinKey) || []);
845
- const bugRows = bugsForRows.length > 0
846
- ? bugsForRows
847
- : [];
841
+ const bugRows = bugsForRows.map((bug) => ({
842
+ id: Number.isFinite(Number(bug === null || bug === void 0 ? void 0 : bug.id)) && Number(bug === null || bug === void 0 ? void 0 : bug.id) > 0 ? Number(bug === null || bug === void 0 ? void 0 : bug.id) : '',
843
+ title: String((bug === null || bug === void 0 ? void 0 : bug.title) || '').trim(),
844
+ responsibility: String((bug === null || bug === void 0 ? void 0 : bug.responsibility) || '').trim(),
845
+ }));
848
846
  const l3l4Rows = this.buildMewpCoverageL3L4Rows(l3l4ForRows);
849
- if (bugRows.length === 0 && l3l4Rows.length === 0) {
850
- rows.push(this.createMewpCoverageRow(requirement, runStatus, this.createEmptyMewpCoverageBugCell(), this.createEmptyMewpCoverageL3L4Cell()));
851
- continue;
852
- }
853
- for (const bug of bugRows) {
854
- rows.push(this.createMewpCoverageRow(requirement, runStatus, bug, this.createEmptyMewpCoverageL3L4Cell()));
855
- }
856
- for (const linkedL3L4 of l3l4Rows) {
857
- rows.push(this.createMewpCoverageRow(requirement, runStatus, this.createEmptyMewpCoverageBugCell(), linkedL3L4));
847
+ const rowCount = Math.max(bugRows.length, l3l4Rows.length, 1);
848
+ for (let index = 0; index < rowCount; index += 1) {
849
+ rows.push(this.createMewpCoverageRow(requirement, runStatus, bugRows[index] || this.createEmptyMewpCoverageBugCell(), l3l4Rows[index] || this.createEmptyMewpCoverageL3L4Cell()));
858
850
  }
859
851
  }
860
852
  return rows;