@empiricalrun/test-gen 0.71.1 → 0.72.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.
Files changed (141) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/actions/index.d.ts.map +1 -1
  3. package/dist/actions/index.js +0 -6
  4. package/dist/agent/browsing/index.d.ts.map +1 -1
  5. package/dist/agent/browsing/index.js +6 -14
  6. package/dist/agent/chat/agent-loop.d.ts +11 -9
  7. package/dist/agent/chat/agent-loop.d.ts.map +1 -1
  8. package/dist/agent/chat/agent-loop.js +20 -10
  9. package/dist/agent/chat/exports.d.ts +2 -2
  10. package/dist/agent/chat/exports.d.ts.map +1 -1
  11. package/dist/agent/chat/exports.js +6 -1
  12. package/dist/agent/chat/index.d.ts.map +1 -1
  13. package/dist/agent/chat/index.js +48 -13
  14. package/dist/agent/chat/prompt/index.d.ts +2 -2
  15. package/dist/agent/chat/prompt/index.d.ts.map +1 -1
  16. package/dist/agent/chat/prompt/index.js +2 -2
  17. package/dist/agent/chat/prompt/repo.d.ts +2 -2
  18. package/dist/agent/chat/prompt/repo.d.ts.map +1 -1
  19. package/dist/agent/chat/prompt/repo.js +20 -11
  20. package/dist/agent/chat/state.d.ts +2 -2
  21. package/dist/agent/chat/state.d.ts.map +1 -1
  22. package/dist/agent/chat/types.d.ts +0 -6
  23. package/dist/agent/chat/types.d.ts.map +1 -1
  24. package/dist/agent/chat/utils/tool-calls.d.ts +21 -0
  25. package/dist/agent/chat/utils/tool-calls.d.ts.map +1 -0
  26. package/dist/agent/chat/utils/tool-calls.js +64 -0
  27. package/dist/agent/chat/utils.d.ts +2 -4
  28. package/dist/agent/chat/utils.d.ts.map +1 -1
  29. package/dist/agent/chat/utils.js +5 -11
  30. package/dist/agent/codegen/repo-edit.d.ts.map +1 -1
  31. package/dist/agent/codegen/repo-edit.js +0 -4
  32. package/dist/agent/codegen/run.d.ts.map +1 -1
  33. package/dist/agent/codegen/run.js +0 -4
  34. package/dist/agent/codegen/utils.d.ts +1 -3
  35. package/dist/agent/codegen/utils.d.ts.map +1 -1
  36. package/dist/agent/codegen/utils.js +1 -2
  37. package/dist/agent/cua/index.d.ts +2 -1
  38. package/dist/agent/cua/index.d.ts.map +1 -1
  39. package/dist/agent/cua/index.js +4 -4
  40. package/dist/agent/master/browser-tests/index.spec.js +1 -1
  41. package/dist/agent/master/execute-browser-action.d.ts.map +1 -1
  42. package/dist/agent/master/execute-browser-action.js +1 -4
  43. package/dist/agent/master/run.d.ts.map +1 -1
  44. package/dist/agent/master/run.js +0 -19
  45. package/dist/agent/master/scroller.d.ts.map +1 -1
  46. package/dist/agent/master/scroller.js +0 -4
  47. package/dist/auth/api-client.d.ts.map +1 -1
  48. package/dist/auth/api-client.js +6 -2
  49. package/dist/bin/environments.d.ts +1 -1
  50. package/dist/bin/environments.d.ts.map +1 -1
  51. package/dist/bin/environments.js +70 -36
  52. package/dist/bin/index.js +2 -36
  53. package/dist/bin/logger/index.d.ts +0 -1
  54. package/dist/bin/logger/index.d.ts.map +1 -1
  55. package/dist/bin/logger/index.js +0 -16
  56. package/dist/bin/setup.d.ts.map +1 -1
  57. package/dist/bin/setup.js +10 -10
  58. package/dist/dashboard/index.d.ts +21 -0
  59. package/dist/dashboard/index.d.ts.map +1 -0
  60. package/dist/dashboard/index.js +83 -0
  61. package/dist/dashboard/totp.d.ts +2 -0
  62. package/dist/dashboard/totp.d.ts.map +1 -0
  63. package/dist/dashboard/totp.js +18 -0
  64. package/dist/file-info/file-system.d.ts +3 -0
  65. package/dist/file-info/file-system.d.ts.map +1 -0
  66. package/dist/{utils/file-tree.js → file-info/file-system.js} +2 -8
  67. package/dist/file-info/github.d.ts +3 -0
  68. package/dist/file-info/github.d.ts.map +1 -0
  69. package/dist/file-info/github.js +108 -0
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +0 -6
  72. package/dist/tools/commit-and-create-pr.js +2 -2
  73. package/dist/tools/definitions/index.d.ts +22 -0
  74. package/dist/tools/definitions/index.d.ts.map +1 -0
  75. package/dist/tools/definitions/index.js +61 -0
  76. package/dist/tools/definitions/run-test.d.ts +23 -0
  77. package/dist/tools/definitions/run-test.d.ts.map +1 -0
  78. package/dist/tools/definitions/run-test.js +28 -0
  79. package/dist/tools/definitions/str_replace_editor.d.ts +3 -0
  80. package/dist/tools/definitions/str_replace_editor.d.ts.map +1 -0
  81. package/dist/tools/definitions/str_replace_editor.js +74 -0
  82. package/dist/tools/definitions/test-gen-browser.d.ts +26 -0
  83. package/dist/tools/definitions/test-gen-browser.d.ts.map +1 -0
  84. package/dist/tools/definitions/test-gen-browser.js +88 -0
  85. package/dist/{tool-call-service/utils.d.ts → tools/definitions/utils/queue.d.ts} +6 -4
  86. package/dist/tools/definitions/utils/queue.d.ts.map +1 -0
  87. package/dist/{tool-call-service/utils.js → tools/definitions/utils/queue.js} +20 -19
  88. package/dist/tools/diagnosis-fetcher.js +1 -1
  89. package/dist/{tool-call-service → tools/executor}/index.d.ts +2 -7
  90. package/dist/tools/executor/index.d.ts.map +1 -0
  91. package/dist/{tool-call-service → tools/executor}/index.js +16 -30
  92. package/dist/tools/executor/utils/checkpoint.d.ts.map +1 -0
  93. package/dist/tools/executor/utils/git.d.ts.map +1 -0
  94. package/dist/{utils → tools/executor/utils}/git.js +5 -5
  95. package/dist/tools/executor/utils/index.d.ts.map +1 -0
  96. package/dist/tools/list-environments.js +1 -1
  97. package/dist/tools/{test-run.d.ts → run-test.d.ts} +1 -1
  98. package/dist/tools/run-test.d.ts.map +1 -0
  99. package/dist/tools/{test-run.js → run-test.js} +5 -24
  100. package/dist/tools/str_replace_editor.d.ts.map +1 -1
  101. package/dist/tools/str_replace_editor.js +6 -58
  102. package/dist/tools/test-gen-browser.d.ts.map +1 -1
  103. package/dist/tools/test-gen-browser.js +2 -83
  104. package/dist/tools/test-run-fetcher/index.js +1 -1
  105. package/dist/tools/upgrade-packages/index.js +2 -2
  106. package/dist/tools/upgrade-packages/utils.js +1 -1
  107. package/dist/types/index.d.ts +0 -8
  108. package/dist/types/index.d.ts.map +1 -1
  109. package/dist/utils/SQSClient.d.ts +14 -0
  110. package/dist/utils/SQSClient.d.ts.map +1 -0
  111. package/dist/utils/SQSClient.js +116 -0
  112. package/dist/utils/repo-tree.d.ts +1 -1
  113. package/dist/utils/repo-tree.d.ts.map +1 -1
  114. package/dist/utils/repo-tree.js +7 -7
  115. package/package.json +18 -10
  116. package/tsconfig.tsbuildinfo +1 -1
  117. package/dist/reporter/index.d.ts +0 -26
  118. package/dist/reporter/index.d.ts.map +0 -1
  119. package/dist/reporter/index.js +0 -149
  120. package/dist/reporter/lib.d.ts +0 -31
  121. package/dist/reporter/lib.d.ts.map +0 -1
  122. package/dist/reporter/lib.js +0 -71
  123. package/dist/tool-call-service/index.d.ts.map +0 -1
  124. package/dist/tool-call-service/utils.d.ts.map +0 -1
  125. package/dist/tools/test-run.d.ts.map +0 -1
  126. package/dist/tools/utils/index.d.ts.map +0 -1
  127. package/dist/uploader/index.d.ts +0 -26
  128. package/dist/uploader/index.d.ts.map +0 -1
  129. package/dist/uploader/index.js +0 -103
  130. package/dist/uploader/utils.d.ts +0 -8
  131. package/dist/uploader/utils.d.ts.map +0 -1
  132. package/dist/uploader/utils.js +0 -35
  133. package/dist/utils/checkpoint.d.ts.map +0 -1
  134. package/dist/utils/file-tree.d.ts +0 -3
  135. package/dist/utils/file-tree.d.ts.map +0 -1
  136. package/dist/utils/git.d.ts.map +0 -1
  137. /package/dist/{utils → tools/executor/utils}/checkpoint.d.ts +0 -0
  138. /package/dist/{utils → tools/executor/utils}/checkpoint.js +0 -0
  139. /package/dist/{utils → tools/executor/utils}/git.d.ts +0 -0
  140. /package/dist/tools/{utils → executor/utils}/index.d.ts +0 -0
  141. /package/dist/tools/{utils → executor/utils}/index.js +0 -0
@@ -1,26 +0,0 @@
1
- import { Reporter } from "./lib";
2
- type ReporterConfigType = {
3
- testSessionId: number;
4
- generationId: number;
5
- projectRepoName: string;
6
- };
7
- export declare function getReporter(): Reporter | undefined;
8
- /**
9
- * function will upload videos and json summary of test results to r2 and report them to reporter.
10
- * method won't throw error if it fails to report
11
- */
12
- export declare function setReporterConfig(config: ReporterConfigType): void;
13
- export declare class TestGenUpdatesReporter {
14
- private repoDir;
15
- constructor();
16
- reportGenAssets({ projectRepoName, testName, }: {
17
- projectRepoName: string;
18
- testName: string;
19
- }): Promise<void>;
20
- sendCurrentView(buffer: Buffer): Promise<void>;
21
- sendMessage(message: string): Promise<void>;
22
- sendLogUrl(message: string): Promise<void>;
23
- sendAgentTraceUrl(message: string): Promise<void>;
24
- }
25
- export {};
26
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAAkB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjD,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAKF,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAUlD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAElE;AAED,qBAAa,sBAAsB;IACjC,OAAO,CAAC,OAAO,CAAS;;IAKlB,eAAe,CAAC,EACpB,eAAe,EACf,QAAQ,GACT,EAAE;QACD,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;KAClB;IAgDK,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8C9C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY1C,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWxD"}
@@ -1,149 +0,0 @@
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.TestGenUpdatesReporter = void 0;
7
- exports.getReporter = getReporter;
8
- exports.setReporterConfig = setReporterConfig;
9
- const r2_uploader_1 = require("@empiricalrun/r2-uploader");
10
- const fs_1 = __importDefault(require("fs"));
11
- const path_1 = __importDefault(require("path"));
12
- const logger_1 = require("../bin/logger");
13
- const uploader_1 = require("../uploader");
14
- const lib_1 = require("./lib");
15
- let reporterInstance = undefined;
16
- let reporterConfig = undefined;
17
- function getReporter() {
18
- // if no config is set, return undefined
19
- if (!reporterConfig) {
20
- console.warn("initialising reporter without any config");
21
- }
22
- // initialise once config is set
23
- if (!reporterInstance && reporterConfig) {
24
- reporterInstance = new lib_1.Reporter(reporterConfig);
25
- }
26
- return reporterInstance;
27
- }
28
- /**
29
- * function will upload videos and json summary of test results to r2 and report them to reporter.
30
- * method won't throw error if it fails to report
31
- */
32
- function setReporterConfig(config) {
33
- reporterConfig = config;
34
- }
35
- class TestGenUpdatesReporter {
36
- repoDir;
37
- constructor() {
38
- this.repoDir = process.cwd();
39
- }
40
- async reportGenAssets({ projectRepoName, testName, }) {
41
- const logger = new logger_1.CustomLogger();
42
- try {
43
- if (!(0, uploader_1.checkIfResultsUploadAllowed)()) {
44
- logger.log("Skipped uploading generated test video");
45
- return;
46
- }
47
- console.log("Uploading assets for the test genearation");
48
- const { videoUrls, traceFiles } = await (0, uploader_1.uploadTestResultsUsingPrjRepo)({
49
- projectRepoName,
50
- testName,
51
- repoDir: this.repoDir,
52
- });
53
- const reporter = getReporter();
54
- await Promise.allSettled([
55
- ...(videoUrls.length
56
- ? [
57
- reporter?.report(new lib_1.MessageBuilder({
58
- type: "video",
59
- message: JSON.stringify({
60
- type: "video",
61
- videoUrls,
62
- }),
63
- })),
64
- ]
65
- : []),
66
- ...(traceFiles.length
67
- ? [
68
- reporter?.report(new lib_1.MessageBuilder({
69
- type: "pw-trace",
70
- message: JSON.stringify({
71
- type: "trace",
72
- traceFiles,
73
- }),
74
- })),
75
- ]
76
- : []),
77
- ]);
78
- }
79
- catch (err) {
80
- logger.error("Failed to report test results");
81
- console.error(err);
82
- }
83
- }
84
- async sendCurrentView(buffer) {
85
- const logger = new logger_1.CustomLogger();
86
- if (!(0, uploader_1.checkIfResultsUploadAllowed)()) {
87
- logger.log("Skipped uploading current view screenshot");
88
- return;
89
- }
90
- if (!reporterConfig?.projectRepoName) {
91
- logger.log("Reporter config is not set skipping screenshot uploads.");
92
- return;
93
- }
94
- try {
95
- // upload current screenshot to r2 and report it to reporter
96
- if (!fs_1.default.existsSync(path_1.default.join(this.repoDir, "gen-assets"))) {
97
- fs_1.default.mkdirSync(path_1.default.join(this.repoDir, "gen-assets"));
98
- }
99
- fs_1.default.writeFileSync(path_1.default.join(this.repoDir, "gen-assets", `current-view-${Date.now()}.png`), buffer);
100
- const uploadDir = (0, uploader_1.getUploadPathForRun)(reporterConfig?.projectRepoName);
101
- const files = await (0, r2_uploader_1.uploadDirectory)({
102
- sourceDir: path_1.default.join(this.repoDir, "gen-assets"),
103
- destinationDir: uploadDir,
104
- uploadBucket: uploader_1.UPLOAD_BUCKET,
105
- });
106
- const filePath = Object.keys(files)[0];
107
- const relativeFilePath = filePath.replace(path_1.default.join(this.repoDir, "gen-assets"), "");
108
- const url = `${uploader_1.UPLOAD_DOMAIN}/${uploadDir}${relativeFilePath}`;
109
- await getReporter()?.report(new lib_1.MessageBuilder({
110
- type: "current-snapshot",
111
- message: JSON.stringify({ type: "current-view", url }),
112
- }));
113
- fs_1.default.rmdirSync(path_1.default.join(this.repoDir, "gen-assets"), {
114
- recursive: true,
115
- });
116
- }
117
- catch (e) {
118
- console.warn("Failed to upload current view screenshot", e);
119
- }
120
- }
121
- async sendMessage(message) {
122
- const reporter = getReporter();
123
- if (reporter) {
124
- await reporter.report(new lib_1.MessageBuilder({
125
- type: "message",
126
- message,
127
- }));
128
- }
129
- }
130
- async sendLogUrl(message) {
131
- const reporter = getReporter();
132
- if (reporter) {
133
- await reporter.report(new lib_1.MessageBuilder({
134
- type: "log-url",
135
- message,
136
- }));
137
- }
138
- }
139
- async sendAgentTraceUrl(message) {
140
- const reporter = getReporter();
141
- if (reporter) {
142
- await reporter.report(new lib_1.MessageBuilder({
143
- type: "agent-trace",
144
- message,
145
- }));
146
- }
147
- }
148
- }
149
- exports.TestGenUpdatesReporter = TestGenUpdatesReporter;
@@ -1,31 +0,0 @@
1
- type DashboardMessagePayload = {
2
- message: string;
3
- messageType: "message" | "agent-trace" | "current-snapshot" | "video" | "pw-trace" | "log-url" | "commit-id";
4
- pull_request?: string;
5
- testCaseName?: string;
6
- testCaseId?: number;
7
- projectRepoName?: string;
8
- testSessionId?: number;
9
- generationId?: number;
10
- };
11
- export declare class MessageBuilder {
12
- private props;
13
- constructor(props: {
14
- message: string;
15
- type: DashboardMessagePayload["messageType"];
16
- });
17
- buildMessage(dashboardOptions?: {
18
- override?: Partial<DashboardMessagePayload>;
19
- }): DashboardMessagePayload;
20
- }
21
- export declare class Reporter {
22
- private config;
23
- constructor(config: {
24
- testSessionId: number;
25
- generationId: number;
26
- });
27
- report(messageBuilder: MessageBuilder): Promise<void>;
28
- private sendMessageToDashboard;
29
- }
30
- export {};
31
- //# sourceMappingURL=lib.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/reporter/lib.ts"],"names":[],"mappings":"AAMA,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EACP,SAAS,GACT,aAAa,GACb,kBAAkB,GAClB,OAAO,GACP,UAAU,GACV,SAAS,GACT,WAAW,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,qBAAa,cAAc;IAEvB,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,uBAAuB,CAAC,aAAa,CAAC,CAAC;KAC9C;IAGH,YAAY,CAAC,gBAAgB,CAAC,EAAE;QAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;KAC7C,GAAG,uBAAuB;CAO5B;AAED,qBAAa,QAAQ;IAEjB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE;QACd,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;KACtB;IAGG,MAAM,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;YAc7C,sBAAsB;CAkCrC"}
@@ -1,71 +0,0 @@
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.Reporter = exports.MessageBuilder = void 0;
7
- const async_retry_1 = __importDefault(require("async-retry"));
8
- const DASHBOARD_DOMAIN = process.env.DASHBOARD_DOMAIN ||
9
- (process.env.CI === "true" ? "https://dash.empirical.run" : "");
10
- class MessageBuilder {
11
- props;
12
- constructor(props) {
13
- this.props = props;
14
- }
15
- buildMessage(dashboardOptions) {
16
- return {
17
- ...dashboardOptions?.override,
18
- message: this.props.message,
19
- messageType: this.props.type,
20
- };
21
- }
22
- }
23
- exports.MessageBuilder = MessageBuilder;
24
- class Reporter {
25
- config;
26
- constructor(config) {
27
- this.config = config;
28
- }
29
- async report(messageBuilder) {
30
- const message = messageBuilder.buildMessage({
31
- override: {
32
- testSessionId: this.config.testSessionId,
33
- generationId: this.config.generationId,
34
- },
35
- });
36
- if (!message) {
37
- console.info("No message found. Skipping sending message to dashboard");
38
- return;
39
- }
40
- await this.sendMessageToDashboard(message);
41
- }
42
- async sendMessageToDashboard(message) {
43
- if (!DASHBOARD_DOMAIN) {
44
- console.warn("No dashboard domain found. Skipping send message to dashboard");
45
- return;
46
- }
47
- try {
48
- await (0, async_retry_1.default)(async () => {
49
- const body = JSON.stringify(message);
50
- await fetch(`${DASHBOARD_DOMAIN}/api/github/updates`, {
51
- method: "POST",
52
- headers: {
53
- "Content-Type": "application/json",
54
- Authorization: `Bearer ${process.env.EMPIRICALRUN_API_KEY}`,
55
- },
56
- body,
57
- });
58
- }, {
59
- retries: 3,
60
- minTimeout: 1000,
61
- maxTimeout: 60_000,
62
- factor: 3,
63
- });
64
- }
65
- catch (e) {
66
- console.error(`Error sending message to Dashboard: ${e.code}`);
67
- console.error(e.message);
68
- }
69
- }
70
- }
71
- exports.Reporter = Reporter;
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tool-call-service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAEL,eAAe,EACf,UAAU,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,mBAAmB,EACnB,IAAI,EACJ,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAmBpC,KAAK,aAAa,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC;CAC5B,CAAC;AAEF,qBAAa,eAAe;IAC1B,KAAK,EAAE,IAAI,EAAE,CAAM;IACnB,aAAa,EAAE,aAAa,CAAM;IAClC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,mBAAmB,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAA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,4BAA4B,CAChD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,cAAc,iBAiBxB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-run.d.ts","sourceRoot":"","sources":["../../src/tools/test-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AAwDnE,eAAO,MAAM,WAAW,EAAE,IAqFzB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAsB,oBAAoB,CAAC,CAAC,EAAE,EAC5C,IAAI,EACJ,MAAc,EACd,IAAI,EACJ,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,CAAC,CAAC,CAmBb;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,EACvC,MAAM,EACN,GAAG,EACH,IAAI,EACJ,MAAM,GACP,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,CAAC,CAAC,CAYb;AAGD,eAAO,MAAM,eAAe,+CAA+C,CAAC;AAG5E,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAiB1D;AAGD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACvB;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AAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAyBnD"}
@@ -1,26 +0,0 @@
1
- export declare const UPLOAD_BUCKET = "test-report";
2
- export declare const UPLOAD_DOMAIN = "https://reports.empirical.run";
3
- export declare function getFullUploadPath(repoDir: string, filePath: string, uploadDir: string): string;
4
- export declare function getRelativeUploadPath(filePath: string, repoDir: string): string;
5
- /**
6
- * Function to upload test results to R2 using the project repo name and test name.
7
- * This function uploads both the JSON summary of test results and associated video files.
8
- * @param {Object} params - The parameters for the function.
9
- * @param {string} params.projectRepoName - Name of the project repository.
10
- * @param {string} params.testName - Name of the testcase which called this test-gen.
11
- * @returns {Promise<Object>} An object containing arrays of video URLs and the summary JSON URL.
12
- * @returns {string[]} returns.videoUrls - URLs of the uploaded video files.
13
- * @returns {string} returns.summaryUrl - URL of the uploaded summary JSON file.
14
- */
15
- export declare function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, repoDir, }: {
16
- projectRepoName: string;
17
- testName: string;
18
- repoDir: string;
19
- }): Promise<{
20
- videoUrls: string[];
21
- summaryUrl: string;
22
- traceFiles: string[];
23
- }>;
24
- export declare function getUploadPathForRun(projectRepoName: string): string;
25
- export declare function checkIfResultsUploadAllowed(): string | undefined;
26
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,CAC/B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,UAKlB;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAEtE;AAED;;;;;;;;;GASG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,eAAe,EACf,QAAQ,EACR,OAAO,GACR,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC;IACV,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC,CAiED;AAED,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,UAM1D;AAED,wBAAgB,2BAA2B,uBAQ1C"}
@@ -1,103 +0,0 @@
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.UPLOAD_DOMAIN = exports.UPLOAD_BUCKET = void 0;
7
- exports.getFullUploadPath = getFullUploadPath;
8
- exports.getRelativeUploadPath = getRelativeUploadPath;
9
- exports.uploadTestResultsUsingPrjRepo = uploadTestResultsUsingPrjRepo;
10
- exports.getUploadPathForRun = getUploadPathForRun;
11
- exports.checkIfResultsUploadAllowed = checkIfResultsUploadAllowed;
12
- const r2_uploader_1 = require("@empiricalrun/r2-uploader");
13
- const path_1 = __importDefault(require("path"));
14
- const utils_1 = require("./utils");
15
- // json summary of test results
16
- // originally we used to upload test results directory for this
17
- // but now we have our test results (per testcase artifacts) inside playwright-report/data
18
- // but we also have summary.json in playwright-report/
19
- // we can avoid html report upload here if we don't want
20
- const PLAYWRIGHT_REPORT_DATA = "playwright-report/data";
21
- exports.UPLOAD_BUCKET = "test-report";
22
- exports.UPLOAD_DOMAIN = "https://reports.empirical.run"; // domain based on bucket mentioned above
23
- const uploadId = crypto.randomUUID();
24
- function getFullUploadPath(repoDir, filePath, uploadDir) {
25
- // remove the source dir from the file path - only keep the relative path
26
- const relativeFilePath = getRelativeUploadPath(filePath, repoDir);
27
- return `${exports.UPLOAD_DOMAIN}/${uploadDir}${relativeFilePath}`;
28
- }
29
- function getRelativeUploadPath(filePath, repoDir) {
30
- return filePath.replace(path_1.default.join(repoDir, PLAYWRIGHT_REPORT_DATA), "");
31
- }
32
- /**
33
- * Function to upload test results to R2 using the project repo name and test name.
34
- * This function uploads both the JSON summary of test results and associated video files.
35
- * @param {Object} params - The parameters for the function.
36
- * @param {string} params.projectRepoName - Name of the project repository.
37
- * @param {string} params.testName - Name of the testcase which called this test-gen.
38
- * @returns {Promise<Object>} An object containing arrays of video URLs and the summary JSON URL.
39
- * @returns {string[]} returns.videoUrls - URLs of the uploaded video files.
40
- * @returns {string} returns.summaryUrl - URL of the uploaded summary JSON file.
41
- */
42
- async function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, repoDir, }) {
43
- const uploadDir = getUploadPathForRun(projectRepoName);
44
- console.log("Current directory for assets upload", repoDir);
45
- const files = await (0, r2_uploader_1.uploadDirectory)({
46
- sourceDir: path_1.default.join(repoDir, PLAYWRIGHT_REPORT_DATA),
47
- destinationDir: uploadDir,
48
- uploadBucket: exports.UPLOAD_BUCKET,
49
- });
50
- // upload summary.json
51
- await (0, r2_uploader_1.uploadDirectory)({
52
- sourceDir: path_1.default.join(repoDir, "playwright-report"),
53
- // TODO: this will only work for repos that use playwright 1.47.1
54
- fileList: [path_1.default.join(repoDir, "playwright-report", "summary.json")],
55
- destinationDir: uploadDir,
56
- uploadBucket: exports.UPLOAD_BUCKET,
57
- });
58
- // fileNames are relative upload paths
59
- const fileNames = Object.keys(files);
60
- console.log("Uploaded files", fileNames.map((f) => getFullUploadPath(repoDir, f, uploadDir)));
61
- const defaultLocation = path_1.default.join(repoDir, "playwright-report", "summary.json");
62
- const results = (0, utils_1.parseJsonReport)(defaultLocation);
63
- const flatTestsList = (0, utils_1.getFlattenedTestList)(results.suites);
64
- const testAttachmentPaths = [];
65
- for (const test of flatTestsList) {
66
- if (test.title === testName) {
67
- if (test.tests[0]) {
68
- if (test.tests[0].results[0]) {
69
- // results array is basically made by retries
70
- for (const attachments of test.tests[0].results[0].attachments) {
71
- if (attachments.path) {
72
- testAttachmentPaths.push(getRelativeUploadPath(attachments.path, repoDir));
73
- }
74
- }
75
- }
76
- }
77
- }
78
- }
79
- const videoFiles = fileNames.filter((fileName) => fileName.endsWith(".webm") && testAttachmentPaths.includes(fileName));
80
- const traceFiles = fileNames.filter((fileName) => fileName.endsWith(".zip") && testAttachmentPaths.includes(fileName));
81
- console.log("videoFiles", videoFiles);
82
- console.log("traceFiles", traceFiles);
83
- return {
84
- videoUrls: videoFiles
85
- .map((fileName) => getFullUploadPath(repoDir, fileName, uploadDir))
86
- .filter((url) => !!url),
87
- summaryUrl: `${exports.UPLOAD_DOMAIN}/${uploadDir}/summary.json`,
88
- traceFiles: traceFiles
89
- .map((fileName) => getFullUploadPath(repoDir, fileName, uploadDir))
90
- .filter((url) => !!url),
91
- };
92
- }
93
- function getUploadPathForRun(projectRepoName) {
94
- const uploadDir = `test-generation/${projectRepoName.replace("-tests", "")}/${uploadId}`;
95
- return uploadDir;
96
- }
97
- function checkIfResultsUploadAllowed() {
98
- // TODO: check for valid R2 credentials
99
- // check for project repo name, and r2 creds
100
- return (process.env.R2_ACCOUNT_ID &&
101
- process.env.R2_ACCESS_KEY_ID &&
102
- process.env.R2_SECRET_ACCESS_KEY);
103
- }
@@ -1,8 +0,0 @@
1
- import type { JSONReportSpec, JSONReportSuite } from "@playwright/test/reporter";
2
- export declare function parseJsonReport<T>(srcFile: string): T;
3
- export type flattenedSpecT = JSONReportSpec & {
4
- nesting: string[];
5
- suitesString: string;
6
- };
7
- export declare const getFlattenedTestList: (suites: JSONReportSuite[]) => flattenedSpecT[];
8
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/uploader/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAChB,MAAM,2BAA2B,CAAC;AAGnC,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAErD;AAMD,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG;IAC5C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,eAAe,EAAE,KACxB,cAAc,EA4BhB,CAAC"}
@@ -1,35 +0,0 @@
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.getFlattenedTestList = void 0;
7
- exports.parseJsonReport = parseJsonReport;
8
- const fs_1 = __importDefault(require("fs"));
9
- function parseJsonReport(srcFile) {
10
- return JSON.parse(fs_1.default.readFileSync(srcFile, { encoding: "utf-8" }));
11
- }
12
- const getFlattenedTestList = (suites) => {
13
- let flattenedSpecs = [];
14
- const traverseSuites = (suite, nesting = []) => {
15
- nesting = [...nesting, suite.title];
16
- flattenedSpecs.push(...suite.specs.map((spec) => {
17
- const finalNesting = [...nesting, spec.title];
18
- const suites = nesting.slice(1);
19
- const suitesString = suites.length ? suites.join("~~") : "~~";
20
- return {
21
- ...spec,
22
- nesting: finalNesting,
23
- suitesString,
24
- };
25
- }));
26
- // Traverse nested suites recursively
27
- if (suite.suites && suite.suites.length > 0) {
28
- suite.suites.forEach((suite) => traverseSuites(suite, nesting));
29
- }
30
- };
31
- // Start the traversal from the top-level suites
32
- suites.forEach((suite) => traverseSuites(suite));
33
- return flattenedSpecs;
34
- };
35
- exports.getFlattenedTestList = getFlattenedTestList;
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../../src/utils/checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAIzD,wBAAsB,gBAAgB,CAAC,EACrC,SAAS,EACT,UAAU,EACV,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAyBA"}
@@ -1,3 +0,0 @@
1
- import { FileInfo } from "../types";
2
- export declare function getFileInfoFromFS(directory: string): Promise<FileInfo>;
3
- //# sourceMappingURL=file-tree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-tree.d.ts","sourceRoot":"","sources":["../../src/utils/file-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsC5E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAOA,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAMhE;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAe1E;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAQnE;AAED,wBAAsB,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,oBAcvE;AAED,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,mBAO1D;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAE/D;AAED,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,UAAU,EACV,KAAK,EACL,QAAQ,GACT,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAIA;AAED,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,qBAUhD;AAED,wBAAsB,gBAAgB,CAAC,EACrC,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,oBA+BA;AAED,wBAAsB,YAAY,CAAC,EACjC,QAAQ,EACR,UAAU,EACV,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,iBAoBA"}
File without changes
File without changes
File without changes