@elisra-devops/docgen-data-provider 1.98.0 → 1.100.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/bin/modules/ResultDataProvider.d.ts +6 -0
- package/bin/modules/ResultDataProvider.js +86 -12
- package/bin/modules/ResultDataProvider.js.map +1 -1
- package/bin/tests/modules/ResultDataProvider.test.js +224 -1
- package/bin/tests/modules/ResultDataProvider.test.js.map +1 -1
- package/package.json +1 -1
- package/src/modules/ResultDataProvider.ts +105 -12
- package/src/tests/modules/ResultDataProvider.test.ts +256 -1
|
@@ -338,6 +338,12 @@ export default class ResultDataProvider {
|
|
|
338
338
|
* Creates a mapping of iterations by their unique keys.
|
|
339
339
|
*/
|
|
340
340
|
private createIterationsMap;
|
|
341
|
+
/**
|
|
342
|
+
* Builds a stable lookup key for joining points to fetched iteration payloads.
|
|
343
|
+
* Run-backed items are keyed by run/result/testCase, while runless items prefer
|
|
344
|
+
* testPointId to avoid collisions across suites that share the same testCaseId.
|
|
345
|
+
*/
|
|
346
|
+
private buildIterationLookupKey;
|
|
341
347
|
/**
|
|
342
348
|
* Fetches test data for all suites, including test points and test cases.
|
|
343
349
|
*/
|
|
@@ -3498,7 +3498,7 @@ class ResultDataProvider {
|
|
|
3498
3498
|
* @returns An array of detailed result objects, either at the test level or step level, depending on the options.
|
|
3499
3499
|
*/
|
|
3500
3500
|
alignStepsWithIterationsBase(testData, iterations, includeNotRunTestCases, includeItemsWithNoIterations, isTestReporter, options) {
|
|
3501
|
-
var _a, _b, _c;
|
|
3501
|
+
var _a, _b, _c, _d;
|
|
3502
3502
|
const detailedResults = [];
|
|
3503
3503
|
if (!iterations || (iterations === null || iterations === void 0 ? void 0 : iterations.length) === 0) {
|
|
3504
3504
|
return detailedResults;
|
|
@@ -3516,19 +3516,48 @@ class ResultDataProvider {
|
|
|
3516
3516
|
}
|
|
3517
3517
|
}
|
|
3518
3518
|
for (const point of testItem.testPointsItems) {
|
|
3519
|
-
const
|
|
3520
|
-
|
|
3519
|
+
const pointTestCaseId = Number((point === null || point === void 0 ? void 0 : point.testCaseId) || 0);
|
|
3520
|
+
const testCase = testCaseById.get(pointTestCaseId) || {
|
|
3521
|
+
workItem: { id: pointTestCaseId, workItemFields: [] },
|
|
3522
|
+
};
|
|
3523
|
+
if (!Number.isFinite(pointTestCaseId) || pointTestCaseId <= 0)
|
|
3521
3524
|
continue;
|
|
3522
|
-
if (
|
|
3525
|
+
if (!testCaseById.has(pointTestCaseId) && isTestReporter) {
|
|
3526
|
+
logger_1.default.debug(`[RunlessResolver] Missing suite testCase payload for point testCaseId=${String(pointTestCaseId)}; using point fallback for alignment`);
|
|
3527
|
+
}
|
|
3528
|
+
const testCaseWorkItemFields = Array.isArray((_d = testCase === null || testCase === void 0 ? void 0 : testCase.workItem) === null || _d === void 0 ? void 0 : _d.workItemFields)
|
|
3529
|
+
? testCase.workItem.workItemFields
|
|
3530
|
+
: [];
|
|
3531
|
+
if (testCaseWorkItemFields.length === 0) {
|
|
3523
3532
|
logger_1.default.warn(`Could not fetch the steps from WI ${JSON.stringify(testCase.workItem.id)}`);
|
|
3524
3533
|
if (!isTestReporter) {
|
|
3525
3534
|
continue;
|
|
3526
3535
|
}
|
|
3527
3536
|
}
|
|
3528
|
-
const iterationKey =
|
|
3529
|
-
|
|
3530
|
-
:
|
|
3531
|
-
|
|
3537
|
+
const iterationKey = this.buildIterationLookupKey({
|
|
3538
|
+
testCaseId: testCase.workItem.id,
|
|
3539
|
+
lastRunId: point === null || point === void 0 ? void 0 : point.lastRunId,
|
|
3540
|
+
lastResultId: point === null || point === void 0 ? void 0 : point.lastResultId,
|
|
3541
|
+
testPointId: point === null || point === void 0 ? void 0 : point.testPointId,
|
|
3542
|
+
testCaseRevision: this.resolveSuiteTestCaseRevision(testCase) ||
|
|
3543
|
+
this.resolveSuiteTestCaseRevision(point === null || point === void 0 ? void 0 : point.suiteTestCase),
|
|
3544
|
+
});
|
|
3545
|
+
const fallbackRevision = Number(this.resolveSuiteTestCaseRevision(testCase) ||
|
|
3546
|
+
this.resolveSuiteTestCaseRevision(point === null || point === void 0 ? void 0 : point.suiteTestCase) ||
|
|
3547
|
+
0);
|
|
3548
|
+
const fallbackRevisionKey = Number.isFinite(fallbackRevision) && fallbackRevision > 0
|
|
3549
|
+
? this.buildIterationLookupKey({
|
|
3550
|
+
testCaseId: testCase.workItem.id,
|
|
3551
|
+
testCaseRevision: fallbackRevision,
|
|
3552
|
+
})
|
|
3553
|
+
: '';
|
|
3554
|
+
const fallbackCaseOnlyKey = `${testCase.workItem.id}`;
|
|
3555
|
+
const fetchedTestCase = iterationsMap[iterationKey] ||
|
|
3556
|
+
(fallbackRevisionKey && fallbackRevisionKey !== iterationKey
|
|
3557
|
+
? iterationsMap[fallbackRevisionKey]
|
|
3558
|
+
: undefined) ||
|
|
3559
|
+
(iterationKey !== fallbackCaseOnlyKey ? iterationsMap[fallbackCaseOnlyKey] : undefined) ||
|
|
3560
|
+
(includeNotRunTestCases ? testCase : undefined);
|
|
3532
3561
|
// First check if fetchedTestCase exists
|
|
3533
3562
|
if (!fetchedTestCase)
|
|
3534
3563
|
continue;
|
|
@@ -3640,23 +3669,67 @@ class ResultDataProvider {
|
|
|
3640
3669
|
(iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.lastResultId) !== null &&
|
|
3641
3670
|
String(iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.lastResultId).trim() !== '';
|
|
3642
3671
|
if (hasRunIdentifiers) {
|
|
3643
|
-
const key =
|
|
3672
|
+
const key = this.buildIterationLookupKey({
|
|
3673
|
+
testCaseId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.testCaseId,
|
|
3674
|
+
lastRunId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.lastRunId,
|
|
3675
|
+
lastResultId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.lastResultId,
|
|
3676
|
+
testPointId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.testPointId,
|
|
3677
|
+
testCaseRevision: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.testCaseRevision,
|
|
3678
|
+
});
|
|
3644
3679
|
map[key] = iterationItem;
|
|
3645
3680
|
}
|
|
3646
3681
|
else if (includeNotRunTestCases) {
|
|
3647
|
-
const key =
|
|
3682
|
+
const key = this.buildIterationLookupKey({
|
|
3683
|
+
testCaseId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.testCaseId,
|
|
3684
|
+
lastRunId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.lastRunId,
|
|
3685
|
+
lastResultId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.lastResultId,
|
|
3686
|
+
testPointId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.testPointId,
|
|
3687
|
+
testCaseRevision: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.testCaseRevision,
|
|
3688
|
+
});
|
|
3648
3689
|
map[key] = iterationItem;
|
|
3649
3690
|
if (isTestReporter && (iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.iteration)) {
|
|
3650
|
-
logger_1.default.debug(`[RunlessResolver] createIterationsMap: mapped runless testCaseId=${String(iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.testCaseId)} to
|
|
3691
|
+
logger_1.default.debug(`[RunlessResolver] createIterationsMap: mapped runless testCaseId=${String(iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.testCaseId)} to key=${key}`);
|
|
3651
3692
|
}
|
|
3652
3693
|
}
|
|
3653
3694
|
else if ((iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.iteration) && !isTestReporter) {
|
|
3654
|
-
const key =
|
|
3695
|
+
const key = this.buildIterationLookupKey({
|
|
3696
|
+
testCaseId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.testCaseId,
|
|
3697
|
+
lastRunId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.lastRunId,
|
|
3698
|
+
lastResultId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.lastResultId,
|
|
3699
|
+
testPointId: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.testPointId,
|
|
3700
|
+
testCaseRevision: iterationItem === null || iterationItem === void 0 ? void 0 : iterationItem.testCaseRevision,
|
|
3701
|
+
});
|
|
3655
3702
|
map[key] = iterationItem;
|
|
3656
3703
|
}
|
|
3657
3704
|
return map;
|
|
3658
3705
|
}, {});
|
|
3659
3706
|
}
|
|
3707
|
+
/**
|
|
3708
|
+
* Builds a stable lookup key for joining points to fetched iteration payloads.
|
|
3709
|
+
* Run-backed items are keyed by run/result/testCase, while runless items prefer
|
|
3710
|
+
* testPointId to avoid collisions across suites that share the same testCaseId.
|
|
3711
|
+
*/
|
|
3712
|
+
buildIterationLookupKey(input) {
|
|
3713
|
+
const testCaseId = Number((input === null || input === void 0 ? void 0 : input.testCaseId) || 0);
|
|
3714
|
+
const hasRunIdentifiers = (input === null || input === void 0 ? void 0 : input.lastRunId) !== undefined &&
|
|
3715
|
+
(input === null || input === void 0 ? void 0 : input.lastRunId) !== null &&
|
|
3716
|
+
String(input === null || input === void 0 ? void 0 : input.lastRunId).trim() !== '' &&
|
|
3717
|
+
(input === null || input === void 0 ? void 0 : input.lastResultId) !== undefined &&
|
|
3718
|
+
(input === null || input === void 0 ? void 0 : input.lastResultId) !== null &&
|
|
3719
|
+
String(input === null || input === void 0 ? void 0 : input.lastResultId).trim() !== '';
|
|
3720
|
+
if (hasRunIdentifiers) {
|
|
3721
|
+
return `${input === null || input === void 0 ? void 0 : input.lastRunId}-${input === null || input === void 0 ? void 0 : input.lastResultId}-${testCaseId}`;
|
|
3722
|
+
}
|
|
3723
|
+
const testPointId = Number((input === null || input === void 0 ? void 0 : input.testPointId) || 0);
|
|
3724
|
+
if (Number.isFinite(testPointId) && testPointId > 0) {
|
|
3725
|
+
return `point-${testPointId}-${testCaseId}`;
|
|
3726
|
+
}
|
|
3727
|
+
const testCaseRevision = Number((input === null || input === void 0 ? void 0 : input.testCaseRevision) || 0);
|
|
3728
|
+
if (Number.isFinite(testCaseRevision) && testCaseRevision > 0) {
|
|
3729
|
+
return `rev-${testCaseId}-${testCaseRevision}`;
|
|
3730
|
+
}
|
|
3731
|
+
return `${testCaseId}`;
|
|
3732
|
+
}
|
|
3660
3733
|
/**
|
|
3661
3734
|
* Fetches test data for all suites, including test points and test cases.
|
|
3662
3735
|
*/
|
|
@@ -4317,6 +4390,7 @@ class ResultDataProvider {
|
|
|
4317
4390
|
const resultDataResponse = {
|
|
4318
4391
|
testCaseName: `${(_e = (_d = resultData === null || resultData === void 0 ? void 0 : resultData.testCase) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : ''} - ${(_g = (_f = resultData === null || resultData === void 0 ? void 0 : resultData.testCase) === null || _f === void 0 ? void 0 : _f.id) !== null && _g !== void 0 ? _g : ''}`,
|
|
4319
4392
|
testCaseId: (_h = resultData === null || resultData === void 0 ? void 0 : resultData.testCase) === null || _h === void 0 ? void 0 : _h.id,
|
|
4393
|
+
testPointId: point === null || point === void 0 ? void 0 : point.testPointId,
|
|
4320
4394
|
testSuiteName: `${(_k = (_j = resultData === null || resultData === void 0 ? void 0 : resultData.testSuite) === null || _j === void 0 ? void 0 : _j.name) !== null && _k !== void 0 ? _k : ''}`,
|
|
4321
4395
|
testSuiteId,
|
|
4322
4396
|
lastRunId,
|