@elisra-devops/docgen-data-provider 1.81.0 → 1.83.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elisra-devops/docgen-data-provider",
3
- "version": "1.81.0",
3
+ "version": "1.83.0",
4
4
  "description": "A document generator data provider, aimed to retrive data from azure devops",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,7 +16,6 @@ export interface MewpCoverageRequestOptions {
16
16
  useRelFallback?: boolean;
17
17
  externalBugsFile?: MewpExternalFileRef | null;
18
18
  externalL3L4File?: MewpExternalFileRef | null;
19
- mergeDuplicateL2Cells?: boolean;
20
19
  }
21
20
 
22
21
  export interface MewpInternalValidationRequestOptions {
@@ -864,7 +864,13 @@ export default class ResultDataProvider {
864
864
  return !linkedBaseKeys.has(baseKey);
865
865
  });
866
866
  const missingFamily = [...expectedFamilyCodes].filter((code) => !linkedFullCodes.has(code));
867
- const extraLinked = [...linkedFullCodes].filter((code) => !expectedFamilyCodes.has(code));
867
+ // Direction B is family-based: if any member of a family is mentioned in Expected Result,
868
+ // linked members of that same family are not considered "linked but not mentioned".
869
+ const extraLinked = [...linkedFullCodes].filter((code) => {
870
+ const baseKey = this.toRequirementKey(code);
871
+ if (!baseKey) return false;
872
+ return !mentionedBaseKeys.has(baseKey);
873
+ });
868
874
  const mentionedButNotLinkedByStep = new Map<string, Set<string>>();
869
875
  const appendMentionedButNotLinked = (requirementId: string, stepRef: string) => {
870
876
  const normalizedRequirementId = this.normalizeMewpRequirementCodeWithSuffix(requirementId);
@@ -1113,8 +1119,20 @@ export default class ResultDataProvider {
1113
1119
  l4Title: existing.l4Title || l4Title,
1114
1120
  });
1115
1121
  }
1122
+ const normalizedPairs = [...deduped.values()];
1123
+ const l3KeysWithAnyL4 = new Set(
1124
+ normalizedPairs
1125
+ .filter((item) => !!String(item?.l3Id || '').trim() && !!String(item?.l4Id || '').trim())
1126
+ .map((item) => String(item?.l3Id || '').trim().toLowerCase())
1127
+ );
1128
+ const filtered = normalizedPairs.filter((item) => {
1129
+ const l3Id = String(item?.l3Id || '').trim();
1130
+ const l4Id = String(item?.l4Id || '').trim();
1131
+ if (!l3Id || !!l4Id) return true;
1132
+ return !l3KeysWithAnyL4.has(l3Id.toLowerCase());
1133
+ });
1116
1134
 
1117
- return [...deduped.values()].sort((a, b) => {
1135
+ return filtered.sort((a, b) => {
1118
1136
  const l3Compare = String(a?.l3Id || '').localeCompare(String(b?.l3Id || ''));
1119
1137
  if (l3Compare !== 0) return l3Compare;
1120
1138
  return String(a?.l4Id || '').localeCompare(String(b?.l4Id || ''));
@@ -1428,6 +1428,84 @@ describe('ResultDataProvider', () => {
1428
1428
  );
1429
1429
  });
1430
1430
 
1431
+ it('should drop standalone L3 row when same L3 has one or more L4 links', () => {
1432
+ const requirements = [
1433
+ {
1434
+ requirementId: 'SR5310',
1435
+ baseKey: 'SR5310',
1436
+ title: 'Req 5310',
1437
+ subSystem: 'Power',
1438
+ responsibility: 'ESUK',
1439
+ linkedTestCaseIds: [111],
1440
+ },
1441
+ ];
1442
+
1443
+ const requirementIndex = new Map([
1444
+ [
1445
+ 'SR5310',
1446
+ new Map([
1447
+ [
1448
+ 111,
1449
+ {
1450
+ passed: 1,
1451
+ failed: 0,
1452
+ notRun: 0,
1453
+ },
1454
+ ],
1455
+ ]),
1456
+ ],
1457
+ ]);
1458
+
1459
+ const observedTestCaseIdsByRequirement = new Map<string, Set<number>>([
1460
+ ['SR5310', new Set([111])],
1461
+ ]);
1462
+
1463
+ const linkedRequirementsByTestCase = new Map([
1464
+ [
1465
+ 111,
1466
+ {
1467
+ baseKeys: new Set(['SR5310']),
1468
+ fullCodes: new Set(['SR5310']),
1469
+ bugIds: new Set(),
1470
+ },
1471
+ ],
1472
+ ]);
1473
+
1474
+ const l3l4ByBaseKey = new Map([
1475
+ [
1476
+ 'SR5310',
1477
+ [
1478
+ { l3Id: '9003', l3Title: 'L3 9003', l4Id: '', l4Title: '' },
1479
+ { l3Id: '9003', l3Title: 'L3 9003', l4Id: '9103', l4Title: 'L4 9103' },
1480
+ { l3Id: '9003', l3Title: 'L3 9003', l4Id: '9104', l4Title: 'L4 9104' },
1481
+ ],
1482
+ ],
1483
+ ]);
1484
+
1485
+ const rows = (resultDataProvider as any).buildMewpCoverageRows(
1486
+ requirements,
1487
+ requirementIndex,
1488
+ observedTestCaseIdsByRequirement,
1489
+ linkedRequirementsByTestCase,
1490
+ l3l4ByBaseKey,
1491
+ new Map()
1492
+ );
1493
+
1494
+ expect(rows).toHaveLength(2);
1495
+ expect(rows[0]).toEqual(
1496
+ expect.objectContaining({
1497
+ 'L3 REQ ID': '9003',
1498
+ 'L4 REQ ID': '9103',
1499
+ })
1500
+ );
1501
+ expect(rows[1]).toEqual(
1502
+ expect.objectContaining({
1503
+ 'L3 REQ ID': '9003',
1504
+ 'L4 REQ ID': '9104',
1505
+ })
1506
+ );
1507
+ });
1508
+
1431
1509
  it('should not emit bug rows from ADO-linked bug ids when external bugs source is empty', () => {
1432
1510
  const requirements = [
1433
1511
  {
@@ -1825,6 +1903,69 @@ describe('ResultDataProvider', () => {
1825
1903
  );
1826
1904
  });
1827
1905
 
1906
+ it('should not flag linked child as Direction B when parent family is mentioned in Expected Result', async () => {
1907
+ jest.spyOn(resultDataProvider as any, 'fetchTestPlanName').mockResolvedValueOnce('Plan A');
1908
+ jest.spyOn(resultDataProvider as any, 'fetchTestSuites').mockResolvedValueOnce([{ testSuiteId: 1 }]);
1909
+ jest.spyOn(resultDataProvider as any, 'fetchTestData').mockResolvedValueOnce([
1910
+ {
1911
+ testPointsItems: [{ testCaseId: 301, testCaseName: 'TC 301' }],
1912
+ testCasesItems: [
1913
+ {
1914
+ workItem: {
1915
+ id: 301,
1916
+ workItemFields: [{ key: 'Steps', value: '<steps></steps>' }],
1917
+ },
1918
+ },
1919
+ ],
1920
+ },
1921
+ ]);
1922
+ jest.spyOn(resultDataProvider as any, 'fetchMewpL2Requirements').mockResolvedValueOnce([
1923
+ {
1924
+ workItemId: 7001,
1925
+ requirementId: 'SR0054',
1926
+ baseKey: 'SR0054',
1927
+ title: 'Parent 0054',
1928
+ responsibility: 'ESUK',
1929
+ linkedTestCaseIds: [],
1930
+ areaPath: 'MEWP\\Customer Requirements\\Level 2',
1931
+ },
1932
+ ]);
1933
+ jest.spyOn(resultDataProvider as any, 'buildLinkedRequirementsByTestCase').mockResolvedValueOnce(
1934
+ new Map([
1935
+ [
1936
+ 301,
1937
+ {
1938
+ baseKeys: new Set(['SR0054']),
1939
+ fullCodes: new Set(['SR0054-1']),
1940
+ },
1941
+ ],
1942
+ ])
1943
+ );
1944
+ jest.spyOn((resultDataProvider as any).testStepParserHelper, 'parseTestSteps').mockResolvedValueOnce([
1945
+ {
1946
+ stepId: '1',
1947
+ stepPosition: '1',
1948
+ action: '',
1949
+ expected: 'SR0054',
1950
+ isSharedStepTitle: false,
1951
+ },
1952
+ ]);
1953
+
1954
+ const result = await (resultDataProvider as any).getMewpInternalValidationFlatResults(
1955
+ '123',
1956
+ mockProjectName,
1957
+ [1]
1958
+ );
1959
+
1960
+ expect(result.rows).toHaveLength(1);
1961
+ expect(result.rows[0]).toEqual(
1962
+ expect.objectContaining({
1963
+ 'Test Case ID': 301,
1964
+ 'Linked but Not Mentioned': '',
1965
+ })
1966
+ );
1967
+ });
1968
+
1828
1969
  it('should produce one detailed row per test case with correct bidirectional discrepancies', async () => {
1829
1970
  const mockDetailedStepsByTestCase = new Map<number, any[]>([
1830
1971
  [