@empiricalrun/test-gen 0.23.1 → 0.23.5
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 +29 -0
- package/dist/agent/browsing/index.d.ts.map +1 -1
- package/dist/agent/browsing/index.js +13 -0
- package/dist/agent/browsing/run.js +1 -1
- package/dist/bin/index.js +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/reporter/index.d.ts +1 -0
- package/dist/reporter/index.d.ts.map +1 -1
- package/dist/session/index.d.ts +7 -1
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +49 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/uploader/index.d.ts.map +1 -1
- package/dist/uploader/index.js +28 -5
- package/dist/uploader/r2.d.ts +2 -1
- package/dist/uploader/r2.d.ts.map +1 -1
- package/dist/uploader/r2.js +10 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.23.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6d954fd: feat: use custom playwright reporter
|
|
8
|
+
- Updated dependencies [6d954fd]
|
|
9
|
+
- @empiricalrun/reporter@0.17.7
|
|
10
|
+
|
|
11
|
+
## 0.23.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- d1068e6: fix: multiple session details call and missing generation id in requests
|
|
16
|
+
- Updated dependencies [d1068e6]
|
|
17
|
+
- @empiricalrun/reporter@0.17.6
|
|
18
|
+
|
|
19
|
+
## 0.23.3
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [f02f7a7]
|
|
24
|
+
- @empiricalrun/llm@0.7.3
|
|
25
|
+
|
|
26
|
+
## 0.23.2
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- f6f488d: feat: add support for cancelling generation
|
|
31
|
+
|
|
3
32
|
## 0.23.1
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAYlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAMnD,KAAK,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,GAAG;IAC1D,YAAY,CAAC,EAAE;QACb,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAYlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAMnD,KAAK,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,GAAG;IAC1D,YAAY,CAAC,EAAE;QACb,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,oBAAoB,mBA0L9B;AAED,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,oBAAoB,mBAqG9B"}
|
|
@@ -50,6 +50,11 @@ async function browsingAgentUsingMasterAgent(task, page, options) {
|
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
const sessionState = await (0, session_1.getSessionState)();
|
|
54
|
+
if (sessionState === "request_complete") {
|
|
55
|
+
await testgenUpdatesReporter.sendMessage("Aborting task, marking the task as done.");
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
53
58
|
const { action, reason } = await (0, run_1.masterAgent)(task, page, masterAgentActions, masterAgentSpan, llm, options);
|
|
54
59
|
logger.log(`Next action: ${action} \n reason: ${reason}`);
|
|
55
60
|
if (!action) {
|
|
@@ -64,6 +69,10 @@ async function browsingAgentUsingMasterAgent(task, page, options) {
|
|
|
64
69
|
const browsingAgentSpan = masterAgentSpan.span({
|
|
65
70
|
name: `browsing-agent`,
|
|
66
71
|
});
|
|
72
|
+
const sessionState = await (0, session_1.getSessionState)();
|
|
73
|
+
if (sessionState === "request_complete") {
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
67
76
|
const pageContentSpan = browsingAgentSpan.span({ name: "page-content" });
|
|
68
77
|
const pageContent = await page.content();
|
|
69
78
|
pageContentSpan.end({ output: { pageContent } });
|
|
@@ -118,6 +127,10 @@ async function browsingAgentUsingMasterAgent(task, page, options) {
|
|
|
118
127
|
const toolCallsSpan = browsingAgentSpan.span({ name: "tool-calls" });
|
|
119
128
|
for (const i in toolCalls) {
|
|
120
129
|
const toolCall = toolCalls[i];
|
|
130
|
+
const sessionState = await (0, session_1.getSessionState)();
|
|
131
|
+
if (sessionState === "request_complete") {
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
121
134
|
try {
|
|
122
135
|
await actions.executeAction(toolCall.function.name, JSON.parse(toolCall.function.arguments));
|
|
123
136
|
executedActions.push({
|
|
@@ -19,6 +19,7 @@ async function generateTestsUsingBrowsingAgent(testFilePath) {
|
|
|
19
19
|
const fileService = new server_1.FileService({ port });
|
|
20
20
|
await fileService.startFileService();
|
|
21
21
|
fileService.setFilePath(testFilePath);
|
|
22
|
+
// read playwright config from ./playwright.config.ts of source repo
|
|
22
23
|
const playwrightConfig = await (0, utils_2.readPlaywrightConfig)();
|
|
23
24
|
const project = await (0, utils_2.detectProjectName)(testFilePath, playwrightConfig);
|
|
24
25
|
logger.log(`Detected playwright project name: ${project}`);
|
|
@@ -39,7 +40,6 @@ async function generateTestsUsingBrowsingAgent(testFilePath) {
|
|
|
39
40
|
catch (e) {
|
|
40
41
|
logger.error(e);
|
|
41
42
|
await new reporter_1.TestGenUpdatesReporter().sendMessage(e);
|
|
42
|
-
process.exit(1);
|
|
43
43
|
}
|
|
44
44
|
await (0, web_1.removeTestOnly)(testFilePath);
|
|
45
45
|
}
|
package/dist/bin/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const utils_1 = require("../agent/browsing/utils");
|
|
|
11
11
|
const run_2 = require("../agent/codegen/run");
|
|
12
12
|
const reporter_1 = require("../reporter");
|
|
13
13
|
const ci_1 = require("../reporter/ci");
|
|
14
|
+
const session_1 = require("../session");
|
|
14
15
|
const logger_1 = require("./logger");
|
|
15
16
|
const utils_2 = require("./utils");
|
|
16
17
|
dotenv_1.default.config({
|
|
@@ -51,11 +52,17 @@ async function runAgent(testGenConfig) {
|
|
|
51
52
|
testGroup: testGenConfig.testCase.group,
|
|
52
53
|
projectRepoName: testGenConfig.options?.metadata.projectRepoName,
|
|
53
54
|
testSessionId: testGenConfig.options?.metadata.testSessionId,
|
|
55
|
+
generationId: testGenConfig.options?.metadata.generationId,
|
|
56
|
+
});
|
|
57
|
+
(0, session_1.setSessionDetails)({
|
|
58
|
+
sessionId: testGenConfig.options?.metadata.testSessionId,
|
|
59
|
+
generationId: testGenConfig.options?.metadata.generationId,
|
|
54
60
|
});
|
|
55
61
|
await runAgent(testGenConfig);
|
|
56
62
|
// TODO: move these reporters to a better lifecycle
|
|
57
63
|
await (0, ci_1.reportOnCI)(testGenConfig.testCase);
|
|
58
64
|
await (0, llm_1.flushAllTraces)();
|
|
59
65
|
await (0, logger_1.waitForLogsToFlush)();
|
|
66
|
+
await (0, session_1.endSession)();
|
|
60
67
|
process.exit(0);
|
|
61
68
|
})();
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAalC,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,iBA+BnE"}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const browsing_1 = require("./agent/browsing");
|
|
|
9
9
|
const utils_1 = require("./bin/utils");
|
|
10
10
|
const client_1 = __importDefault(require("./file/client"));
|
|
11
11
|
const reporter_1 = require("./reporter");
|
|
12
|
+
const session_1 = require("./session");
|
|
12
13
|
process.on("beforeExit", async () => await (0, llm_1.flushAllTraces)());
|
|
13
14
|
process.on("exit", async () => await (0, llm_1.flushAllTraces)());
|
|
14
15
|
process.on("SIGINT", async () => await (0, llm_1.flushAllTraces)());
|
|
@@ -22,6 +23,11 @@ async function createTest(task, page, test) {
|
|
|
22
23
|
testGroup: testGenConfig.testCase.group,
|
|
23
24
|
projectRepoName: testGenConfig.options?.metadata.projectRepoName,
|
|
24
25
|
testSessionId: testGenConfig.options?.metadata.testSessionId,
|
|
26
|
+
generationId: testGenConfig.options?.metadata.generationId,
|
|
27
|
+
});
|
|
28
|
+
(0, session_1.setSessionDetails)({
|
|
29
|
+
sessionId: testGenConfig.options?.metadata.testSessionId,
|
|
30
|
+
generationId: testGenConfig.options?.metadata.generationId,
|
|
25
31
|
});
|
|
26
32
|
const fileService = new client_1.default(Number(port));
|
|
27
33
|
test.setTimeout(900000);
|
package/dist/reporter/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAc5E,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAKF,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAUlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAGlE;AAED,qBAAa,sBAAsB;;IAE3B,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,eAAe,CAAC,EACpB,eAAe,EACf,QAAQ,GACT,EAAE;QACD,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;KAClB;IAkCK,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B9C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUlD"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAc5E,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAKF,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAUlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAGlE;AAED,qBAAa,sBAAsB;;IAE3B,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,eAAe,CAAC,EACpB,eAAe,EACf,QAAQ,GACT,EAAE;QACD,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;KAClB;IAkCK,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B9C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUlD"}
|
package/dist/session/index.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
declare function getSessionDetails(): {
|
|
2
|
-
id:
|
|
2
|
+
id: string;
|
|
3
3
|
version: string;
|
|
4
4
|
};
|
|
5
|
+
export declare function setSessionDetails({ sessionId, generationId, }: {
|
|
6
|
+
sessionId: number;
|
|
7
|
+
generationId: number;
|
|
8
|
+
}): void;
|
|
9
|
+
export declare function getSessionState(): Promise<"started" | "completed" | "request_complete">;
|
|
10
|
+
export declare function endSession(): Promise<void>;
|
|
5
11
|
export { getSessionDetails };
|
|
6
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAeA,iBAAS,iBAAiB;;;EAKzB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,YAAY,GACb,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB,QAGA;AAED,wBAAsB,eAAe,0DAkBpC;AAED,wBAAsB,UAAU,kBAmB/B;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/session/index.js
CHANGED
|
@@ -3,14 +3,59 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getSessionDetails = void 0;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
6
|
+
exports.getSessionDetails = exports.endSession = exports.getSessionState = exports.setSessionDetails = void 0;
|
|
8
7
|
const package_json_1 = __importDefault(require("./../../package.json"));
|
|
9
|
-
const
|
|
8
|
+
const sessionDetails = {
|
|
9
|
+
sessionId: undefined,
|
|
10
|
+
version: package_json_1.default.version,
|
|
11
|
+
generationId: undefined,
|
|
12
|
+
};
|
|
13
|
+
const DASHBOARD_DOMAIN = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
|
|
10
14
|
function getSessionDetails() {
|
|
11
15
|
return {
|
|
12
|
-
id:
|
|
16
|
+
id: `${sessionDetails.generationId}`,
|
|
13
17
|
version: package_json_1.default.version,
|
|
14
18
|
};
|
|
15
19
|
}
|
|
16
20
|
exports.getSessionDetails = getSessionDetails;
|
|
21
|
+
function setSessionDetails({ sessionId, generationId, }) {
|
|
22
|
+
sessionDetails.sessionId = sessionId;
|
|
23
|
+
sessionDetails.generationId = generationId;
|
|
24
|
+
}
|
|
25
|
+
exports.setSessionDetails = setSessionDetails;
|
|
26
|
+
async function getSessionState() {
|
|
27
|
+
const apiPath = `${DASHBOARD_DOMAIN}/api/sessions/${sessionDetails.sessionId}/generation?generation_id=${sessionDetails.generationId}`;
|
|
28
|
+
const response = await fetch(apiPath, {
|
|
29
|
+
method: "GET",
|
|
30
|
+
headers: {
|
|
31
|
+
"Content-Type": "application/json",
|
|
32
|
+
Authorization: "weQPMWKT",
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const generationStateData = (await response.json());
|
|
36
|
+
// TODO: fix this heirarchy
|
|
37
|
+
return generationStateData.data.state.state;
|
|
38
|
+
}
|
|
39
|
+
exports.getSessionState = getSessionState;
|
|
40
|
+
async function endSession() {
|
|
41
|
+
const apiPath = `${DASHBOARD_DOMAIN}/api/sessions/${sessionDetails.sessionId}/generation?generation_id=${sessionDetails.generationId}`;
|
|
42
|
+
try {
|
|
43
|
+
await fetch(apiPath, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: {
|
|
46
|
+
"Content-Type": "application/json",
|
|
47
|
+
Authorization: "weQPMWKT",
|
|
48
|
+
},
|
|
49
|
+
body: JSON.stringify({
|
|
50
|
+
generationId: sessionDetails.generationId,
|
|
51
|
+
state: {
|
|
52
|
+
state: "completed",
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error("Failed to end session:", error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.endSession = endSession;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;IACrC,KAAK,EAAE,QAAQ,CAAC;IAChB,aAAa,EAAE,WAAW,CAAC;IAC3B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,QAAQ,EAAE;QACR,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,E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AE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAC;CAC/E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAC3C,eAAO,MAAM,aAAa,kCAAkC,CAAC;AAG7D,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAUpE;AAED;;;;;;;;;GASG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,eAAe,EACf,QAAQ,GACT,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC;IACV,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC,CAmED;AAED,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,UAM1D;AAED,wBAAgB,2BAA2B,uBAQ1C"}
|
package/dist/uploader/index.js
CHANGED
|
@@ -8,12 +8,20 @@ const reporter_1 = require("@empiricalrun/reporter");
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const r2_1 = require("./r2");
|
|
10
10
|
// json summary of test results
|
|
11
|
-
|
|
11
|
+
// originally we used to upload test results directory for this
|
|
12
|
+
// but now we have our test results (per testcase artifacts) inside playwright-report/data
|
|
13
|
+
// but we also have summary.json in playwright-report/
|
|
14
|
+
// we can avoid html report upload here if we don't want
|
|
15
|
+
const PLAYWRIGHT_REPORT_DATA = "playwright-report/data";
|
|
12
16
|
exports.UPLOAD_BUCKET = "test-report";
|
|
13
17
|
exports.UPLOAD_DOMAIN = "https://reports.empirical.run"; // domain based on bucket mentioned above
|
|
14
18
|
const uploadId = crypto.randomUUID();
|
|
15
19
|
function getFullUploadPath(filePath, uploadDir) {
|
|
16
|
-
|
|
20
|
+
// remove the source dir from the file path - only keep the relative path
|
|
21
|
+
// old path for data: ~/source-repo/test-results/testName/
|
|
22
|
+
// new path for data: ~/source-repo/playwright-report/data/testName
|
|
23
|
+
const relativeFilePath = filePath.replace(path_1.default.join(process.cwd(), PLAYWRIGHT_REPORT_DATA), "");
|
|
24
|
+
// new relativeFilePath will look like
|
|
17
25
|
return `${exports.UPLOAD_DOMAIN}/${uploadDir}${relativeFilePath}`;
|
|
18
26
|
}
|
|
19
27
|
exports.getFullUploadPath = getFullUploadPath;
|
|
@@ -29,14 +37,27 @@ exports.getFullUploadPath = getFullUploadPath;
|
|
|
29
37
|
*/
|
|
30
38
|
async function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, }) {
|
|
31
39
|
// project repo name is the github repo name
|
|
40
|
+
// test-generation/<project-name>/<random-uuid>
|
|
32
41
|
const uploadDir = getUploadPathForRun(projectRepoName);
|
|
42
|
+
// upload test assets
|
|
33
43
|
const files = await (0, r2_1.uploadDirectory)({
|
|
34
|
-
|
|
44
|
+
// ~/source-repo/playwright-report -> has index.html, data, trace(they are assets for index.html, not sure why they are called trace), and summary.json
|
|
45
|
+
sourceDir: path_1.default.join(process.cwd(), PLAYWRIGHT_REPORT_DATA), // upload data dir
|
|
46
|
+
destinationDir: uploadDir,
|
|
47
|
+
uploadBucket: exports.UPLOAD_BUCKET,
|
|
48
|
+
});
|
|
49
|
+
// upload summary.json
|
|
50
|
+
await (0, r2_1.uploadDirectory)({
|
|
51
|
+
// ~/source-repo/playwright-report -> has index.html, data, trace(they are assets for index.html, not sure why they are called trace), and summary.json
|
|
52
|
+
sourceDir: path_1.default.join(process.cwd(), "playwright-report"), // upload data dir
|
|
53
|
+
fileList: [path_1.default.join(process.cwd(), "playwright-report", "summary.json")],
|
|
35
54
|
destinationDir: uploadDir,
|
|
36
55
|
uploadBucket: exports.UPLOAD_BUCKET,
|
|
37
56
|
});
|
|
38
57
|
const fileNames = Object.keys(files); // fileNames are absolute paths of the input files
|
|
39
|
-
|
|
58
|
+
// old default location: ..../source-repo/test-results/summary.json
|
|
59
|
+
// new default location: ..../source-repo/playwright-report/summary.json
|
|
60
|
+
const defaultLocation = path_1.default.join(process.cwd(), "playwright-report", "summary.json");
|
|
40
61
|
const results = (0, reporter_1.parseJsonReport)(defaultLocation);
|
|
41
62
|
const flatTestsList = (0, reporter_1.getFlattenedTestList)(results.suites);
|
|
42
63
|
const testAttachmentPaths = [];
|
|
@@ -61,7 +82,9 @@ async function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, }) {
|
|
|
61
82
|
const traceFiles = fileNames.filter((fileName) => fileName.endsWith(".zip") && testAttachmentPaths.includes(fileName));
|
|
62
83
|
return {
|
|
63
84
|
videoUrls: videoFiles.map((fileName) => getFullUploadPath(fileName, uploadDir)),
|
|
64
|
-
|
|
85
|
+
// uploaded separately
|
|
86
|
+
summaryUrl: `${exports.UPLOAD_DOMAIN}/${uploadDir}/summary.json`,
|
|
87
|
+
// summaryUrl: getFullUploadPath("/test-results/summary.json", uploadDir),
|
|
65
88
|
traceFiles: traceFiles.map((fileName) => getFullUploadPath(fileName, uploadDir)),
|
|
66
89
|
};
|
|
67
90
|
}
|
package/dist/uploader/r2.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
interface FileMap {
|
|
2
2
|
[file: string]: string;
|
|
3
3
|
}
|
|
4
|
-
export declare function uploadDirectory({ sourceDir, destinationDir, uploadBucket, }: {
|
|
4
|
+
export declare function uploadDirectory({ sourceDir, fileList, destinationDir, uploadBucket, }: {
|
|
5
5
|
sourceDir: string;
|
|
6
|
+
fileList?: string[];
|
|
6
7
|
destinationDir: string;
|
|
7
8
|
uploadBucket: string;
|
|
8
9
|
}): Promise<FileMap>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"r2.d.ts","sourceRoot":"","sources":["../../src/uploader/r2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"r2.d.ts","sourceRoot":"","sources":["../../src/uploader/r2.ts"],"names":[],"mappings":"AAsBA,UAAU,OAAO;IACf,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AA2GD,wBAAsB,eAAe,CAAC,EACpC,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,GACb,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,OAAO,CAAC,CAYnB"}
|
package/dist/uploader/r2.js
CHANGED
|
@@ -60,7 +60,14 @@ const run = async (config) => {
|
|
|
60
60
|
secretAccessKey: config.secretAccessKey,
|
|
61
61
|
},
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
let files;
|
|
64
|
+
if (config.fileList) {
|
|
65
|
+
console.log("uploading single file: ", config.fileList[0]);
|
|
66
|
+
files = config.fileList;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
files = getFileList(config.sourceDir);
|
|
70
|
+
}
|
|
64
71
|
await Promise.all(files.map(async (file) => {
|
|
65
72
|
console.log(file);
|
|
66
73
|
const fileStream = fs.readFileSync(file);
|
|
@@ -115,7 +122,7 @@ const run = async (config) => {
|
|
|
115
122
|
}));
|
|
116
123
|
return urls;
|
|
117
124
|
};
|
|
118
|
-
async function uploadDirectory({ sourceDir, destinationDir, uploadBucket, }) {
|
|
125
|
+
async function uploadDirectory({ sourceDir, fileList, destinationDir, uploadBucket, }) {
|
|
119
126
|
let config = {
|
|
120
127
|
accountId: process.env.R2_ACCOUNT_ID,
|
|
121
128
|
accessKeyId: process.env.R2_ACCESS_KEY_ID,
|
|
@@ -123,6 +130,7 @@ async function uploadDirectory({ sourceDir, destinationDir, uploadBucket, }) {
|
|
|
123
130
|
bucket: uploadBucket,
|
|
124
131
|
sourceDir,
|
|
125
132
|
destinationDir,
|
|
133
|
+
fileList,
|
|
126
134
|
};
|
|
127
135
|
const uploadedFiles = await run(config);
|
|
128
136
|
return uploadedFiles;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"ts-morph": "^23.0.0",
|
|
42
42
|
"tsx": "^4.16.2",
|
|
43
43
|
"typescript": "^5.3.3",
|
|
44
|
-
"@empiricalrun/llm": "^0.7.
|
|
45
|
-
"@empiricalrun/reporter": "^0.17.
|
|
44
|
+
"@empiricalrun/llm": "^0.7.3",
|
|
45
|
+
"@empiricalrun/reporter": "^0.17.7"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/detect-port": "^1.3.5",
|