@elisra-devops/docgen-data-provider 1.35.0 → 1.36.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.
@@ -472,6 +472,7 @@ class ResultDataProvider {
472
472
  testCaseUrl: `${this.orgUrl}${projectName}/_workitems/edit/${testPoint.testCaseReference.id}`,
473
473
  configurationName: (_a = testPoint.configuration) === null || _a === void 0 ? void 0 : _a.name,
474
474
  outcome: ((_b = testPoint.results) === null || _b === void 0 ? void 0 : _b.outcome) || 'Not Run',
475
+ testSuite: testPoint.testSuite,
475
476
  lastRunId: (_c = testPoint.results) === null || _c === void 0 ? void 0 : _c.lastTestRunId,
476
477
  lastResultId: (_d = testPoint.results) === null || _d === void 0 ? void 0 : _d.lastResultId,
477
478
  lastResultDetails: (_e = testPoint.results) === null || _e === void 0 ? void 0 : _e.lastResultDetails,
@@ -486,6 +487,7 @@ class ResultDataProvider {
486
487
  testCaseId: testPoint.testCase.id,
487
488
  testCaseName: testPoint.testCase.name,
488
489
  testCaseUrl: `${this.orgUrl}${projectName}/_workitems/edit/${testPoint.testCase.id}`,
490
+ testSuite: testPoint.testSuite,
489
491
  configurationName: (_a = testPoint.configuration) === null || _a === void 0 ? void 0 : _a.name,
490
492
  outcome: testPoint.outcome || 'Not Run',
491
493
  lastRunId: (_b = testPoint.lastTestRun) === null || _b === void 0 ? void 0 : _b.id,
@@ -529,12 +531,61 @@ class ResultDataProvider {
529
531
  * @param isQueryMode - (Optional) A flag indicating whether the result data is being fetched in query mode.
530
532
  * @returns A promise that resolves to the fetched result data.
531
533
  */
532
- async fetchResultDataBasedOnWiBase(projectName, runId, resultId, isTestReporter = false, selectedFields, isQueryMode) {
533
- var _a, _b;
534
+ async fetchResultDataBasedOnWiBase(projectName, runId, resultId, isTestReporter = false, selectedFields, isQueryMode, point) {
535
+ var _a, _b, _c, _d, _e, _f, _g;
534
536
  try {
537
+ let filteredFields = {};
538
+ let relatedRequirements = [];
539
+ let relatedBugs = [];
540
+ let relatedCRs = [];
535
541
  if (runId === '0' || resultId === '0') {
536
- logger_1.default.warn(`Invalid runId or resultId: ${runId}, ${resultId}`);
537
- return null;
542
+ if (!point) {
543
+ logger_1.default.warn(`Invalid run result ${runId} or result ${resultId}`);
544
+ return null;
545
+ }
546
+ logger_1.default.warn(`Current Test point for Test case ${point.testCaseId} is in Active state`);
547
+ const url = `${this.orgUrl}${projectName}/_apis/wit/workItems/${point.testCaseId}?$expand=all`;
548
+ const testCaseData = await tfs_1.TFSServices.getItemContent(url, this.token);
549
+ const newResultData = {
550
+ id: 0,
551
+ outcome: point.outcome,
552
+ revision: (testCaseData === null || testCaseData === void 0 ? void 0 : testCaseData.rev) || 1,
553
+ testCase: { id: point.testCaseId, name: point.testCaseName },
554
+ state: ((_a = testCaseData === null || testCaseData === void 0 ? void 0 : testCaseData.fields) === null || _a === void 0 ? void 0 : _a['System.State']) || 'Active',
555
+ priority: ((_b = testCaseData === null || testCaseData === void 0 ? void 0 : testCaseData.fields) === null || _b === void 0 ? void 0 : _b['Microsoft.VSTS.TCM.Priority']) || 0,
556
+ createdDate: ((_c = testCaseData === null || testCaseData === void 0 ? void 0 : testCaseData.fields) === null || _c === void 0 ? void 0 : _c['System.CreatedDate']) || '0001-01-01T00:00:00',
557
+ testSuite: point.testSuite,
558
+ failureType: 'None',
559
+ };
560
+ if (isQueryMode) {
561
+ this.appendQueryRelations(point.testCaseId, relatedRequirements, relatedBugs, relatedCRs);
562
+ }
563
+ else {
564
+ const filteredLinkedFields = (_d = selectedFields === null || selectedFields === void 0 ? void 0 : selectedFields.filter((field) => field.includes('@linked'))) === null || _d === void 0 ? void 0 : _d.map((field) => field.split('@')[0]);
565
+ const selectedLinkedFieldSet = new Set(filteredLinkedFields);
566
+ const { relations } = testCaseData;
567
+ if (relations) {
568
+ await this.appendLinkedRelations(relations, relatedRequirements, relatedBugs, relatedCRs, testCaseData, selectedLinkedFieldSet);
569
+ }
570
+ selectedLinkedFieldSet.clear();
571
+ }
572
+ const filteredTestCaseFields = (_e = selectedFields === null || selectedFields === void 0 ? void 0 : selectedFields.filter((field) => field.includes('@testCaseWorkItemField'))) === null || _e === void 0 ? void 0 : _e.map((field) => field.split('@')[0]);
573
+ const selectedFieldSet = new Set(filteredTestCaseFields);
574
+ // Filter fields based on selected field set
575
+ if (selectedFieldSet.size !== 0) {
576
+ filteredFields = Object.keys(testCaseData.fields)
577
+ .filter((key) => selectedFieldSet.has(key))
578
+ .reduce((obj, key) => {
579
+ var _a, _b;
580
+ obj[key] = (_b = (_a = testCaseData.fields[key]) === null || _a === void 0 ? void 0 : _a.displayName) !== null && _b !== void 0 ? _b : testCaseData.fields[key];
581
+ return obj;
582
+ }, {});
583
+ }
584
+ selectedFieldSet.clear();
585
+ return Object.assign(Object.assign({}, newResultData), { stepsResultXml: testCaseData.fields['Microsoft.VSTS.TCM.Steps'] || undefined, testCaseRevision: testCaseData.rev, filteredFields,
586
+ relatedRequirements,
587
+ relatedBugs,
588
+ relatedCRs });
538
589
  }
539
590
  const url = `${this.orgUrl}${projectName}/_apis/test/runs/${runId}/results/${resultId}?detailsToInclude=Iterations`;
540
591
  const resultData = await tfs_1.TFSServices.getItemContent(url, this.token);
@@ -544,18 +595,14 @@ class ResultDataProvider {
544
595
  const expandParam = isTestReporter ? '?$expand=all' : '';
545
596
  const wiUrl = `${this.orgUrl}${projectName}/_apis/wit/workItems/${resultData.testCase.id}/revisions/${resultData.testCaseRevision}${expandParam}`;
546
597
  const wiByRevision = await tfs_1.TFSServices.getItemContent(wiUrl, this.token);
547
- let filteredFields = {};
548
- let relatedRequirements = [];
549
- let relatedBugs = [];
550
- let relatedCRs = [];
551
598
  // Process selected fields if provided
552
599
  if (isTestReporter) {
553
600
  // Process related requirements if needed
554
601
  if (isQueryMode) {
555
- this.appendQueryRelations(resultData, relatedRequirements, relatedBugs, relatedCRs);
602
+ this.appendQueryRelations(resultData.testCase.id, relatedRequirements, relatedBugs, relatedCRs);
556
603
  }
557
604
  else {
558
- const filteredLinkedFields = (_a = selectedFields === null || selectedFields === void 0 ? void 0 : selectedFields.filter((field) => field.includes('@linked'))) === null || _a === void 0 ? void 0 : _a.map((field) => field.split('@')[0]);
605
+ const filteredLinkedFields = (_f = selectedFields === null || selectedFields === void 0 ? void 0 : selectedFields.filter((field) => field.includes('@linked'))) === null || _f === void 0 ? void 0 : _f.map((field) => field.split('@')[0]);
559
606
  const selectedLinkedFieldSet = new Set(filteredLinkedFields);
560
607
  const { relations } = wiByRevision;
561
608
  if (relations) {
@@ -563,7 +610,7 @@ class ResultDataProvider {
563
610
  }
564
611
  selectedLinkedFieldSet.clear();
565
612
  }
566
- const filteredTestCaseFields = (_b = selectedFields === null || selectedFields === void 0 ? void 0 : selectedFields.filter((field) => field.includes('@testCaseWorkItemField'))) === null || _b === void 0 ? void 0 : _b.map((field) => field.split('@')[0]);
613
+ const filteredTestCaseFields = (_g = selectedFields === null || selectedFields === void 0 ? void 0 : selectedFields.filter((field) => field.includes('@testCaseWorkItemField'))) === null || _g === void 0 ? void 0 : _g.map((field) => field.split('@')[0]);
567
614
  const selectedFieldSet = new Set(filteredTestCaseFields);
568
615
  // Filter fields based on selected field set
569
616
  if (selectedFieldSet.size !== 0) {
@@ -590,9 +637,9 @@ class ResultDataProvider {
590
637
  return null;
591
638
  }
592
639
  }
593
- appendQueryRelations(resultData, relatedRequirements, relatedBugs, relatedCRs) {
640
+ appendQueryRelations(testCaseId, relatedRequirements, relatedBugs, relatedCRs) {
594
641
  if (this.testToAssociatedItemMap.size !== 0) {
595
- const relatedItemSet = this.testToAssociatedItemMap.get(Number(resultData.testCase.id));
642
+ const relatedItemSet = this.testToAssociatedItemMap.get(Number(testCaseId));
596
643
  if (relatedItemSet) {
597
644
  for (const relatedItem of relatedItemSet) {
598
645
  const { id, fields, _links } = relatedItem;
@@ -740,6 +787,7 @@ class ResultDataProvider {
740
787
  }
741
788
  // Process filtered fields if available
742
789
  const filteredFields = new Set(((_b = (_a = options.selectedFields) === null || _a === void 0 ? void 0 : _a.filter((field) => field.includes('@stepsRunProperties'))) === null || _b === void 0 ? void 0 : _b.map((field) => field.split('@')[0])) || []);
790
+ const iterationsMap = this.createIterationsMap(iterations, isTestReporter, includeNotRunTestCases);
743
791
  for (const testItem of testData) {
744
792
  for (const point of testItem.testPointsItems) {
745
793
  const testCase = testItem.testCasesItems.find((tc) => Number(tc.workItem.id) === Number(point.testCaseId));
@@ -751,22 +799,18 @@ class ResultDataProvider {
751
799
  continue;
752
800
  }
753
801
  }
754
- if (includeNotRunTestCases && !point.lastRunId && !point.lastResultId) {
755
- this.AppendResults(options, testCase, filteredFields, testItem, point, detailedResults);
756
- }
757
- else {
758
- const iterationsMap = this.createIterationsMap(iterations, testCase.workItem.id, isTestReporter);
759
- const iterationKey = `${point.lastRunId}-${point.lastResultId}-${testCase.workItem.id}`;
760
- const fetchedTestCase = iterationsMap[iterationKey] || (includeNotRunTestCases ? testCase : undefined);
761
- // First check if fetchedTestCase exists
762
- if (!fetchedTestCase)
763
- continue;
764
- // Then separately check for iteration only if configured not to include items without iterations
765
- if (!includeItemsWithNoIterations && !fetchedTestCase.iteration)
766
- continue;
767
- // Determine if we should process at step level
768
- this.AppendResults(options, fetchedTestCase, filteredFields, testItem, point, detailedResults);
769
- }
802
+ const iterationKey = !point.lastRunId || !point.lastResultId
803
+ ? `${testCase.workItem.id}`
804
+ : `${point.lastRunId}-${point.lastResultId}-${testCase.workItem.id}`;
805
+ const fetchedTestCase = iterationsMap[iterationKey] || (includeNotRunTestCases ? testCase : undefined);
806
+ // First check if fetchedTestCase exists
807
+ if (!fetchedTestCase)
808
+ continue;
809
+ // Then separately check for iteration only if configured not to include items without iterations
810
+ if (!includeItemsWithNoIterations && !fetchedTestCase.iteration)
811
+ continue;
812
+ // Determine if we should process at step level
813
+ this.AppendResults(options, fetchedTestCase, filteredFields, testItem, point, detailedResults);
770
814
  }
771
815
  }
772
816
  return detailedResults;
@@ -857,11 +901,15 @@ class ResultDataProvider {
857
901
  /**
858
902
  * Creates a mapping of iterations by their unique keys.
859
903
  */
860
- createIterationsMap(iterations, testCaseId, isTestReporter) {
904
+ createIterationsMap(iterations, isTestReporter, includeNotRunTestCases) {
861
905
  return iterations.reduce((map, iterationItem) => {
862
906
  if ((isTestReporter && iterationItem.lastRunId && iterationItem.lastResultId) ||
863
907
  iterationItem.iteration) {
864
- const key = `${iterationItem.lastRunId}-${iterationItem.lastResultId}-${testCaseId}`;
908
+ const key = `${iterationItem.lastRunId}-${iterationItem.lastResultId}-${iterationItem.testCaseId}`;
909
+ map[key] = iterationItem;
910
+ }
911
+ else if (includeNotRunTestCases) {
912
+ const key = `${iterationItem.testCaseId}`;
865
913
  map[key] = iterationItem;
866
914
  }
867
915
  return map;
@@ -899,13 +947,15 @@ class ResultDataProvider {
899
947
  * @param additionalArgs - An optional array of additional arguments to be passed to the fetch strategy.
900
948
  * @returns A Promise that resolves to an array of fetched result data.
901
949
  */
902
- async fetchAllResultDataBase(testData, projectName, fetchStrategy, additionalArgs = []) {
950
+ async fetchAllResultDataBase(testData, projectName, isTestReporter, fetchStrategy, additionalArgs = []) {
903
951
  const results = [];
904
952
  for (const item of testData) {
905
953
  if (item.testPointsItems && item.testPointsItems.length > 0) {
906
954
  const { testSuiteId, testPointsItems } = item;
907
955
  // Filter and sort valid points
908
- const validPoints = testPointsItems.filter((point) => point && point.lastRunId && point.lastResultId);
956
+ const validPoints = isTestReporter
957
+ ? testPointsItems
958
+ : testPointsItems.filter((point) => point && point.lastRunId && point.lastResultId);
909
959
  // Fetch results for each point sequentially
910
960
  for (const point of validPoints) {
911
961
  const resultData = await fetchStrategy(projectName, testSuiteId, point, ...additionalArgs);
@@ -921,78 +971,81 @@ class ResultDataProvider {
921
971
  * Fetches result data for all test points within the given test data, sequentially to avoid context-related errors.
922
972
  */
923
973
  async fetchAllResultData(testData, projectName) {
924
- return this.fetchAllResultDataBase(testData, projectName, (projectName, testSuiteId, point) => this.fetchResultData(projectName, testSuiteId, point));
974
+ return this.fetchAllResultDataBase(testData, projectName, false, (projectName, testSuiteId, point) => this.fetchResultData(projectName, testSuiteId, point));
925
975
  }
926
976
  /**
927
977
  * Fetches result Data for a specific test point
928
978
  */
929
979
  async fetchResultDataBase(projectName, testSuiteId, point, fetchResultMethod, createResponseObject, additionalArgs = []) {
930
- const { lastRunId, lastResultId } = point;
931
- if (!lastRunId || !lastResultId) {
932
- logger_1.default.warn(`Invalid lastRunId or lastResultId for point: ${JSON.stringify(point)}`);
933
- return null;
934
- }
935
- else if (lastRunId === '0' || lastResultId === '0') {
936
- logger_1.default.warn(`Invalid lastRunId or lastResultId: ${lastRunId}, ${lastResultId}`);
937
- return null;
938
- }
939
- const resultData = await fetchResultMethod(projectName, lastRunId.toString(), lastResultId.toString(), ...additionalArgs);
940
- const iteration = resultData.iterationDetails.length > 0
941
- ? resultData.iterationDetails[resultData.iterationDetails.length - 1]
942
- : undefined;
943
- if (resultData.stepsResultXml && iteration) {
944
- const actionResultsWithSharedModels = iteration.actionResults.filter((result) => result.sharedStepModel);
945
- const sharedStepIdToRevisionLookupMap = new Map();
946
- if ((actionResultsWithSharedModels === null || actionResultsWithSharedModels === void 0 ? void 0 : actionResultsWithSharedModels.length) > 0) {
947
- actionResultsWithSharedModels.forEach((actionResult) => {
948
- const { sharedStepModel } = actionResult;
949
- sharedStepIdToRevisionLookupMap.set(Number(sharedStepModel.id), Number(sharedStepModel.revision));
950
- });
951
- }
952
- const stepsList = await this.testStepParserHelper.parseTestSteps(resultData.stepsResultXml, sharedStepIdToRevisionLookupMap);
953
- sharedStepIdToRevisionLookupMap.clear();
954
- const stepMap = new Map();
955
- for (const step of stepsList) {
956
- stepMap.set(step.stepId.toString(), step);
957
- }
958
- for (const actionResult of iteration.actionResults) {
959
- const step = stepMap.get(actionResult.stepIdentifier);
960
- if (step) {
961
- actionResult.stepPosition = step.stepPosition;
962
- actionResult.action = step.action;
963
- actionResult.expected = step.expected;
964
- actionResult.isSharedStepTitle = step.isSharedStepTitle;
980
+ var _a;
981
+ try {
982
+ const { lastRunId, lastResultId } = point;
983
+ const resultData = await fetchResultMethod(projectName, (lastRunId === null || lastRunId === void 0 ? void 0 : lastRunId.toString()) || '0', (lastResultId === null || lastResultId === void 0 ? void 0 : lastResultId.toString()) || '0', ...additionalArgs);
984
+ const iteration = ((_a = resultData.iterationDetails) === null || _a === void 0 ? void 0 : _a.length) > 0
985
+ ? resultData.iterationDetails[resultData.iterationDetails.length - 1]
986
+ : undefined;
987
+ if (resultData.stepsResultXml && iteration) {
988
+ const actionResultsWithSharedModels = iteration.actionResults.filter((result) => result.sharedStepModel);
989
+ const sharedStepIdToRevisionLookupMap = new Map();
990
+ if ((actionResultsWithSharedModels === null || actionResultsWithSharedModels === void 0 ? void 0 : actionResultsWithSharedModels.length) > 0) {
991
+ actionResultsWithSharedModels.forEach((actionResult) => {
992
+ const { sharedStepModel } = actionResult;
993
+ sharedStepIdToRevisionLookupMap.set(Number(sharedStepModel.id), Number(sharedStepModel.revision));
994
+ });
995
+ }
996
+ const stepsList = await this.testStepParserHelper.parseTestSteps(resultData.stepsResultXml, sharedStepIdToRevisionLookupMap);
997
+ sharedStepIdToRevisionLookupMap.clear();
998
+ const stepMap = new Map();
999
+ for (const step of stepsList) {
1000
+ stepMap.set(step.stepId.toString(), step);
1001
+ }
1002
+ for (const actionResult of iteration.actionResults) {
1003
+ const step = stepMap.get(actionResult.stepIdentifier);
1004
+ if (step) {
1005
+ actionResult.stepPosition = step.stepPosition;
1006
+ actionResult.action = step.action;
1007
+ actionResult.expected = step.expected;
1008
+ actionResult.isSharedStepTitle = step.isSharedStepTitle;
1009
+ }
965
1010
  }
1011
+ //Sort by step position
1012
+ iteration.actionResults = iteration.actionResults
1013
+ .filter((result) => result.stepPosition)
1014
+ .sort((a, b) => this.compareActionResults(a.stepPosition, b.stepPosition));
966
1015
  }
967
- //Sort by step position
968
- iteration.actionResults = iteration.actionResults
969
- .filter((result) => result.stepPosition)
970
- .sort((a, b) => this.compareActionResults(a.stepPosition, b.stepPosition));
1016
+ return (resultData === null || resultData === void 0 ? void 0 : resultData.testCase)
1017
+ ? createResponseObject(resultData, testSuiteId, point, ...additionalArgs)
1018
+ : null;
1019
+ }
1020
+ catch (error) {
1021
+ logger_1.default.error(`Error occurred for point ${point.testCaseId}: ${error.message}`);
1022
+ logger_1.default.error(`Stack trace: ${error.stack}`);
1023
+ return null;
971
1024
  }
972
- return (resultData === null || resultData === void 0 ? void 0 : resultData.testCase)
973
- ? createResponseObject(resultData, testSuiteId, point, ...additionalArgs)
974
- : null;
975
1025
  }
976
1026
  /**
977
1027
  * Fetches result Data for a specific test point
978
1028
  */
979
1029
  async fetchResultData(projectName, testSuiteId, point) {
980
- return this.fetchResultDataBase(projectName, testSuiteId, point, (project, runId, resultId) => this.fetchResultDataBasedOnWi(project, runId, resultId), (resultData, testSuiteId, point) => ({
981
- testCaseName: `${resultData.testCase.name} - ${resultData.testCase.id}`,
982
- testCaseId: resultData.testCase.id,
983
- testSuiteName: `${resultData.testSuite.name}`,
984
- testSuiteId,
985
- lastRunId: point.lastRunId,
986
- lastResultId: point.lastResultId,
987
- iteration: resultData.iterationDetails.length > 0
988
- ? resultData.iterationDetails[resultData.iterationDetails.length - 1]
989
- : undefined,
990
- testCaseRevision: resultData.testCaseRevision,
991
- failureType: resultData.failureType,
992
- resolution: resultData.resolutionState,
993
- comment: resultData.comment,
994
- analysisAttachments: resultData.analysisAttachments,
995
- }));
1030
+ return this.fetchResultDataBase(projectName, testSuiteId, point, (project, runId, resultId) => this.fetchResultDataBasedOnWi(project, runId, resultId), (resultData, testSuiteId, point) => {
1031
+ var _a;
1032
+ return ({
1033
+ testCaseName: `${resultData.testCase.name} - ${resultData.testCase.id}`,
1034
+ testCaseId: resultData.testCase.id,
1035
+ testSuiteName: `${resultData.testSuite.name}`,
1036
+ testSuiteId,
1037
+ lastRunId: point.lastRunId,
1038
+ lastResultId: point.lastResultId,
1039
+ iteration: ((_a = resultData.iterationDetails) === null || _a === void 0 ? void 0 : _a.length) > 0
1040
+ ? resultData.iterationDetails[resultData.iterationDetails.length - 1]
1041
+ : undefined,
1042
+ testCaseRevision: resultData.testCaseRevision,
1043
+ failureType: resultData.failureType,
1044
+ resolution: resultData.resolutionState,
1045
+ comment: resultData.comment,
1046
+ analysisAttachments: resultData.analysisAttachments,
1047
+ });
1048
+ });
996
1049
  }
997
1050
  /**
998
1051
  * Fetches all the linked work items (WI) for the given test case.
@@ -1324,8 +1377,8 @@ class ResultDataProvider {
1324
1377
  * @param selectedFields - (Optional) An array of field names to include in the result data.
1325
1378
  * @returns A promise that resolves to the fetched result data.
1326
1379
  */
1327
- async fetchResultDataBasedOnWiTestReporter(projectName, runId, resultId, selectedFields, isQueryMode) {
1328
- return this.fetchResultDataBasedOnWiBase(projectName, runId, resultId, true, selectedFields, isQueryMode);
1380
+ async fetchResultDataBasedOnWiTestReporter(projectName, runId, resultId, selectedFields, isQueryMode, point) {
1381
+ return this.fetchResultDataBasedOnWiBase(projectName, runId, resultId, true, selectedFields, isQueryMode, point);
1329
1382
  }
1330
1383
  /**
1331
1384
  * Fetches all result data for the test reporter by processing the provided test data.
@@ -1340,7 +1393,7 @@ class ResultDataProvider {
1340
1393
  * @returns A promise that resolves to an array of processed result data.
1341
1394
  */
1342
1395
  async fetchAllResultDataTestReporter(testData, projectName, selectedFields, isQueryMode) {
1343
- return this.fetchAllResultDataBase(testData, projectName, (projectName, testSuiteId, point, selectedFields, isQueryMode) => this.fetchResultDataForTestReporter(projectName, testSuiteId, point, selectedFields, isQueryMode), [selectedFields, isQueryMode]);
1396
+ return this.fetchAllResultDataBase(testData, projectName, true, (projectName, testSuiteId, point, selectedFields, isQueryMode) => this.fetchResultDataForTestReporter(projectName, testSuiteId, point, selectedFields, isQueryMode), [selectedFields, isQueryMode]);
1344
1397
  }
1345
1398
  /**
1346
1399
  * Aligns test steps with iterations for the test reporter by processing test data and iterations
@@ -1400,12 +1453,12 @@ class ResultDataProvider {
1400
1453
  * test suite, last run, iteration, and other selected fields.
1401
1454
  */
1402
1455
  async fetchResultDataForTestReporter(projectName, testSuiteId, point, selectedFields, isQueryMode) {
1403
- return this.fetchResultDataBase(projectName, testSuiteId, point, (project, runId, resultId, fields, isQueryMode) => this.fetchResultDataBasedOnWiTestReporter(project, runId, resultId, fields, isQueryMode), (resultData, testSuiteId, point, selectedFields) => {
1404
- var _a, _b;
1456
+ return this.fetchResultDataBase(projectName, testSuiteId, point, (project, runId, resultId, fields, isQueryMode, point) => this.fetchResultDataBasedOnWiTestReporter(project, runId, resultId, fields, isQueryMode, point), (resultData, testSuiteId, point, selectedFields) => {
1457
+ var _a, _b, _c;
1405
1458
  const { lastRunId, lastResultId, configurationName, lastResultDetails } = point;
1406
1459
  try {
1407
- const iteration = resultData.iterationDetails.length > 0
1408
- ? resultData.iterationDetails[resultData.iterationDetails.length - 1]
1460
+ const iteration = ((_a = resultData.iterationDetails) === null || _a === void 0 ? void 0 : _a.length) > 0
1461
+ ? resultData.iterationDetails[((_b = resultData.iterationDetails) === null || _b === void 0 ? void 0 : _b.length) - 1]
1409
1462
  : undefined;
1410
1463
  const resultDataResponse = {
1411
1464
  testCaseName: `${resultData.testCase.name} - ${resultData.testCase.id}`,
@@ -1434,7 +1487,7 @@ class ResultDataProvider {
1434
1487
  const customFields = this.standardCustomField(resultData.filteredFields);
1435
1488
  resultDataResponse.customFields = customFields;
1436
1489
  }
1437
- const filteredFields = (_a = selectedFields === null || selectedFields === void 0 ? void 0 : selectedFields.filter((field) => field.includes('@runResultField'))) === null || _a === void 0 ? void 0 : _a.map((field) => field.split('@')[0]);
1490
+ const filteredFields = (_c = selectedFields === null || selectedFields === void 0 ? void 0 : selectedFields.filter((field) => field.includes('@runResultField'))) === null || _c === void 0 ? void 0 : _c.map((field) => field.split('@')[0]);
1438
1491
  if (filteredFields && filteredFields.length > 0) {
1439
1492
  for (const field of filteredFields) {
1440
1493
  switch (field) {
@@ -1442,9 +1495,7 @@ class ResultDataProvider {
1442
1495
  resultDataResponse.priority = resultData.priority;
1443
1496
  break;
1444
1497
  case 'testCaseResult':
1445
- const outcome = ((_b = resultData.iterationDetails[resultData.iterationDetails.length - 1]) === null || _b === void 0 ? void 0 : _b.outcome) ||
1446
- resultData.outcome ||
1447
- 'NotApplicable';
1498
+ const outcome = this.getTestOutcome(resultData);
1448
1499
  if (lastRunId === undefined || lastResultId === undefined) {
1449
1500
  resultDataResponse.testCaseResult = {
1450
1501
  resultMessage: `${this.convertRunStatus(outcome)}`,
@@ -1486,7 +1537,20 @@ class ResultDataProvider {
1486
1537
  logger_1.default.error(`Error stack: ${err.stack}`);
1487
1538
  return null;
1488
1539
  }
1489
- }, [selectedFields, isQueryMode]);
1540
+ }, [selectedFields, isQueryMode, point]);
1541
+ }
1542
+ getTestOutcome(resultData) {
1543
+ // Default outcome if nothing else is available
1544
+ const defaultOutcome = 'NotApplicable';
1545
+ // Check if we have iteration details
1546
+ const hasIterationDetails = (resultData === null || resultData === void 0 ? void 0 : resultData.iterationDetails) && resultData.iterationDetails.length > 0;
1547
+ if (hasIterationDetails) {
1548
+ // Get the last iteration's outcome if available
1549
+ const lastIteration = resultData.iterationDetails[resultData.iterationDetails.length - 1];
1550
+ return (lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.outcome) || resultData.outcome || defaultOutcome;
1551
+ }
1552
+ // No iteration details, use result outcome or default
1553
+ return resultData.outcome || defaultOutcome;
1490
1554
  }
1491
1555
  standardCustomField(fieldsToProcess, selectedColumns) {
1492
1556
  var _a, _b, _c;