@midscene/test 1.13.1-beta-20260921080849.0 → 1.13.1

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, calculateTestRunHealth } from "@midscene/core/report";
12
+ import { TestRunReportAssembler } 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}`;
@@ -724,6 +724,7 @@ const selectProjects = (projects, names)=>{
724
724
  return projects.filter((project)=>requested.has(project.name));
725
725
  };
726
726
  async function prepareProject(project, projectRoot, runDir, defaultTimeoutMs, options = {}) {
727
+ const platform = options.platform?.trim();
727
728
  const fileSelection = project.files ?? DEFAULT_TEST_FILE_SELECTION;
728
729
  const prerequisiteFile = options.prerequisiteFile ? resolve(options.prerequisiteFile) : void 0;
729
730
  const mainFiles = options.files ?? discoverResolvedTestFiles(projectRoot, fileSelection);
@@ -795,7 +796,9 @@ async function prepareProject(project, projectRoot, runDir, defaultTimeoutMs, op
795
796
  const prerequisiteDocument = documents.find((document)=>document.sourcePath === prerequisiteSource?.sourcePath);
796
797
  return {
797
798
  project,
798
- platform: options.platform ?? 'test',
799
+ ...platform ? {
800
+ platform
801
+ } : {},
799
802
  documentConcurrency: options.documentConcurrency ?? 1,
800
803
  ...prerequisiteDocument ? {
801
804
  prerequisiteDocumentId: prerequisiteDocument.documentId
@@ -1007,32 +1010,13 @@ const asNotRun = (documentId, collectedCase, projectName, reason)=>({
1007
1010
  notRunReason: reason
1008
1011
  });
1009
1012
  const summarize = (projects)=>{
1010
- const healthCases = projects.flatMap((project)=>{
1011
- const documentAttemptByRunId = new Map(project.documents.map((document)=>[
1012
- document.documentRunId,
1013
- document.attemptIndex ?? 0
1014
- ]));
1015
- return latestById(project.cases, (item)=>item.caseId).map((item)=>({
1016
- status: item.status,
1017
- ...item.run ? {
1018
- run: item.run
1019
- } : {},
1020
- ...item.attempts ? {
1021
- attempts: item.attempts
1022
- } : {},
1023
- retryCount: item.documentRunId ? documentAttemptByRunId.get(item.documentRunId) ?? 0 : 0
1024
- }));
1025
- });
1013
+ const cases = projects.flatMap((project)=>latestById(project.cases, (item)=>item.caseId));
1026
1014
  const documents = projects.flatMap((project)=>latestById(project.documents, (item)=>item.documentId));
1027
- const health = calculateTestRunHealth(healthCases);
1028
1015
  return {
1029
- total: health.total,
1030
- passed: health.passed,
1031
- failed: health.failed,
1032
- notRun: health.notRun,
1033
- passedAfterRetry: health.passedAfterRetry,
1034
- finalPassRate: health.finalPassRate,
1035
- firstPassRate: health.firstPassRate,
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,
1036
1020
  filtered: projects.reduce((total, project)=>total + project.filteredCaseCount, 0),
1037
1021
  collectionErrors: projects.reduce((total, project)=>total + project.collectionErrors.length, 0),
1038
1022
  documentFailures: documents.filter((document)=>'failed' === document.status).length,
@@ -1093,7 +1077,9 @@ async function runPreparedTestProject(plan) {
1093
1077
  return {
1094
1078
  projectId: project.projectId,
1095
1079
  name: project.name,
1096
- platform: prepared.platform,
1080
+ ...prepared.platform ? {
1081
+ platform: prepared.platform
1082
+ } : {},
1097
1083
  status: projectFailed ? 'failed' : 'success',
1098
1084
  retry: project.retry,
1099
1085
  fileSelection: prepared.fileSelection,