@elisra-devops/docgen-data-provider 1.85.0 → 1.86.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.
@@ -558,34 +558,56 @@ class ResultDataProvider {
558
558
  diagnostics.testCasesWithoutMentionedCustomerIds += 1;
559
559
  }
560
560
  const mentionedBaseKeys = new Set([...mentionedL2Only].map((code) => this.toRequirementKey(code)).filter((code) => !!code));
561
- const expectedFamilyCodes = new Set();
562
- for (const baseKey of mentionedBaseKeys) {
563
- const familyCodes = requirementFamilies.get(baseKey);
564
- if (familyCodes === null || familyCodes === void 0 ? void 0 : familyCodes.size) {
565
- familyCodes.forEach((code) => expectedFamilyCodes.add(code));
566
- }
567
- else {
568
- for (const code of mentionedL2Only) {
569
- if (this.toRequirementKey(code) === baseKey)
570
- expectedFamilyCodes.add(code);
571
- }
572
- }
573
- }
574
561
  const linkedFullCodesRaw = ((_c = linkedRequirementsByTestCase.get(testCaseId)) === null || _c === void 0 ? void 0 : _c.fullCodes) || new Set();
575
562
  const linkedFullCodes = (scopedRequirementKeys === null || scopedRequirementKeys === void 0 ? void 0 : scopedRequirementKeys.size) && linkedFullCodesRaw.size > 0
576
563
  ? new Set([...linkedFullCodesRaw].filter((code) => scopedRequirementKeys.has(this.toRequirementKey(code))))
577
564
  : linkedFullCodesRaw;
578
565
  const linkedBaseKeys = new Set([...linkedFullCodes].map((code) => this.toRequirementKey(code)).filter((code) => !!code));
579
- const missingMentioned = [...mentionedL2Only].filter((code) => {
566
+ const mentionedCodesByBase = new Map();
567
+ for (const code of mentionedL2Only) {
580
568
  const baseKey = this.toRequirementKey(code);
581
569
  if (!baseKey)
582
- return false;
583
- const hasSpecificSuffix = /-\d+$/.test(code);
584
- if (hasSpecificSuffix)
585
- return !linkedFullCodes.has(code);
586
- return !linkedBaseKeys.has(baseKey);
587
- });
588
- const missingFamily = [...expectedFamilyCodes].filter((code) => !linkedFullCodes.has(code));
570
+ continue;
571
+ if (!mentionedCodesByBase.has(baseKey))
572
+ mentionedCodesByBase.set(baseKey, new Set());
573
+ mentionedCodesByBase.get(baseKey).add(code);
574
+ }
575
+ // Context-based direction A logic:
576
+ // 1) If no member of family is linked -> report only base SR (Step X: SR0054).
577
+ // 2) If family is partially linked -> report only specific missing members.
578
+ // 3) If family fully linked -> report nothing for that family.
579
+ const missingBaseWhenFamilyUncovered = new Set();
580
+ const missingSpecificMentionedNoFamily = new Set();
581
+ const missingFamilyMembers = new Set();
582
+ for (const [baseKey, mentionedCodes] of mentionedCodesByBase.entries()) {
583
+ const familyCodes = requirementFamilies.get(baseKey);
584
+ if (familyCodes === null || familyCodes === void 0 ? void 0 : familyCodes.size) {
585
+ const missingInFamily = [...familyCodes].filter((code) => !linkedFullCodes.has(code));
586
+ if (missingInFamily.length === 0)
587
+ continue;
588
+ const linkedInFamilyCount = familyCodes.size - missingInFamily.length;
589
+ if (linkedInFamilyCount === 0) {
590
+ missingBaseWhenFamilyUncovered.add(baseKey);
591
+ }
592
+ else {
593
+ for (const code of missingInFamily) {
594
+ missingFamilyMembers.add(code);
595
+ }
596
+ }
597
+ continue;
598
+ }
599
+ // Fallback path when family data is unavailable for this base key.
600
+ for (const code of mentionedCodes) {
601
+ const hasSpecificSuffix = /-\d+$/.test(code);
602
+ if (hasSpecificSuffix) {
603
+ if (!linkedFullCodes.has(code))
604
+ missingSpecificMentionedNoFamily.add(code);
605
+ }
606
+ else if (!linkedBaseKeys.has(baseKey)) {
607
+ missingBaseWhenFamilyUncovered.add(baseKey);
608
+ }
609
+ }
610
+ }
589
611
  // Direction B is family-based: if any member of a family is mentioned in Expected Result,
590
612
  // linked members of that same family are not considered "linked but not mentioned".
591
613
  const extraLinked = [...linkedFullCodes].filter((code) => {
@@ -605,13 +627,18 @@ class ResultDataProvider {
605
627
  }
606
628
  mentionedButNotLinkedByStep.get(normalizedStepRef).add(normalizedRequirementId);
607
629
  };
608
- const sortedMissingMentioned = [...new Set(missingMentioned)].sort((a, b) => a.localeCompare(b));
609
- const sortedMissingFamily = [...new Set(missingFamily)].sort((a, b) => a.localeCompare(b));
610
- for (const code of sortedMissingMentioned) {
630
+ const sortedMissingSpecificMentionedNoFamily = [...missingSpecificMentionedNoFamily].sort((a, b) => a.localeCompare(b));
631
+ const sortedMissingBaseWhenFamilyUncovered = [...missingBaseWhenFamilyUncovered].sort((a, b) => a.localeCompare(b));
632
+ const sortedMissingFamilyMembers = [...missingFamilyMembers].sort((a, b) => a.localeCompare(b));
633
+ for (const code of sortedMissingSpecificMentionedNoFamily) {
611
634
  const stepRef = mentionedCodeFirstStep.get(code) || 'Step ?';
612
635
  appendMentionedButNotLinked(code, stepRef);
613
636
  }
614
- for (const code of sortedMissingFamily) {
637
+ for (const baseKey of sortedMissingBaseWhenFamilyUncovered) {
638
+ const stepRef = mentionedBaseFirstStep.get(baseKey) || 'Step ?';
639
+ appendMentionedButNotLinked(baseKey, stepRef);
640
+ }
641
+ for (const code of sortedMissingFamilyMembers) {
615
642
  const baseKey = this.toRequirementKey(code);
616
643
  const stepRef = mentionedBaseFirstStep.get(baseKey) || 'Step ?';
617
644
  appendMentionedButNotLinked(code, stepRef);
@@ -645,7 +672,9 @@ class ResultDataProvider {
645
672
  logger_1.default.debug(`MEWP internal validation parse diagnostics: ` +
646
673
  `testCaseId=${testCaseId} parsedSteps=${executableSteps.length} ` +
647
674
  `stepsWithMentions=${mentionEntries.length} customerIdsFound=${mentionedL2Only.size} ` +
648
- `linkedRequirements=${linkedFullCodes.size} mentionedButNotLinked=${sortedMissingMentioned.length + sortedMissingFamily.length} ` +
675
+ `linkedRequirements=${linkedFullCodes.size} mentionedButNotLinked=${sortedMissingSpecificMentionedNoFamily.length +
676
+ sortedMissingBaseWhenFamilyUncovered.length +
677
+ sortedMissingFamilyMembers.length} ` +
649
678
  `linkedButNotMentioned=${sortedExtraLinked.length} status=${validationStatus} ` +
650
679
  `customerIdSample='${[...mentionedL2Only].slice(0, 5).join(', ')}'`);
651
680
  rows.push({