@midscene/test 1.13.2 → 1.13.3

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.
@@ -9,7 +9,7 @@ import { JSON_SCHEMA, load } from "js-yaml";
9
9
  import { createHash, randomUUID } from "node:crypto";
10
10
  import { mkdir, writeFile } from "node:fs/promises";
11
11
  import { setMaxListeners } from "node:events";
12
- import { TestRunReportAssembler } from "@midscene/core/report";
12
+ import { TestRunReportAssembler, calculateTestRunHealth } from "@midscene/core/report";
13
13
  import { getDebug } from "@midscene/shared/logger";
14
14
  const registry_NodeRegistry = NodeRegistry;
15
15
  const projectIdFromIndex = (index)=>`project-${index}`;
@@ -1010,13 +1010,32 @@ const asNotRun = (documentId, collectedCase, projectName, reason)=>({
1010
1010
  notRunReason: reason
1011
1011
  });
1012
1012
  const summarize = (projects)=>{
1013
- const cases = projects.flatMap((project)=>latestById(project.cases, (item)=>item.caseId));
1013
+ const healthCases = projects.flatMap((project)=>{
1014
+ const documentAttemptByRunId = new Map(project.documents.map((document)=>[
1015
+ document.documentRunId,
1016
+ document.attemptIndex ?? 0
1017
+ ]));
1018
+ return latestById(project.cases, (item)=>item.caseId).map((item)=>({
1019
+ status: item.status,
1020
+ ...item.run ? {
1021
+ run: item.run
1022
+ } : {},
1023
+ ...item.attempts ? {
1024
+ attempts: item.attempts
1025
+ } : {},
1026
+ retryCount: item.documentRunId ? documentAttemptByRunId.get(item.documentRunId) ?? 0 : 0
1027
+ }));
1028
+ });
1014
1029
  const documents = projects.flatMap((project)=>latestById(project.documents, (item)=>item.documentId));
1030
+ const health = calculateTestRunHealth(healthCases);
1015
1031
  return {
1016
- total: cases.length,
1017
- passed: cases.filter((item)=>'success' === item.status).length,
1018
- failed: cases.filter((item)=>'failed' === item.status).length,
1019
- notRun: cases.filter((item)=>'not-run' === item.status).length,
1032
+ total: health.total,
1033
+ passed: health.passed,
1034
+ failed: health.failed,
1035
+ notRun: health.notRun,
1036
+ passedAfterRetry: health.passedAfterRetry,
1037
+ finalPassRate: health.finalPassRate,
1038
+ firstPassRate: health.firstPassRate,
1020
1039
  filtered: projects.reduce((total, project)=>total + project.filteredCaseCount, 0),
1021
1040
  collectionErrors: projects.reduce((total, project)=>total + project.collectionErrors.length, 0),
1022
1041
  documentFailures: documents.filter((document)=>'failed' === document.status).length,