@empiricalrun/playwright-utils 0.34.2 → 0.35.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/CHANGELOG.md +13 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +8 -23
- package/dist/reporter/blob-utils.d.ts +4 -0
- package/dist/reporter/blob-utils.d.ts.map +1 -0
- package/dist/reporter/blob-utils.js +66 -0
- package/dist/reporter/empirical-reporter.d.ts +7 -0
- package/dist/reporter/empirical-reporter.d.ts.map +1 -1
- package/dist/reporter/empirical-reporter.js +43 -1
- package/dist/reporter/uploader.d.ts +2 -22
- package/dist/reporter/uploader.d.ts.map +1 -1
- package/dist/reporter/uploader.js +2 -50
- package/package.json +3 -3
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @empiricalrun/playwright-utils
|
|
2
2
|
|
|
3
|
+
## 0.35.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 79a4e0f: feat: add blob reporters for sharding
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- c07a2de: fix: ensure all test case events are pushed by await queue
|
|
12
|
+
- Updated dependencies [79a4e0f]
|
|
13
|
+
- @empiricalrun/r2-uploader@0.6.0
|
|
14
|
+
- @empiricalrun/test-gen@0.78.4
|
|
15
|
+
|
|
3
16
|
## 0.34.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAczD,wBAAgB,gBAAgB,IAAI,MAAM,CAazC;AAkBD,eAAO,MAAM,UAAU,EAAE,oBAyBxB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,iBAarB,CAAC"}
|
package/dist/config/index.js
CHANGED
|
@@ -5,8 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.devices = exports.baseConfig = void 0;
|
|
7
7
|
exports.chromeStablePath = chromeStablePath;
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
8
|
const deviceDescriptorsSource_json_1 = __importDefault(require("./devices/v1.53.2/deviceDescriptorsSource.json"));
|
|
11
9
|
function getPlatformOS() {
|
|
12
10
|
const platform = process.platform;
|
|
@@ -37,29 +35,16 @@ function chromeStablePath() {
|
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
|
-
function getPlaywrightVersion() {
|
|
41
|
-
try {
|
|
42
|
-
const packageJsonPath = path_1.default.join(process.cwd(), "node_modules", "@playwright", "test", "package.json");
|
|
43
|
-
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf8"));
|
|
44
|
-
return packageJson.version;
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
console.log("Package not found");
|
|
48
|
-
return "";
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function isPlaywrightV147() {
|
|
52
|
-
const version = getPlaywrightVersion();
|
|
53
|
-
return version && version.includes("1.47") ? true : false;
|
|
54
|
-
}
|
|
55
38
|
function getReporters() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
const middle = process.env.HAS_SHARDING
|
|
40
|
+
? [["blob", { outputDir: "blob-report" }]]
|
|
41
|
+
: [
|
|
42
|
+
["json", { outputFile: "summary.json" }],
|
|
43
|
+
["html", { open: "never" }],
|
|
44
|
+
];
|
|
59
45
|
return [
|
|
60
46
|
["list"],
|
|
61
|
-
|
|
62
|
-
["html", { open: "never" }],
|
|
47
|
+
...middle,
|
|
63
48
|
[
|
|
64
49
|
"./node_modules/@empiricalrun/playwright-utils/dist/reporter/empirical-reporter.js",
|
|
65
50
|
],
|
|
@@ -68,7 +53,7 @@ function getReporters() {
|
|
|
68
53
|
exports.baseConfig = {
|
|
69
54
|
testDir: "./tests",
|
|
70
55
|
// outputDir is where we store playwright artifacts (during and post test run)
|
|
71
|
-
outputDir:
|
|
56
|
+
outputDir: "./test-results",
|
|
72
57
|
reporter: getReporters(),
|
|
73
58
|
fullyParallel: true,
|
|
74
59
|
forbidOnly: false,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type AttachmentKey = string;
|
|
2
|
+
export declare function makeAttachmentKey(testId: string, retryIndex: number, attachmentName: string): AttachmentKey;
|
|
3
|
+
export declare function patchBlobZip(zipPath: string, attachmentUrlMap: Map<AttachmentKey, string>): Record<string, string>;
|
|
4
|
+
//# sourceMappingURL=blob-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob-utils.d.ts","sourceRoot":"","sources":["../../src/reporter/blob-utils.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACrB,aAAa,CAEf;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,GAC3C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoExB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.makeAttachmentKey = makeAttachmentKey;
|
|
7
|
+
exports.patchBlobZip = patchBlobZip;
|
|
8
|
+
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
function makeAttachmentKey(testId, retryIndex, attachmentName) {
|
|
11
|
+
return `${testId}|${retryIndex}|${attachmentName}`;
|
|
12
|
+
}
|
|
13
|
+
function patchBlobZip(zipPath, attachmentUrlMap) {
|
|
14
|
+
const zip = new adm_zip_1.default(zipPath);
|
|
15
|
+
const reportEntry = zip.getEntry("report.jsonl");
|
|
16
|
+
if (!reportEntry) {
|
|
17
|
+
logger_1.logger.debug(`[Blob Utils] No report.jsonl found in blob zip: ${zipPath}`);
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
const content = reportEntry.getData().toString("utf8");
|
|
21
|
+
const lines = content.split("\n").filter((line) => line.length);
|
|
22
|
+
const retryCounters = new Map();
|
|
23
|
+
const testRetryMap = new Map();
|
|
24
|
+
const resourceToUrlMap = {};
|
|
25
|
+
for (const line of lines) {
|
|
26
|
+
const event = JSON.parse(line);
|
|
27
|
+
if (event.method === "onTestEnd") {
|
|
28
|
+
const testId = event.params.test.testId;
|
|
29
|
+
const retryIndex = retryCounters.get(testId) ?? 0;
|
|
30
|
+
retryCounters.set(testId, retryIndex + 1);
|
|
31
|
+
testRetryMap.set(event.params.result.id, retryIndex);
|
|
32
|
+
for (const attachment of event.params.result?.attachments ?? []) {
|
|
33
|
+
if (!attachment.path)
|
|
34
|
+
continue;
|
|
35
|
+
const key = makeAttachmentKey(testId, retryIndex, attachment.name);
|
|
36
|
+
const url = attachmentUrlMap.get(key);
|
|
37
|
+
if (url) {
|
|
38
|
+
resourceToUrlMap[attachment.path] = url;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (event.method === "onAttach") {
|
|
43
|
+
const testId = event.params.testId;
|
|
44
|
+
const resultId = event.params.resultId;
|
|
45
|
+
const retryIndex = testRetryMap.get(resultId) ?? retryCounters.get(testId) ?? 0;
|
|
46
|
+
for (const attachment of event.params.attachments ?? []) {
|
|
47
|
+
if (!attachment.path)
|
|
48
|
+
continue;
|
|
49
|
+
const key = makeAttachmentKey(testId, retryIndex, attachment.name);
|
|
50
|
+
const url = attachmentUrlMap.get(key);
|
|
51
|
+
if (url) {
|
|
52
|
+
resourceToUrlMap[attachment.path] = url;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
zip.addFile("_empirical_urls.json", Buffer.from(JSON.stringify(resourceToUrlMap, null, 2)));
|
|
58
|
+
for (const entry of zip.getEntries()) {
|
|
59
|
+
if (entry.entryName.startsWith("resources/")) {
|
|
60
|
+
zip.deleteFile(entry.entryName);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
zip.writeZip(zipPath);
|
|
64
|
+
logger_1.logger.debug(`[Blob Utils] Patched blob zip: ${zipPath}, mapped ${Object.keys(resourceToUrlMap).length} resources`);
|
|
65
|
+
return resourceToUrlMap;
|
|
66
|
+
}
|
|
@@ -7,11 +7,18 @@ declare class EmpiricalReporter implements Reporter {
|
|
|
7
7
|
private _testResultSourceDir;
|
|
8
8
|
private _baseUrl;
|
|
9
9
|
private _urlPrefix;
|
|
10
|
+
private _pendingTestCaseEvents;
|
|
11
|
+
private _hasSharding;
|
|
12
|
+
private _attachmentUrlMap;
|
|
13
|
+
private _testRetryCounts;
|
|
10
14
|
private checkR2Creds;
|
|
11
15
|
constructor();
|
|
12
16
|
private enqueTestAttachmentUploadTask;
|
|
13
17
|
onTestEnd(test: TestCase, result: TestResult): void;
|
|
14
18
|
onEnd(result: FullResult): Promise<void>;
|
|
19
|
+
private _patchBlobReport;
|
|
20
|
+
private _patchBlobZip;
|
|
21
|
+
private _uploadBlobReport;
|
|
15
22
|
}
|
|
16
23
|
export default EmpiricalReporter;
|
|
17
24
|
//# sourceMappingURL=empirical-reporter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"empirical-reporter.d.ts","sourceRoot":"","sources":["../../src/reporter/empirical-reporter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"empirical-reporter.d.ts","sourceRoot":"","sources":["../../src/reporter/empirical-reporter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,2BAA2B,CAAC;AAkBnC,cAAM,iBAAkB,YAAW,QAAQ;IACzC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,aAAa,CAAyB;IAC9C,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,oBAAoB,CAAkB;IAC9C,OAAO,CAAC,oBAAoB,CAG1B;IACF,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,UAAU,CACwE;IAC1F,OAAO,CAAC,sBAAsB,CAAuB;IAErD,OAAO,CAAC,YAAY,CAAgD;IACpE,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,gBAAgB,CAAkC;IAE1D,OAAO,CAAC,YAAY;;IAyBpB,OAAO,CAAC,6BAA6B,CA4BnC;IAEF,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU;IAuFtC,KAAK,CAAC,MAAM,EAAE,UAAU;YA6HhB,gBAAgB;IAO9B,OAAO,CAAC,aAAa;YAIP,iBAAiB;CAWhC;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -7,6 +7,7 @@ const r2_uploader_1 = require("@empiricalrun/r2-uploader");
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const logger_1 = require("../logger");
|
|
10
|
+
const blob_utils_1 = require("./blob-utils");
|
|
10
11
|
const uploader_1 = require("./uploader");
|
|
11
12
|
const util_1 = require("./util");
|
|
12
13
|
class EmpiricalReporter {
|
|
@@ -17,6 +18,10 @@ class EmpiricalReporter {
|
|
|
17
18
|
_testResultSourceDir = path_1.default.join(this._currentWorkingDir, "test-results");
|
|
18
19
|
_baseUrl = `https://reports.empirical.run`;
|
|
19
20
|
_urlPrefix = `${this._baseUrl}/${process.env.PROJECT_NAME}/${process.env.TEST_RUN_GITHUB_ACTION_ID}`;
|
|
21
|
+
_pendingTestCaseEvents = [];
|
|
22
|
+
_hasSharding = process.env.HAS_SHARDING === "true";
|
|
23
|
+
_attachmentUrlMap = new Map();
|
|
24
|
+
_testRetryCounts = new Map();
|
|
20
25
|
checkR2Creds() {
|
|
21
26
|
if (!process.env.R2_ACCOUNT_ID ||
|
|
22
27
|
!process.env.R2_ACCESS_KEY_ID ||
|
|
@@ -65,6 +70,8 @@ class EmpiricalReporter {
|
|
|
65
70
|
logger_1.logger.debug("[Empirical Reporter] TEST_RUN_GITHUB_ACTION_ID is not set");
|
|
66
71
|
return;
|
|
67
72
|
}
|
|
73
|
+
const retryIndex = this._testRetryCounts.get(test.id) ?? 0;
|
|
74
|
+
this._testRetryCounts.set(test.id, retryIndex + 1);
|
|
68
75
|
try {
|
|
69
76
|
const attachmentPromises = result.attachments.map(async (attachment) => {
|
|
70
77
|
try {
|
|
@@ -82,6 +89,10 @@ class EmpiricalReporter {
|
|
|
82
89
|
logger_1.logger.error(`No path in attachment for ${attachment.name}`);
|
|
83
90
|
return undefined;
|
|
84
91
|
}
|
|
92
|
+
if (this._hasSharding) {
|
|
93
|
+
const key = (0, blob_utils_1.makeAttachmentKey)(test.id, retryIndex, attachment.name);
|
|
94
|
+
this._attachmentUrlMap.set(key, url);
|
|
95
|
+
}
|
|
85
96
|
return {
|
|
86
97
|
name: attachment.name,
|
|
87
98
|
contentType: attachment.contentType,
|
|
@@ -114,7 +125,7 @@ class EmpiricalReporter {
|
|
|
114
125
|
logger_1.logger.error(`[Empirical Reporter] Error sending test case event for: ${test.title}:`, error);
|
|
115
126
|
}
|
|
116
127
|
};
|
|
117
|
-
|
|
128
|
+
this._pendingTestCaseEvents.push(testCaseRunEventTask());
|
|
118
129
|
return;
|
|
119
130
|
}
|
|
120
131
|
catch (error) {
|
|
@@ -185,6 +196,17 @@ class EmpiricalReporter {
|
|
|
185
196
|
return;
|
|
186
197
|
}
|
|
187
198
|
await (0, r2_uploader_1.waitForTaskQueueToFinish)();
|
|
199
|
+
await Promise.allSettled(this._pendingTestCaseEvents);
|
|
200
|
+
if (this._hasSharding) {
|
|
201
|
+
const blobDir = path_1.default.join(this._currentWorkingDir, "blob-report");
|
|
202
|
+
if (fs_1.default.existsSync(blobDir)) {
|
|
203
|
+
await this._patchBlobReport(blobDir);
|
|
204
|
+
await this._uploadBlobReport(blobDir);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
logger_1.logger.debug(`[Empirical Reporter] blob-report does not exist at: ${blobDir}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
188
210
|
logger_1.logger.debug("[Empirical Reporter] All uploads finished");
|
|
189
211
|
const endTime = new Date().getTime();
|
|
190
212
|
logger_1.logger.debug("[Empirical Reporter] Finished final report upload at: ", new Intl.DateTimeFormat("en-US", {
|
|
@@ -195,5 +217,25 @@ class EmpiricalReporter {
|
|
|
195
217
|
const timeDiff = endTime - startTime;
|
|
196
218
|
logger_1.logger.debug("[Empirical Reporter] Time taken to upload after tests ended: ", timeDiff, "ms");
|
|
197
219
|
}
|
|
220
|
+
async _patchBlobReport(blobDir) {
|
|
221
|
+
const files = await fs_1.default.promises.readdir(blobDir);
|
|
222
|
+
for (const fileName of files.filter((f) => f.endsWith(".zip"))) {
|
|
223
|
+
this._patchBlobZip(path_1.default.join(blobDir, fileName));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
_patchBlobZip(zipPath) {
|
|
227
|
+
(0, blob_utils_1.patchBlobZip)(zipPath, this._attachmentUrlMap);
|
|
228
|
+
}
|
|
229
|
+
async _uploadBlobReport(blobDir) {
|
|
230
|
+
const uploadTask = (0, uploader_1.createUploadTaskV2)({
|
|
231
|
+
sourceDir: blobDir,
|
|
232
|
+
destinationDir: path_1.default.join(this._destinationDir, "blobs"),
|
|
233
|
+
uploadBucket: this._uploadBucket,
|
|
234
|
+
baseUrl: this._baseUrl,
|
|
235
|
+
});
|
|
236
|
+
await (0, r2_uploader_1.sendTaskToQueue)(uploadTask);
|
|
237
|
+
await (0, r2_uploader_1.waitForTaskQueueToFinish)();
|
|
238
|
+
logger_1.logger.debug("[Empirical Reporter] Blob report uploaded");
|
|
239
|
+
}
|
|
198
240
|
}
|
|
199
241
|
exports.default = EmpiricalReporter;
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* Creates an async task for uploading files to R2 storage.
|
|
4
|
-
* This is an improved version of createUploadTask that:
|
|
5
|
-
* 1. Takes sourceDir directly instead of computing it from outputFolder + relativePath
|
|
6
|
-
* 2. Allows specifying a custom upload bucket instead of using a global constant
|
|
7
|
-
* 3. Preserves the full file path in the returned URLs instead of just the filename
|
|
8
|
-
*
|
|
9
|
-
* @param {Object} params - The upload parameters
|
|
10
|
-
* @param {string} params.sourceDir - The source directory containing files to upload
|
|
11
|
-
* @param {string[]} [params.fileList] - Optional list of specific files to upload
|
|
12
|
-
* @param {string} params.destinationDir - The destination directory in R2 storage
|
|
13
|
-
* @param {string} params.uploadBucket - The R2 bucket to upload to
|
|
14
|
-
* @returns {AsyncTask} An async task that when executed will upload the files and return a map of file paths to URLs
|
|
15
|
-
*/
|
|
16
|
-
export declare function createUploadTaskV2({ sourceDir, fileList, destinationDir, uploadBucket, baseUrl, }: {
|
|
17
|
-
sourceDir: string;
|
|
18
|
-
fileList?: string[];
|
|
19
|
-
destinationDir: string;
|
|
20
|
-
uploadBucket: string;
|
|
21
|
-
baseUrl: string;
|
|
22
|
-
}): AsyncTask;
|
|
1
|
+
import { createUploadTask } from "@empiricalrun/r2-uploader";
|
|
2
|
+
export { createUploadTask as createUploadTaskV2 };
|
|
23
3
|
//# sourceMappingURL=uploader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/reporter/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/reporter/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,gBAAgB,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,53 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createUploadTaskV2 =
|
|
3
|
+
exports.createUploadTaskV2 = void 0;
|
|
7
4
|
const r2_uploader_1 = require("@empiricalrun/r2-uploader");
|
|
8
|
-
|
|
9
|
-
const logger_1 = require("../logger");
|
|
10
|
-
/**
|
|
11
|
-
* Creates an async task for uploading files to R2 storage.
|
|
12
|
-
* This is an improved version of createUploadTask that:
|
|
13
|
-
* 1. Takes sourceDir directly instead of computing it from outputFolder + relativePath
|
|
14
|
-
* 2. Allows specifying a custom upload bucket instead of using a global constant
|
|
15
|
-
* 3. Preserves the full file path in the returned URLs instead of just the filename
|
|
16
|
-
*
|
|
17
|
-
* @param {Object} params - The upload parameters
|
|
18
|
-
* @param {string} params.sourceDir - The source directory containing files to upload
|
|
19
|
-
* @param {string[]} [params.fileList] - Optional list of specific files to upload
|
|
20
|
-
* @param {string} params.destinationDir - The destination directory in R2 storage
|
|
21
|
-
* @param {string} params.uploadBucket - The R2 bucket to upload to
|
|
22
|
-
* @returns {AsyncTask} An async task that when executed will upload the files and return a map of file paths to URLs
|
|
23
|
-
*/
|
|
24
|
-
function createUploadTaskV2({ sourceDir, fileList, destinationDir, uploadBucket, baseUrl, }) {
|
|
25
|
-
return async () => {
|
|
26
|
-
if (!process.env.R2_ACCOUNT_ID ||
|
|
27
|
-
!process.env.R2_ACCESS_KEY_ID ||
|
|
28
|
-
!process.env.R2_SECRET_ACCESS_KEY) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
const uploadedFiles = await (0, r2_uploader_1.uploadDirectory)({
|
|
33
|
-
sourceDir,
|
|
34
|
-
fileList,
|
|
35
|
-
destinationDir,
|
|
36
|
-
uploadBucket,
|
|
37
|
-
});
|
|
38
|
-
const urls = {};
|
|
39
|
-
Object.entries(uploadedFiles).forEach(([filePath]) => {
|
|
40
|
-
// Example: If R2_BASE_URL is "https://r2.example.com" and destinationDir is "test-results/123" and filePath is "screenshot.png"
|
|
41
|
-
// The resulting URL will be: "https://r2.example.com/test-results/123/screenshot.png"
|
|
42
|
-
const fileUrl = new URL(path_1.default.join(destinationDir, filePath), baseUrl);
|
|
43
|
-
urls[filePath] = fileUrl.toString();
|
|
44
|
-
});
|
|
45
|
-
logger_1.logger.debug("Finished Upload Files");
|
|
46
|
-
return urls;
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
logger_1.logger.error("Error uploading files", error);
|
|
50
|
-
return {};
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
5
|
+
Object.defineProperty(exports, "createUploadTaskV2", { enumerable: true, get: function () { return r2_uploader_1.createUploadTask; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/playwright-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"puppeteer-extra-plugin-recaptcha": "^3.6.8",
|
|
46
46
|
"rimraf": "^6.0.1",
|
|
47
47
|
"@empiricalrun/llm": "^0.25.1",
|
|
48
|
-
"@empiricalrun/r2-uploader": "^0.
|
|
49
|
-
"@empiricalrun/test-gen": "^0.78.
|
|
48
|
+
"@empiricalrun/r2-uploader": "^0.6.0",
|
|
49
|
+
"@empiricalrun/test-gen": "^0.78.4"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"dev": "tsc --build --watch",
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/email.ts","./src/index.ts","./src/kv.ts","./src/logger.ts","./src/mailosaur-client.ts","./src/playwright-extensions.ts","./src/postgres.ts","./src/auth/google.ts","./src/auth/index.ts","./src/auth/types.ts","./src/captcha/index.ts","./src/captcha/vision.ts","./src/config/index.ts","./src/config/devices/types.ts","./src/overlay-tests/cache.spec.ts","./src/overlay-tests/click.spec.ts","./src/overlay-tests/fixtures.ts","./src/overlay-tests/patch.spec.ts","./src/reporter/empirical-reporter.ts","./src/reporter/uploader.ts","./src/reporter/util.ts","./src/test/constants.ts","./src/test/expect.ts","./src/test/index.ts","./src/test/types.ts","./src/test/video-labels.ts","./src/test/scripts/agent-capabilities.ts","./src/test/scripts/index.ts","./src/test/scripts/locator-highlights.ts","./src/test/scripts/locator-vision.ts","./src/test/scripts/mouse-pointer.ts","./src/test/scripts/types.ts","./src/test/scripts/pw-locator-patch/dismiss-overlays/cache.ts","./src/test/scripts/pw-locator-patch/dismiss-overlays/index.ts","./src/test/scripts/pw-locator-patch/dismiss-overlays/prompt.ts","./src/test/scripts/pw-locator-patch/dismiss-overlays/types.ts","./src/test/scripts/pw-locator-patch/dismiss-overlays/utils.ts","./src/test/scripts/pw-locator-patch/highlight/click.ts","./src/test/scripts/pw-locator-patch/highlight/expect.ts","./src/test/scripts/pw-locator-patch/highlight/hover.ts","./src/test/scripts/pw-locator-patch/highlight/inner-text.ts","./src/test/scripts/pw-locator-patch/highlight/input-value.ts","./src/test/scripts/pw-locator-patch/highlight/is-checked.ts","./src/test/scripts/pw-locator-patch/highlight/is-disabled.ts","./src/test/scripts/pw-locator-patch/highlight/is-editable.ts","./src/test/scripts/pw-locator-patch/highlight/text-content.ts","./src/test/scripts/pw-locator-patch/utils/index.ts","./src/test/scripts/pw-locator-patch/vision/query.ts"],"version":"5.8.3"}
|
|
1
|
+
{"root":["./src/email.ts","./src/index.ts","./src/kv.ts","./src/logger.ts","./src/mailosaur-client.ts","./src/playwright-extensions.ts","./src/postgres.ts","./src/auth/google.ts","./src/auth/index.ts","./src/auth/types.ts","./src/captcha/index.ts","./src/captcha/vision.ts","./src/config/index.ts","./src/config/devices/types.ts","./src/overlay-tests/cache.spec.ts","./src/overlay-tests/click.spec.ts","./src/overlay-tests/fixtures.ts","./src/overlay-tests/patch.spec.ts","./src/reporter/blob-utils.ts","./src/reporter/empirical-reporter.ts","./src/reporter/uploader.ts","./src/reporter/util.ts","./src/test/constants.ts","./src/test/expect.ts","./src/test/index.ts","./src/test/types.ts","./src/test/video-labels.ts","./src/test/scripts/agent-capabilities.ts","./src/test/scripts/index.ts","./src/test/scripts/locator-highlights.ts","./src/test/scripts/locator-vision.ts","./src/test/scripts/mouse-pointer.ts","./src/test/scripts/types.ts","./src/test/scripts/pw-locator-patch/dismiss-overlays/cache.ts","./src/test/scripts/pw-locator-patch/dismiss-overlays/index.ts","./src/test/scripts/pw-locator-patch/dismiss-overlays/prompt.ts","./src/test/scripts/pw-locator-patch/dismiss-overlays/types.ts","./src/test/scripts/pw-locator-patch/dismiss-overlays/utils.ts","./src/test/scripts/pw-locator-patch/highlight/click.ts","./src/test/scripts/pw-locator-patch/highlight/expect.ts","./src/test/scripts/pw-locator-patch/highlight/hover.ts","./src/test/scripts/pw-locator-patch/highlight/inner-text.ts","./src/test/scripts/pw-locator-patch/highlight/input-value.ts","./src/test/scripts/pw-locator-patch/highlight/is-checked.ts","./src/test/scripts/pw-locator-patch/highlight/is-disabled.ts","./src/test/scripts/pw-locator-patch/highlight/is-editable.ts","./src/test/scripts/pw-locator-patch/highlight/text-content.ts","./src/test/scripts/pw-locator-patch/utils/index.ts","./src/test/scripts/pw-locator-patch/vision/query.ts"],"version":"5.8.3"}
|