@empiricalrun/playwright-utils 0.22.6 → 0.23.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 +19 -0
- package/bundled/test-gen/actions/assert.d.ts +4 -0
- package/bundled/test-gen/actions/assert.d.ts.map +1 -0
- package/bundled/test-gen/actions/assert.js +50 -0
- package/bundled/test-gen/actions/click.d.ts +4 -0
- package/bundled/test-gen/actions/click.d.ts.map +1 -0
- package/bundled/test-gen/actions/click.js +51 -0
- package/bundled/test-gen/actions/constants/index.d.ts +2 -0
- package/bundled/test-gen/actions/constants/index.d.ts.map +1 -0
- package/bundled/test-gen/actions/constants/index.js +4 -0
- package/bundled/test-gen/actions/done.d.ts +4 -0
- package/bundled/test-gen/actions/done.d.ts.map +1 -0
- package/bundled/test-gen/actions/done.js +30 -0
- package/bundled/test-gen/actions/fill.d.ts +4 -0
- package/bundled/test-gen/actions/fill.d.ts.map +1 -0
- package/bundled/test-gen/actions/fill.js +82 -0
- package/bundled/test-gen/actions/goto.d.ts +4 -0
- package/bundled/test-gen/actions/goto.d.ts.map +1 -0
- package/bundled/test-gen/actions/goto.js +47 -0
- package/bundled/test-gen/actions/hover.d.ts +4 -0
- package/bundled/test-gen/actions/hover.d.ts.map +1 -0
- package/bundled/test-gen/actions/hover.js +51 -0
- package/bundled/test-gen/actions/index.d.ts +30 -0
- package/bundled/test-gen/actions/index.d.ts.map +1 -0
- package/bundled/test-gen/actions/index.js +159 -0
- package/bundled/test-gen/actions/next-task.d.ts +53 -0
- package/bundled/test-gen/actions/next-task.d.ts.map +1 -0
- package/bundled/test-gen/actions/next-task.js +58 -0
- package/bundled/test-gen/actions/press.d.ts +4 -0
- package/bundled/test-gen/actions/press.d.ts.map +1 -0
- package/bundled/test-gen/actions/press.js +56 -0
- package/bundled/test-gen/actions/skill.d.ts +21 -0
- package/bundled/test-gen/actions/skill.d.ts.map +1 -0
- package/bundled/test-gen/actions/skill.js +127 -0
- package/bundled/test-gen/actions/text-content.d.ts +4 -0
- package/bundled/test-gen/actions/text-content.d.ts.map +1 -0
- package/bundled/test-gen/actions/text-content.js +58 -0
- package/bundled/test-gen/actions/utils/index.d.ts +10 -0
- package/bundled/test-gen/actions/utils/index.d.ts.map +1 -0
- package/bundled/test-gen/actions/utils/index.js +109 -0
- package/bundled/test-gen/agent/browsing/index.d.ts +15 -0
- package/bundled/test-gen/agent/browsing/index.d.ts.map +1 -0
- package/bundled/test-gen/agent/browsing/index.js +68 -0
- package/bundled/test-gen/agent/browsing/run.d.ts +19 -0
- package/bundled/test-gen/agent/browsing/run.d.ts.map +1 -0
- package/bundled/test-gen/agent/browsing/run.js +88 -0
- package/bundled/test-gen/agent/browsing/utils.d.ts +41 -0
- package/bundled/test-gen/agent/browsing/utils.d.ts.map +1 -0
- package/bundled/test-gen/agent/browsing/utils.js +406 -0
- package/bundled/test-gen/agent/codegen/create-test-block.d.ts +9 -0
- package/bundled/test-gen/agent/codegen/create-test-block.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/create-test-block.js +63 -0
- package/bundled/test-gen/agent/codegen/fix-ts-errors.d.ts +13 -0
- package/bundled/test-gen/agent/codegen/fix-ts-errors.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/fix-ts-errors.js +80 -0
- package/bundled/test-gen/agent/codegen/generate-code-apply-changes.d.ts +13 -0
- package/bundled/test-gen/agent/codegen/generate-code-apply-changes.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/generate-code-apply-changes.js +381 -0
- package/bundled/test-gen/agent/codegen/lexical-scoped-vars.d.ts +9 -0
- package/bundled/test-gen/agent/codegen/lexical-scoped-vars.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/lexical-scoped-vars.js +56 -0
- package/bundled/test-gen/agent/codegen/repo-edit.d.ts +23 -0
- package/bundled/test-gen/agent/codegen/repo-edit.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/repo-edit.js +86 -0
- package/bundled/test-gen/agent/codegen/run.d.ts +16 -0
- package/bundled/test-gen/agent/codegen/run.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/run.js +119 -0
- package/bundled/test-gen/agent/codegen/skills-retriever.d.ts +26 -0
- package/bundled/test-gen/agent/codegen/skills-retriever.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/skills-retriever.js +93 -0
- package/bundled/test-gen/agent/codegen/test-update-feedback.d.ts +12 -0
- package/bundled/test-gen/agent/codegen/test-update-feedback.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/test-update-feedback.js +50 -0
- package/bundled/test-gen/agent/codegen/types.d.ts +25 -0
- package/bundled/test-gen/agent/codegen/types.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/types.js +8 -0
- package/bundled/test-gen/agent/codegen/update-flow.d.ts +34 -0
- package/bundled/test-gen/agent/codegen/update-flow.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/update-flow.js +300 -0
- package/bundled/test-gen/agent/codegen/use-skill.d.ts +11 -0
- package/bundled/test-gen/agent/codegen/use-skill.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/use-skill.js +54 -0
- package/bundled/test-gen/agent/codegen/utils.d.ts +126 -0
- package/bundled/test-gen/agent/codegen/utils.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/utils.js +416 -0
- package/bundled/test-gen/agent/diagnosis-agent/index.d.ts +18 -0
- package/bundled/test-gen/agent/diagnosis-agent/index.d.ts.map +1 -0
- package/bundled/test-gen/agent/diagnosis-agent/index.js +105 -0
- package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.d.ts +9 -0
- package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.d.ts.map +1 -0
- package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.js +31 -0
- package/bundled/test-gen/agent/enrich-prompt/index.d.ts +12 -0
- package/bundled/test-gen/agent/enrich-prompt/index.d.ts.map +1 -0
- package/bundled/test-gen/agent/enrich-prompt/index.js +81 -0
- package/bundled/test-gen/agent/enrich-prompt/utils.d.ts +6 -0
- package/bundled/test-gen/agent/enrich-prompt/utils.d.ts.map +1 -0
- package/bundled/test-gen/agent/enrich-prompt/utils.js +12 -0
- package/bundled/test-gen/agent/infer-agent/index.d.ts +10 -0
- package/bundled/test-gen/agent/infer-agent/index.d.ts.map +1 -0
- package/bundled/test-gen/agent/infer-agent/index.js +70 -0
- package/bundled/test-gen/agent/master/action-tool-calls.d.ts +42 -0
- package/bundled/test-gen/agent/master/action-tool-calls.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/action-tool-calls.js +87 -0
- package/bundled/test-gen/agent/master/browser-tests/fixtures.d.ts +9 -0
- package/bundled/test-gen/agent/master/browser-tests/fixtures.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/browser-tests/fixtures.js +33 -0
- package/bundled/test-gen/agent/master/browser-tests/index.spec.d.ts +2 -0
- package/bundled/test-gen/agent/master/browser-tests/index.spec.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/browser-tests/index.spec.js +113 -0
- package/bundled/test-gen/agent/master/browser-tests/skills.spec.d.ts +2 -0
- package/bundled/test-gen/agent/master/browser-tests/skills.spec.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/browser-tests/skills.spec.js +109 -0
- package/bundled/test-gen/agent/master/element-annotation.d.ts +30 -0
- package/bundled/test-gen/agent/master/element-annotation.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/element-annotation.js +195 -0
- package/bundled/test-gen/agent/master/execute-browser-action.d.ts +24 -0
- package/bundled/test-gen/agent/master/execute-browser-action.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/execute-browser-action.js +124 -0
- package/bundled/test-gen/agent/master/execute-skill-action.d.ts +11 -0
- package/bundled/test-gen/agent/master/execute-skill-action.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/execute-skill-action.js +25 -0
- package/bundled/test-gen/agent/master/icon-descriptor/index.d.ts +22 -0
- package/bundled/test-gen/agent/master/icon-descriptor/index.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/icon-descriptor/index.js +250 -0
- package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.d.ts +2 -0
- package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.js +248 -0
- package/bundled/test-gen/agent/master/next-action.d.ts +22 -0
- package/bundled/test-gen/agent/master/next-action.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/next-action.js +104 -0
- package/bundled/test-gen/agent/master/planner.d.ts +15 -0
- package/bundled/test-gen/agent/master/planner.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/planner.js +144 -0
- package/bundled/test-gen/agent/master/run.d.ts +15 -0
- package/bundled/test-gen/agent/master/run.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/run.js +274 -0
- package/bundled/test-gen/agent/master/scroller.d.ts +15 -0
- package/bundled/test-gen/agent/master/scroller.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/scroller.js +375 -0
- package/bundled/test-gen/agent/master/with-hints.d.ts +17 -0
- package/bundled/test-gen/agent/master/with-hints.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/with-hints.js +102 -0
- package/bundled/test-gen/agent/planner/run-time-planner.d.ts +15 -0
- package/bundled/test-gen/agent/planner/run-time-planner.d.ts.map +1 -0
- package/bundled/test-gen/agent/planner/run-time-planner.js +100 -0
- package/bundled/test-gen/agent/planner/run.d.ts +7 -0
- package/bundled/test-gen/agent/planner/run.d.ts.map +1 -0
- package/bundled/test-gen/agent/planner/run.js +127 -0
- package/bundled/test-gen/agent/utils.d.ts +2 -0
- package/bundled/test-gen/agent/utils.d.ts.map +1 -0
- package/bundled/test-gen/agent/utils.js +12 -0
- package/bundled/test-gen/bin/index.d.ts +3 -0
- package/bundled/test-gen/bin/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/index.js +212 -0
- package/bundled/test-gen/bin/logger/index.d.ts +14 -0
- package/bundled/test-gen/bin/logger/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/logger/index.js +57 -0
- package/bundled/test-gen/bin/utils/context.d.ts +13 -0
- package/bundled/test-gen/bin/utils/context.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/context.js +67 -0
- package/bundled/test-gen/bin/utils/fs/index.d.ts +6 -0
- package/bundled/test-gen/bin/utils/fs/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/fs/index.js +63 -0
- package/bundled/test-gen/bin/utils/index.d.ts +9 -0
- package/bundled/test-gen/bin/utils/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/index.js +64 -0
- package/bundled/test-gen/bin/utils/platform/web/index.d.ts +78 -0
- package/bundled/test-gen/bin/utils/platform/web/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/platform/web/index.js +544 -0
- package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.d.ts +2 -0
- package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.js +7 -0
- package/bundled/test-gen/bin/utils/scenarios/index.d.ts +6 -0
- package/bundled/test-gen/bin/utils/scenarios/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/scenarios/index.js +57 -0
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.js +615 -0
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.d.ts +2 -0
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.d.ts.map +1 -0
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.js +207 -0
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.ts +332 -0
- package/bundled/test-gen/constants/index.d.ts +7 -0
- package/bundled/test-gen/constants/index.d.ts.map +1 -0
- package/bundled/test-gen/constants/index.js +18 -0
- package/bundled/test-gen/errors/index.d.ts +5 -0
- package/bundled/test-gen/errors/index.d.ts.map +1 -0
- package/bundled/test-gen/errors/index.js +9 -0
- package/bundled/test-gen/evals/add-scenario-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/add-scenario-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/add-scenario-agent.evals.js +44 -0
- package/bundled/test-gen/evals/append-create-test-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/append-create-test-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/append-create-test-agent.evals.js +117 -0
- package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.js +36 -0
- package/bundled/test-gen/evals/infer-master-or-code-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/infer-master-or-code-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/infer-master-or-code-agent.evals.js +22 -0
- package/bundled/test-gen/evals/master-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/master-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/master-agent.evals.js +35 -0
- package/bundled/test-gen/evals/type.d.ts +12 -0
- package/bundled/test-gen/evals/type.d.ts.map +1 -0
- package/bundled/test-gen/evals/type.js +2 -0
- package/bundled/test-gen/evals/update-scenario-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/update-scenario-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/update-scenario-agent.evals.js +47 -0
- package/bundled/test-gen/file/client.d.ts +14 -0
- package/bundled/test-gen/file/client.d.ts.map +1 -0
- package/bundled/test-gen/file/client.js +48 -0
- package/bundled/test-gen/file/server.d.ts +13 -0
- package/bundled/test-gen/file/server.d.ts.map +1 -0
- package/bundled/test-gen/file/server.js +52 -0
- package/bundled/test-gen/human-in-the-loop/cli.d.ts +2 -0
- package/bundled/test-gen/human-in-the-loop/cli.d.ts.map +1 -0
- package/bundled/test-gen/human-in-the-loop/cli.js +24 -0
- package/bundled/test-gen/human-in-the-loop/index.d.ts +12 -0
- package/bundled/test-gen/human-in-the-loop/index.d.ts.map +1 -0
- package/bundled/test-gen/human-in-the-loop/index.js +30 -0
- package/bundled/test-gen/human-in-the-loop/ipc.d.ts +4 -0
- package/bundled/test-gen/human-in-the-loop/ipc.d.ts.map +1 -0
- package/bundled/test-gen/human-in-the-loop/ipc.js +47 -0
- package/bundled/test-gen/index.d.ts +4 -0
- package/bundled/test-gen/index.d.ts.map +1 -0
- package/bundled/test-gen/index.js +55 -0
- package/bundled/test-gen/package.json +106 -0
- package/bundled/test-gen/page/index.d.ts +11 -0
- package/bundled/test-gen/page/index.d.ts.map +1 -0
- package/bundled/test-gen/page/index.js +16 -0
- package/bundled/test-gen/prompts/lib/ts-transformer.d.ts +4 -0
- package/bundled/test-gen/prompts/lib/ts-transformer.d.ts.map +1 -0
- package/bundled/test-gen/prompts/lib/ts-transformer.js +92 -0
- package/bundled/test-gen/reporter/index.d.ts +33 -0
- package/bundled/test-gen/reporter/index.d.ts.map +1 -0
- package/bundled/test-gen/reporter/index.js +161 -0
- package/bundled/test-gen/session/index.d.ts +20 -0
- package/bundled/test-gen/session/index.d.ts.map +1 -0
- package/bundled/test-gen/session/index.js +105 -0
- package/bundled/test-gen/test-build/index.d.ts +10 -0
- package/bundled/test-gen/test-build/index.d.ts.map +1 -0
- package/bundled/test-gen/test-build/index.js +30 -0
- package/bundled/test-gen/types/index.d.ts +69 -0
- package/bundled/test-gen/types/index.d.ts.map +1 -0
- package/bundled/test-gen/types/index.js +2 -0
- package/bundled/test-gen/uploader/index.d.ts +26 -0
- package/bundled/test-gen/uploader/index.d.ts.map +1 -0
- package/bundled/test-gen/uploader/index.js +102 -0
- package/bundled/test-gen/utils/env.d.ts +2 -0
- package/bundled/test-gen/utils/env.d.ts.map +1 -0
- package/bundled/test-gen/utils/env.js +9 -0
- package/bundled/test-gen/utils/exec.d.ts +4 -0
- package/bundled/test-gen/utils/exec.d.ts.map +1 -0
- package/bundled/test-gen/utils/exec.js +45 -0
- package/bundled/test-gen/utils/file.d.ts +2 -0
- package/bundled/test-gen/utils/file.d.ts.map +1 -0
- package/bundled/test-gen/utils/file.js +25 -0
- package/bundled/test-gen/utils/html.d.ts +4 -0
- package/bundled/test-gen/utils/html.d.ts.map +1 -0
- package/bundled/test-gen/utils/html.js +46 -0
- package/bundled/test-gen/utils/index.d.ts +2 -0
- package/bundled/test-gen/utils/index.d.ts.map +1 -0
- package/bundled/test-gen/utils/index.js +5 -0
- package/bundled/test-gen/utils/pw-test.d.ts +3 -0
- package/bundled/test-gen/utils/pw-test.d.ts.map +1 -0
- package/bundled/test-gen/utils/pw-test.js +26 -0
- package/bundled/test-gen/utils/slug.d.ts +2 -0
- package/bundled/test-gen/utils/slug.d.ts.map +1 -0
- package/bundled/test-gen/utils/slug.js +18 -0
- package/bundled/test-gen/utils/string.d.ts +2 -0
- package/bundled/test-gen/utils/string.d.ts.map +1 -0
- package/bundled/test-gen/utils/string.js +9 -0
- package/dist/overlay-tests/click.spec.js +1 -1
- package/package.json +3 -3
- package/scripts/prepare-publish.js +42 -0
|
@@ -0,0 +1,30 @@
|
|
|
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.downloadBuild = void 0;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const logger_1 = require("../bin/logger");
|
|
9
|
+
const exec_1 = require("../utils/exec");
|
|
10
|
+
/**
|
|
11
|
+
* method to download the build from the URL provided in the build object
|
|
12
|
+
* this is only used in cases like chrome extension as of yet.
|
|
13
|
+
* @export
|
|
14
|
+
* @param {Build} build
|
|
15
|
+
* @return {*} {Promise<void>}
|
|
16
|
+
*/
|
|
17
|
+
async function downloadBuild(build) {
|
|
18
|
+
const logger = new logger_1.CustomLogger({ useReporter: false });
|
|
19
|
+
const packageJSONPath = "package.json";
|
|
20
|
+
const packageJsonStr = await fs_extra_1.default.readFile(packageJSONPath, "utf-8");
|
|
21
|
+
const packageJSONData = JSON.parse(packageJsonStr);
|
|
22
|
+
const buildDownloadScript = packageJSONData.scripts["download"];
|
|
23
|
+
if (buildDownloadScript && build?.url) {
|
|
24
|
+
logger.log(`Downloading build from ${build.url}`);
|
|
25
|
+
await (0, exec_1.cmd)(`npm run download ${build.url}`.split(" "), {
|
|
26
|
+
env: { ...Object(process.env) },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.downloadBuild = downloadBuild;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
+
import OpenAI from "openai";
|
|
3
|
+
import { TestGenPage } from "../page";
|
|
4
|
+
export type { TestGenPage };
|
|
5
|
+
export type PlaywrightActionGenerator<T extends BaseActionArgs = ActionArgs> = (page: TestGenPage, options: {
|
|
6
|
+
stateVariables: Record<string, any>;
|
|
7
|
+
setStateVariables: (stateVariables: Record<string, any>) => void;
|
|
8
|
+
}) => Action<T>;
|
|
9
|
+
export type ActionSchema = OpenAI.Chat.Completions.ChatCompletionTool;
|
|
10
|
+
export type Action<T extends BaseActionArgs = ActionArgs> = {
|
|
11
|
+
name: string;
|
|
12
|
+
schema: ActionSchema;
|
|
13
|
+
execute: (options: {
|
|
14
|
+
args: T;
|
|
15
|
+
trace?: TraceClient;
|
|
16
|
+
}) => Promise<{
|
|
17
|
+
locator: string;
|
|
18
|
+
testCaseLine?: string;
|
|
19
|
+
} | void>;
|
|
20
|
+
template: (args: T, options: {
|
|
21
|
+
locator: string;
|
|
22
|
+
testCaseLine?: string;
|
|
23
|
+
}) => {
|
|
24
|
+
code: string;
|
|
25
|
+
importPath?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type ScopeVars = Record<string, any>;
|
|
29
|
+
export type BaseActionArgs = {
|
|
30
|
+
reason: string;
|
|
31
|
+
elementAnnotation?: string;
|
|
32
|
+
};
|
|
33
|
+
export type ClickActionArgs = BaseActionArgs & {
|
|
34
|
+
xpath: string;
|
|
35
|
+
css_selector: string;
|
|
36
|
+
};
|
|
37
|
+
export type FillActionArgs = BaseActionArgs & {
|
|
38
|
+
text: string;
|
|
39
|
+
variable_name: string;
|
|
40
|
+
xpath: string;
|
|
41
|
+
css_selector: string;
|
|
42
|
+
};
|
|
43
|
+
export type GotoActionArgs = BaseActionArgs & {
|
|
44
|
+
url: string;
|
|
45
|
+
};
|
|
46
|
+
export type PressActionArgs = BaseActionArgs & {
|
|
47
|
+
key: string;
|
|
48
|
+
xpath: string;
|
|
49
|
+
css_selector: string;
|
|
50
|
+
};
|
|
51
|
+
export type AssertTextVisibilityActionArgs = BaseActionArgs & {
|
|
52
|
+
xpath: string;
|
|
53
|
+
css_selector: string;
|
|
54
|
+
};
|
|
55
|
+
export type TextContentActionArgs = BaseActionArgs & {
|
|
56
|
+
variable_name: string;
|
|
57
|
+
xpath: string;
|
|
58
|
+
css_selector: string;
|
|
59
|
+
};
|
|
60
|
+
export type HoverActionArgs = BaseActionArgs & {
|
|
61
|
+
xpath: string;
|
|
62
|
+
css_selector: string;
|
|
63
|
+
};
|
|
64
|
+
export type SkillActionArgs = BaseActionArgs & {
|
|
65
|
+
skill: string;
|
|
66
|
+
action: string;
|
|
67
|
+
};
|
|
68
|
+
export type ActionArgs = ClickActionArgs | FillActionArgs | GotoActionArgs | PressActionArgs | AssertTextVisibilityActionArgs | TextContentActionArgs | HoverActionArgs | SkillActionArgs;
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,cAAc,GAAG,UAAU,IAAI,CAC7E,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE;IACP,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,iBAAiB,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;CAClE,KACE,MAAM,CAAC,CAAC,CAAC,CAAC;AAEf,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC;AAEtE,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,cAAc,GAAG,UAAU,IAAI;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,CAAC,OAAO,EAAE;QACjB,IAAI,EAAE,CAAC,CAAC;QACR,KAAK,CAAC,EAAE,WAAW,CAAC;KACrB,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACjE,QAAQ,EAAE,CACR,IAAI,EAAE,CAAC,EACP,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,KAChD;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE5C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG;IAC5C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,cAAc,GAAG;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,cAAc,GAAG;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,eAAe,GACf,cAAc,GACd,cAAc,GACd,eAAe,GACf,8BAA8B,GAC9B,qBAAqB,GACrB,eAAe,GACf,eAAe,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"AAWA,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,CAgED;AAED,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,UAM1D;AAED,wBAAgB,2BAA2B,uBAQ1C"}
|
|
@@ -0,0 +1,102 @@
|
|
|
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.checkIfResultsUploadAllowed = exports.getUploadPathForRun = exports.uploadTestResultsUsingPrjRepo = exports.getRelativeUploadPath = exports.getFullUploadPath = exports.UPLOAD_DOMAIN = exports.UPLOAD_BUCKET = void 0;
|
|
7
|
+
const r2_uploader_1 = require("@empiricalrun/r2-uploader");
|
|
8
|
+
const reporter_1 = require("@empiricalrun/reporter");
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
// json summary of test results
|
|
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";
|
|
16
|
+
exports.UPLOAD_BUCKET = "test-report";
|
|
17
|
+
exports.UPLOAD_DOMAIN = "https://reports.empirical.run"; // domain based on bucket mentioned above
|
|
18
|
+
const uploadId = crypto.randomUUID();
|
|
19
|
+
function getFullUploadPath(repoDir, filePath, uploadDir) {
|
|
20
|
+
// remove the source dir from the file path - only keep the relative path
|
|
21
|
+
const relativeFilePath = getRelativeUploadPath(filePath, repoDir);
|
|
22
|
+
return `${exports.UPLOAD_DOMAIN}/${uploadDir}${relativeFilePath}`;
|
|
23
|
+
}
|
|
24
|
+
exports.getFullUploadPath = getFullUploadPath;
|
|
25
|
+
function getRelativeUploadPath(filePath, repoDir) {
|
|
26
|
+
return filePath.replace(path_1.default.join(repoDir, PLAYWRIGHT_REPORT_DATA), "");
|
|
27
|
+
}
|
|
28
|
+
exports.getRelativeUploadPath = getRelativeUploadPath;
|
|
29
|
+
/**
|
|
30
|
+
* Function to upload test results to R2 using the project repo name and test name.
|
|
31
|
+
* This function uploads both the JSON summary of test results and associated video files.
|
|
32
|
+
* @param {Object} params - The parameters for the function.
|
|
33
|
+
* @param {string} params.projectRepoName - Name of the project repository.
|
|
34
|
+
* @param {string} params.testName - Name of the testcase which called this test-gen.
|
|
35
|
+
* @returns {Promise<Object>} An object containing arrays of video URLs and the summary JSON URL.
|
|
36
|
+
* @returns {string[]} returns.videoUrls - URLs of the uploaded video files.
|
|
37
|
+
* @returns {string} returns.summaryUrl - URL of the uploaded summary JSON file.
|
|
38
|
+
*/
|
|
39
|
+
async function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, repoDir, }) {
|
|
40
|
+
const uploadDir = getUploadPathForRun(projectRepoName);
|
|
41
|
+
console.log("Current directory for assets upload", repoDir);
|
|
42
|
+
const files = await (0, r2_uploader_1.uploadDirectory)({
|
|
43
|
+
sourceDir: path_1.default.join(repoDir, PLAYWRIGHT_REPORT_DATA),
|
|
44
|
+
destinationDir: uploadDir,
|
|
45
|
+
uploadBucket: exports.UPLOAD_BUCKET,
|
|
46
|
+
});
|
|
47
|
+
// upload summary.json
|
|
48
|
+
await (0, r2_uploader_1.uploadDirectory)({
|
|
49
|
+
sourceDir: path_1.default.join(repoDir, "playwright-report"),
|
|
50
|
+
fileList: [path_1.default.join(repoDir, "playwright-report", "summary.json")],
|
|
51
|
+
destinationDir: uploadDir,
|
|
52
|
+
uploadBucket: exports.UPLOAD_BUCKET,
|
|
53
|
+
});
|
|
54
|
+
// fileNames are relative upload paths
|
|
55
|
+
const fileNames = Object.keys(files);
|
|
56
|
+
console.log("Uploaded files", fileNames.map((f) => getFullUploadPath(repoDir, f, uploadDir)));
|
|
57
|
+
const defaultLocation = path_1.default.join(repoDir, "playwright-report", "summary.json");
|
|
58
|
+
const results = (0, reporter_1.parseJsonReport)(defaultLocation);
|
|
59
|
+
const flatTestsList = (0, reporter_1.getFlattenedTestList)(results.suites);
|
|
60
|
+
const testAttachmentPaths = [];
|
|
61
|
+
for (const test of flatTestsList) {
|
|
62
|
+
if (test.title === testName) {
|
|
63
|
+
if (test.tests[0]) {
|
|
64
|
+
if (test.tests[0].results[0]) {
|
|
65
|
+
// results array is basically made by retries
|
|
66
|
+
for (const attachments of test.tests[0].results[0].attachments) {
|
|
67
|
+
if (attachments.path) {
|
|
68
|
+
testAttachmentPaths.push(getRelativeUploadPath(attachments.path, repoDir));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const videoFiles = fileNames.filter((fileName) => fileName.endsWith(".webm") && testAttachmentPaths.includes(fileName));
|
|
76
|
+
const traceFiles = fileNames.filter((fileName) => fileName.endsWith(".zip") && testAttachmentPaths.includes(fileName));
|
|
77
|
+
console.log("videoFiles", videoFiles);
|
|
78
|
+
console.log("traceFiles", traceFiles);
|
|
79
|
+
return {
|
|
80
|
+
videoUrls: videoFiles
|
|
81
|
+
.map((fileName) => getFullUploadPath(repoDir, fileName, uploadDir))
|
|
82
|
+
.filter((url) => !!url),
|
|
83
|
+
summaryUrl: `${exports.UPLOAD_DOMAIN}/${uploadDir}/summary.json`,
|
|
84
|
+
traceFiles: traceFiles
|
|
85
|
+
.map((fileName) => getFullUploadPath(repoDir, fileName, uploadDir))
|
|
86
|
+
.filter((url) => !!url),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
exports.uploadTestResultsUsingPrjRepo = uploadTestResultsUsingPrjRepo;
|
|
90
|
+
function getUploadPathForRun(projectRepoName) {
|
|
91
|
+
const uploadDir = `test-generation/${projectRepoName.replace("-tests", "")}/${uploadId}`;
|
|
92
|
+
return uploadDir;
|
|
93
|
+
}
|
|
94
|
+
exports.getUploadPathForRun = getUploadPathForRun;
|
|
95
|
+
function checkIfResultsUploadAllowed() {
|
|
96
|
+
// TODO: check for valid R2 credentials
|
|
97
|
+
// check for project repo name, and r2 creds
|
|
98
|
+
return (process.env.R2_ACCOUNT_ID &&
|
|
99
|
+
process.env.R2_ACCESS_KEY_ID &&
|
|
100
|
+
process.env.R2_SECRET_ACCESS_KEY);
|
|
101
|
+
}
|
|
102
|
+
exports.checkIfResultsUploadAllowed = checkIfResultsUploadAllowed;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,YAM/B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isRunningOnCloud = void 0;
|
|
4
|
+
function isRunningOnCloud() {
|
|
5
|
+
return (process.env.CI === "true" ||
|
|
6
|
+
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
7
|
+
!!process.env.RUNNING_BROWSER_TESTS_FOR_TEST_GEN);
|
|
8
|
+
}
|
|
9
|
+
exports.isRunningOnCloud = isRunningOnCloud;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAGA,wBAAsB,GAAG,CACvB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACxC,OAAO,CAAC,MAAM,CAAC,CAuCjB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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.cmd = void 0;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const process_1 = __importDefault(require("process"));
|
|
9
|
+
async function cmd(command, options) {
|
|
10
|
+
let errorLogs = [];
|
|
11
|
+
return new Promise((resolveFunc, rejectFunc) => {
|
|
12
|
+
if (!command[0]) {
|
|
13
|
+
rejectFunc(new Error("Command cannot be empty"));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
let p = (0, child_process_1.spawn)(command[0], command.slice(1), {
|
|
17
|
+
env: { ...process_1.default.env, ...options.env },
|
|
18
|
+
});
|
|
19
|
+
p.stdout.on("data", (x) => {
|
|
20
|
+
const log = x.toString();
|
|
21
|
+
if (log.includes("Error")) {
|
|
22
|
+
errorLogs.push(log);
|
|
23
|
+
}
|
|
24
|
+
process_1.default.stdout.write(log);
|
|
25
|
+
});
|
|
26
|
+
p.stderr.on("data", (x) => {
|
|
27
|
+
const log = x.toString();
|
|
28
|
+
process_1.default.stderr.write(log);
|
|
29
|
+
errorLogs.push(log);
|
|
30
|
+
});
|
|
31
|
+
p.on("error", async (err) => {
|
|
32
|
+
rejectFunc(err);
|
|
33
|
+
});
|
|
34
|
+
p.on("exit", async (code) => {
|
|
35
|
+
if (code !== 0) {
|
|
36
|
+
const errorMessage = errorLogs.slice(-3).join("\n");
|
|
37
|
+
rejectFunc(new Error(errorMessage));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
resolveFunc(code ?? 1);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.cmd = cmd;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAGA,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,SAAS,CAgBpB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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.findFileRecursively = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function findFileRecursively(directory, fileName) {
|
|
10
|
+
const files = fs_1.default.readdirSync(directory);
|
|
11
|
+
for (const file of files) {
|
|
12
|
+
const fullPath = path_1.default.join(directory, file);
|
|
13
|
+
const stat = fs_1.default.statSync(fullPath);
|
|
14
|
+
if (stat.isDirectory()) {
|
|
15
|
+
const result = findFileRecursively(fullPath, fileName);
|
|
16
|
+
if (result) {
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else if (file === fileName) {
|
|
21
|
+
return fullPath;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.findFileRecursively = findFileRecursively;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/utils/html.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,QAClB,MAAM,YACF;IACP,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B,WAsCF,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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.sanitizeHtml = void 0;
|
|
7
|
+
const sanitize_html_1 = __importDefault(require("sanitize-html"));
|
|
8
|
+
const sanitizeHtml = (str, options = {}) => {
|
|
9
|
+
let sanitizedStr = (0, sanitize_html_1.default)(str, {
|
|
10
|
+
allowedTags: sanitize_html_1.default.defaults.allowedTags.concat([
|
|
11
|
+
"button",
|
|
12
|
+
"div",
|
|
13
|
+
"form",
|
|
14
|
+
"h1",
|
|
15
|
+
"h2",
|
|
16
|
+
"h3",
|
|
17
|
+
"img",
|
|
18
|
+
"input",
|
|
19
|
+
"label",
|
|
20
|
+
"select",
|
|
21
|
+
"textarea",
|
|
22
|
+
]),
|
|
23
|
+
allowedAttributes: {
|
|
24
|
+
"*": [
|
|
25
|
+
"alt",
|
|
26
|
+
"aria-*",
|
|
27
|
+
"class",
|
|
28
|
+
"disabled",
|
|
29
|
+
"for",
|
|
30
|
+
"id",
|
|
31
|
+
"href",
|
|
32
|
+
"placeholder",
|
|
33
|
+
"role",
|
|
34
|
+
"selected",
|
|
35
|
+
"src",
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
if (options.disallowedStrings) {
|
|
40
|
+
options.disallowedStrings.forEach((s) => {
|
|
41
|
+
sanitizedStr = sanitizedStr.replaceAll(s, "");
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return sanitizedStr;
|
|
45
|
+
};
|
|
46
|
+
exports.sanitizeHtml = sanitizeHtml;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTypescriptTestBlock = void 0;
|
|
4
|
+
var web_1 = require("../bin/utils/platform/web");
|
|
5
|
+
Object.defineProperty(exports, "getTypescriptTestBlock", { enumerable: true, get: function () { return web_1.getTypescriptTestBlock; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pw-test.d.ts","sourceRoot":"","sources":["../../src/utils/pw-test.ts"],"names":[],"mappings":"AAEA,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,GAAG,CAAC,CAKd;AAED,wBAAsB,QAAQ,kBAS7B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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.skipTest = exports.getTestFixtureModuleFromRepo = void 0;
|
|
7
|
+
const api_1 = __importDefault(require("tsx/cjs/api"));
|
|
8
|
+
async function getTestFixtureModuleFromRepo(repoDir) {
|
|
9
|
+
const [lastDir] = repoDir.split("/").reverse();
|
|
10
|
+
const dir = `${repoDir}/${lastDir}`;
|
|
11
|
+
const { test } = await api_1.default.require(`./tests/fixtures.ts`, dir);
|
|
12
|
+
return test;
|
|
13
|
+
}
|
|
14
|
+
exports.getTestFixtureModuleFromRepo = getTestFixtureModuleFromRepo;
|
|
15
|
+
async function skipTest() {
|
|
16
|
+
let test;
|
|
17
|
+
let repoDir = process.cwd();
|
|
18
|
+
try {
|
|
19
|
+
test = await getTestFixtureModuleFromRepo(repoDir);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.error("Error while importing fixture module to extract test:", e);
|
|
23
|
+
}
|
|
24
|
+
test.skip();
|
|
25
|
+
}
|
|
26
|
+
exports.skipTest = skipTest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slug.d.ts","sourceRoot":"","sources":["../../src/utils/slug.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,uBAAuB,SAAgB,MAAM,oBAOzD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asyncGenerateRandomSlug = void 0;
|
|
4
|
+
// @ts-expect-error
|
|
5
|
+
let customAlphabet;
|
|
6
|
+
const loadNanoid = async () => {
|
|
7
|
+
const { customAlphabet: importedCustomAlphabet } = await import("nanoid");
|
|
8
|
+
customAlphabet = importedCustomAlphabet;
|
|
9
|
+
};
|
|
10
|
+
const asyncGenerateRandomSlug = async (size) => {
|
|
11
|
+
if (!customAlphabet) {
|
|
12
|
+
await loadNanoid();
|
|
13
|
+
}
|
|
14
|
+
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
15
|
+
const nanoid = customAlphabet(chars, size);
|
|
16
|
+
return nanoid();
|
|
17
|
+
};
|
|
18
|
+
exports.asyncGenerateRandomSlug = asyncGenerateRandomSlug;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,UAInD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertTextToJsComments = void 0;
|
|
4
|
+
function convertTextToJsComments(text) {
|
|
5
|
+
const lines = text.split("\n");
|
|
6
|
+
const commentedLines = lines.map((line) => `// ${line}`);
|
|
7
|
+
return commentedLines.join("\n");
|
|
8
|
+
}
|
|
9
|
+
exports.convertTextToJsComments = convertTextToJsComments;
|
|
@@ -40,7 +40,7 @@ fixtures_1.test.beforeEach(async ({ page }) => {
|
|
|
40
40
|
await (0, fixtures_1.expect)(page.getByText("This is a toast message")).not.toBeVisible();
|
|
41
41
|
await (0, fixtures_1.expect)(page.getByRole("button", { name: "Close" })).toBeVisible();
|
|
42
42
|
});
|
|
43
|
-
(0, fixtures_1.test)("should
|
|
43
|
+
(0, fixtures_1.test)("should fallback when the overlay cannot be dismissed", async ({ page, server, }) => {
|
|
44
44
|
await page.goto(`${server.baseURL}/no-overlay.html`);
|
|
45
45
|
let error;
|
|
46
46
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/playwright-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/code-frame": "^7.24.7",
|
|
37
|
+
"@empiricalrun/test-gen": "file:./bundled/test-gen",
|
|
37
38
|
"async-retry": "^1.3.3",
|
|
38
39
|
"console-log-level": "^1.4.1",
|
|
39
40
|
"mailosaur": "^8.6.1",
|
|
@@ -43,8 +44,7 @@
|
|
|
43
44
|
"puppeteer-extra-plugin-recaptcha": "^3.6.8",
|
|
44
45
|
"rimraf": "^6.0.1",
|
|
45
46
|
"@empiricalrun/llm": "^0.9.35",
|
|
46
|
-
"@empiricalrun/r2-uploader": "^0.3.8"
|
|
47
|
-
"@empiricalrun/test-gen": "^0.46.9"
|
|
47
|
+
"@empiricalrun/r2-uploader": "^0.3.8"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"dev": "tsc --build --watch",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This script prepares the package for publishing by:
|
|
5
|
+
* 1. Creating a temporary copy of the workspace packages we want to bundle
|
|
6
|
+
* 2. Modifying the package.json to use the local files instead of workspace references
|
|
7
|
+
* 3. The publish process will then automatically include these files
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const { execSync } = require('child_process');
|
|
13
|
+
|
|
14
|
+
// Paths
|
|
15
|
+
const ROOT_DIR = path.resolve(__dirname, '../../..');
|
|
16
|
+
const PLAYWRIGHT_UTILS_DIR = path.resolve(__dirname, '..');
|
|
17
|
+
const TEST_GEN_DIR = path.resolve(ROOT_DIR, 'packages/test-gen');
|
|
18
|
+
const BUNDLED_DIR = path.resolve(PLAYWRIGHT_UTILS_DIR, 'bundled');
|
|
19
|
+
|
|
20
|
+
// Create bundled directory if it doesn't exist
|
|
21
|
+
if (!fs.existsSync(BUNDLED_DIR)) {
|
|
22
|
+
fs.mkdirSync(BUNDLED_DIR);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Copy test-gen to bundled directory
|
|
26
|
+
const TEST_GEN_BUNDLED_DIR = path.resolve(BUNDLED_DIR, 'test-gen');
|
|
27
|
+
console.log('Copying test-gen to bundled directory...');
|
|
28
|
+
execSync(`rm -rf ${TEST_GEN_BUNDLED_DIR}`);
|
|
29
|
+
execSync(`cp -r ${TEST_GEN_DIR}/dist ${TEST_GEN_BUNDLED_DIR}`);
|
|
30
|
+
execSync(`cp ${TEST_GEN_DIR}/package.json ${TEST_GEN_BUNDLED_DIR}/package.json`);
|
|
31
|
+
|
|
32
|
+
// Read and modify playwright-utils package.json
|
|
33
|
+
const packageJsonPath = path.resolve(PLAYWRIGHT_UTILS_DIR, 'package.json');
|
|
34
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
35
|
+
|
|
36
|
+
// Update the dependency to use the bundled version
|
|
37
|
+
packageJson.dependencies['@empiricalrun/test-gen'] = 'file:./bundled/test-gen';
|
|
38
|
+
|
|
39
|
+
// Write the modified package.json
|
|
40
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
41
|
+
|
|
42
|
+
console.log('Package prepared for publishing with bundled dependencies');
|