@empiricalrun/test-run 0.17.0 → 0.17.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @empiricalrun/test-run
2
2
 
3
+ ## 0.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 8b1be9e: fix: html report attachment urls for pw 1.60.0
8
+ - Updated dependencies [8b1be9e]
9
+ - @empiricalrun/reporter@0.29.1
10
+
3
11
  ## 0.17.0
4
12
 
5
13
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/lib/merge-reports/html.ts"],"names":[],"mappings":"AAaA,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,MAAM,EACpB,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAAC,IAAI,CAAC,CAsIf"}
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/lib/merge-reports/html.ts"],"names":[],"mappings":"AAeA,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,MAAM,EACpB,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAAC,IAAI,CAAC,CAoHf"}
@@ -52,10 +52,7 @@ async function patchMergedHtmlReport(htmlFilePath, summaryJsonFilePath) {
52
52
  logger_1.logger.error(`[Merge Reports] Failed to read HTML file:`, error);
53
53
  return;
54
54
  }
55
- // Support both old format (1.53.x) and new format (1.57.0+)
56
- const oldFormatMatch = htmlContent.match(/window\.playwrightReportBase64\s*=\s*"(?:data:application\/zip;base64,)?([^"]+)"/);
57
- const newFormatMatch = htmlContent.match(/<script\s+id="playwrightReportBase64"[^>]*>(?:data:application\/zip;base64,)?([^<]+)<\/script>/);
58
- const base64 = oldFormatMatch?.[1] || newFormatMatch?.[1];
55
+ const base64 = (0, reporter_1.findPlaywrightReportBase64)(htmlContent);
59
56
  if (!base64) {
60
57
  logger_1.logger.error(`[Merge Reports] Base64 zip data not found in HTML`);
61
58
  return;
@@ -89,13 +86,7 @@ async function patchMergedHtmlReport(htmlFilePath, summaryJsonFilePath) {
89
86
  const newBuffer = await (0, zip_1.createZipFromDirectory)(tempDir);
90
87
  const newBase64 = newBuffer.toString("base64");
91
88
  logger_1.logger.info(`[Merge Reports] New zip created in ${Date.now() - stepTime}ms`);
92
- let updatedHtml;
93
- if (oldFormatMatch) {
94
- updatedHtml = htmlContent.replace(/(window\.playwrightReportBase64\s*=\s*")(?:data:application\/zip;base64,)?[^"]*(")/, `$1data:application/zip;base64,${newBase64}$2`);
95
- }
96
- else {
97
- updatedHtml = htmlContent.replace(/(<script\s+id="playwrightReportBase64"[^>]*>)(?:data:application\/zip;base64,)?[^<]*(<\/script>)/, `$1data:application/zip;base64,${newBase64}$2`);
98
- }
89
+ const updatedHtml = (0, reporter_1.replacePlaywrightReportBase64)(htmlContent, newBase64);
99
90
  await fs_1.default.promises.writeFile(htmlFilePath, updatedHtml, "utf8");
100
91
  logger_1.logger.info(`[Merge Reports] HTML file patched successfully`);
101
92
  }
@@ -2,6 +2,8 @@ import type { MergeReportsOptions, UploadOptions } from "./types";
2
2
  export { patchMergedHtmlReport } from "./html";
3
3
  export { patchSummaryJson } from "./json";
4
4
  export type { MergeReportsOptions, UploadOptions } from "./types";
5
+ export declare function parsePlaywrightVersionFromReportJsonl(content: string): string | null;
6
+ export declare function getPlaywrightVersionForMerge(blobDir: string): Promise<string | null>;
5
7
  export declare function runPlaywrightMergeReports(options: MergeReportsOptions): Promise<{
6
8
  success: boolean;
7
9
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/merge-reports/index.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;A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AAO,CAAA;CAAE,CAAC,CA+C/B;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAoCjC;AAED,wBAAsB,mBAAmB,CAAC,EACxC,SAAS,EACT,aAAa,GACd,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,aAAa,CAAC;CAC9B,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDhB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAgFhC"}
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.patchSummaryJson = exports.patchMergedHtmlReport = void 0;
7
+ exports.parsePlaywrightVersionFromReportJsonl = parsePlaywrightVersionFromReportJsonl;
8
+ exports.getPlaywrightVersionForMerge = getPlaywrightVersionForMerge;
7
9
  exports.runPlaywrightMergeReports = runPlaywrightMergeReports;
8
10
  exports.extractUrlMappingsFromBlobs = extractUrlMappingsFromBlobs;
9
11
  exports.uploadMergedReports = uploadMergedReports;
@@ -64,15 +66,81 @@ function getCredentialsFromEnv(enableS3) {
64
66
  }
65
67
  return null;
66
68
  }
69
+ function parsePlaywrightVersionFromReportJsonl(content) {
70
+ let userAgentVersion = null;
71
+ for (const line of content.split("\n")) {
72
+ if (!line.trim()) {
73
+ continue;
74
+ }
75
+ try {
76
+ const event = JSON.parse(line);
77
+ if (event.method === "onConfigure") {
78
+ const version = event.params?.config?.version;
79
+ if (typeof version === "string") {
80
+ return version;
81
+ }
82
+ }
83
+ if (event.method === "onBlobReportMetadata") {
84
+ const userAgent = event.params?.userAgent;
85
+ if (typeof userAgent === "string") {
86
+ const match = userAgent.match(/\bPlaywright\/([^\s)]+)/);
87
+ if (match?.[1])
88
+ userAgentVersion = match[1];
89
+ }
90
+ }
91
+ }
92
+ catch {
93
+ // Ignore malformed lines; Playwright merge-reports will validate the blob.
94
+ }
95
+ }
96
+ return userAgentVersion;
97
+ }
98
+ function isSafePlaywrightVersion(version) {
99
+ return /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version);
100
+ }
101
+ async function getPlaywrightVersionForMerge(blobDir) {
102
+ const override = process.env.PLAYWRIGHT_MERGE_VERSION;
103
+ if (override) {
104
+ if (!isSafePlaywrightVersion(override)) {
105
+ throw new Error(`Invalid PLAYWRIGHT_MERGE_VERSION: ${override}`);
106
+ }
107
+ return override;
108
+ }
109
+ const versions = new Set();
110
+ const files = fs_1.default.readdirSync(blobDir).filter((f) => f.endsWith(".zip"));
111
+ for (const fileName of files) {
112
+ const reportJsonl = await (0, zip_1.readZipEntry)(path_1.default.join(blobDir, fileName), "report.jsonl");
113
+ if (!reportJsonl) {
114
+ continue;
115
+ }
116
+ const version = parsePlaywrightVersionFromReportJsonl(reportJsonl.toString("utf8"));
117
+ if (version) {
118
+ if (!isSafePlaywrightVersion(version)) {
119
+ throw new Error(`Invalid Playwright version in ${fileName}: ${version}`);
120
+ }
121
+ versions.add(version);
122
+ }
123
+ }
124
+ if (versions.size > 1) {
125
+ logger_1.logger.warn(`[Merge Reports] Multiple Playwright versions found in blobs: ${Array.from(versions).join(", ")}`);
126
+ }
127
+ return versions.values().next().value ?? null;
128
+ }
67
129
  async function runPlaywrightMergeReports(options) {
68
130
  const { blobDir, outputDir, cwd } = options;
69
131
  logger_1.logger.debug(`[Merge Reports] Running playwright merge-reports`);
70
132
  logger_1.logger.debug(`[Merge Reports] Blob dir: ${blobDir}`);
71
133
  logger_1.logger.debug(`[Merge Reports] Output dir: ${outputDir}`);
72
134
  try {
135
+ const playwrightVersion = await getPlaywrightVersionForMerge(blobDir);
136
+ if (!playwrightVersion) {
137
+ logger_1.logger.error(`[Merge Reports] Could not determine Playwright version from blob reports`);
138
+ return { success: false };
139
+ }
140
+ logger_1.logger.debug(`[Merge Reports] Playwright version: ${playwrightVersion}`);
73
141
  await (0, cmd_1.spawnCmd)("npx", [
74
142
  "--yes",
75
- "playwright@1.58.2",
143
+ `playwright@${playwrightVersion}`,
76
144
  "merge-reports",
77
145
  blobDir,
78
146
  "--reporter",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-run",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -37,7 +37,7 @@
37
37
  "minimatch": "^10.0.1",
38
38
  "ts-morph": "^23.0.0",
39
39
  "@empiricalrun/r2-uploader": "^0.9.1",
40
- "@empiricalrun/reporter": "^0.29.0"
40
+ "@empiricalrun/reporter": "^0.29.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@playwright/test": "1.60.0",
@@ -46,7 +46,7 @@
46
46
  "@types/console-log-level": "^1.4.5",
47
47
  "@types/node": "^22.5.5",
48
48
  "memfs": "^4.17.1",
49
- "@empiricalrun/shared-types": "0.13.0"
49
+ "@empiricalrun/shared-types": "0.14.0"
50
50
  },
51
51
  "scripts": {
52
52
  "dev": "tsc --build --watch",