@checksum-ai/runtime 1.0.3 → 1.0.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/LICENSE CHANGED
@@ -0,0 +1 @@
1
+ Checksum license
@@ -0,0 +1 @@
1
+ Checksum readme
@@ -0,0 +1,56 @@
1
+ import { RunMode, getChecksumConfig } from "@checksum-ai/runtime";
2
+
3
+ export default getChecksumConfig({
4
+ /**
5
+ * Checksum runtime running mode -
6
+ * normal - tests run normally
7
+ * heal - checksum will attempt to heal tests that failed using fallback
8
+ * refactor - checksum will attempt to refactor and improve your tests
9
+ */
10
+ runMode: RunMode.Normal,
11
+
12
+ /**
13
+ * Insert here your Checksum API key
14
+ */
15
+ apiKey: "<API key>",
16
+
17
+ /**
18
+ * This is the base URL of the tested app
19
+ */
20
+ baseURL: "<base URL>",
21
+
22
+ /**
23
+ * Insert the account's username that will be used
24
+ * to login into your testing environment
25
+ */
26
+ username: "<username>",
27
+
28
+ /**
29
+ * Insert the account's password that will be used
30
+ * to login into your testing environment
31
+ */
32
+ password: "<password>",
33
+
34
+ options: {
35
+ /**
36
+ * Whether to fallback to ESRA if the action selector is not found
37
+ */
38
+ actionsESRAfallback: true,
39
+
40
+ /**
41
+ * Whether to use LLM fallback if action selector is not found
42
+ */
43
+ actionsLLMFallback: true,
44
+
45
+ /**
46
+ * Whether to use mock API data when running your tests
47
+ */
48
+ useMockData: false,
49
+
50
+ /**
51
+ * Print runtime logs.
52
+ * Use for debug only
53
+ */
54
+ printLogs: false,
55
+ },
56
+ });
@@ -0,0 +1,19 @@
1
+ import { ChecksumConfig, IChecksumPage } from "@checksum-ai/runtime";
2
+
3
+ /**
4
+ * Login method
5
+ */
6
+ export default async function login(
7
+ page: IChecksumPage,
8
+ config: ChecksumConfig
9
+ ) {
10
+ /**
11
+ * Update this function to login to your application
12
+ * i.e.:
13
+ * await page.goto('/login');
14
+ * await page.getByPlaceholder("Email...").fill(config.username);
15
+ * await page.getByPlaceholder("Password...").fill(config.password);
16
+ * await page.getByText("Continue").click();
17
+ * await page.waitForURL("/main");
18
+ */
19
+ }
@@ -0,0 +1,32 @@
1
+ import { defineConfig, devices } from "@playwright/test";
2
+
3
+ export default defineConfig({
4
+ timeout: 120000,
5
+ testMatch: [/.*.[.]checksum.spec.ts/],
6
+ testDir: ".",
7
+ /* disable parallel test runs */
8
+ workers: 1,
9
+ /* Run tests in files in parallel */
10
+ fullyParallel: false,
11
+ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
12
+ reporter: "html",
13
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
14
+ use: {
15
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
16
+ trace: "on",
17
+ video: "on",
18
+ },
19
+
20
+ /* Configure projects for major browsers */
21
+ projects: [
22
+ {
23
+ name: "chromium",
24
+ use: { ...devices["Desktop Chrome"] },
25
+ },
26
+ {
27
+ name: "checksumpage",
28
+ use: { ...devices["Desktop Chrome"] },
29
+ testDir: "./src/lib/runtime",
30
+ },
31
+ ],
32
+ });
package/cli.js CHANGED
@@ -1,3 +1,16 @@
1
- export function init() {
2
- console.log("cli init");
3
- }
1
+ var g=Object.create;var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var k=(c,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of f(e))!d.call(c,o)&&o!==t&&l(c,o,{get:()=>e[o],enumerable:!(s=m(e,o))||s.enumerable});return c};var C=(c,e,t)=>(t=c!=null?g(p(c)):{},k(e||!c||!c.__esModule?l(t,"default",{value:c,enumerable:!0}):t,c));var i=require("fs"),r=C(require("child_process")),n=require("path"),y="checksum",u=class{constructor(){this.checksumConfig=void 0}async execute(){var e;switch(process.argv[2]){case"install":this.install();break;case"run":if(((e=process.argv)==null?void 0:e[3])==="--help"){await this.printHelp("run");break}await this.run(process.argv.slice(3));break;default:await this.printHelp()}process.exit(0)}async execCmd(e){let t=await r.spawn(e,{shell:!0,stdio:"inherit"});return new Promise((o,a)=>{t.on("exit",h=>{h===0?o(!0):a(new Error(`Checsum failed execution with code: ${h} for command: "${e}`))})})}async getCmdOutput(e){return new Promise(function(t,s){r.exec(e,(o,a,h)=>{if(o){s(`Error executing command: ${o.message}`);return}t(a)})})}async printHelp(e){switch(e){default:console.log(`
2
+ Checksum CLI
3
+ Usage: checksum [command] [options]
4
+
5
+ Commands:
6
+ install installs checksum files and folders
7
+ run runs checksum tests
8
+ help prints this help message
9
+ `);break;case"run":try{let t="npx playwright test --help",s=(await this.getCmdOutput(t)).replace(/npx playwright test/g,"yarn checksum run").split(`
10
+ `);s.splice(5,0," --checksum-config=<config> Checksum configuration in JSON format").join(`
11
+ `),console.log(s.join(`
12
+ `))}catch(t){console.log("Error",t.message)}break}}async run(e){e=this.getChecksumConfig(e);let t=`npx playwright test --config ${(0,n.join)(this.getRootDirPath(),"playwright.config.ts")} ${e.join(" ")}`;try{this.buildVolatileConfig(),await this.execCmd(t)}catch(s){console.log("Error",s.message)}finally{this.cleanup()}}buildVolatileConfig(){if(!this.checksumConfig)return;let e=this.getVolatileConfigPath(),t=`
13
+ import { RunMode, getChecksumConfig } from "@checksum-ai/runtime";
14
+
15
+ export default getChecksumConfig(${JSON.stringify(this.checksumConfig,null,2)});
16
+ `;(0,i.writeFileSync)(e,t)}cleanup(){let e=this.getVolatileConfigPath();(0,i.existsSync)(e)&&(0,i.rmSync)(e)}getVolatileConfigPath(){return(0,n.join)(this.getRootDirPath(),"checksum.config.tmp.ts")}getChecksumConfig(e){for(let t of e)if(t.startsWith("--checksum-config"))try{return this.checksumConfig=JSON.parse(t.split("=")[1]),e.filter(s=>s!==t)}catch(s){console.log("Error parsing checksum config",s.message),this.checksumConfig=void 0}return e}install(){console.log("Creating Checksum directory and necessary files to run your tests");let e=this.getRootDirPath();if((0,i.existsSync)(this.getRootDirPath())||(0,i.mkdirSync)(e),!(0,i.existsSync)(this.getChecksumRootOrigin()))throw new Error("Could not find checksum root directory, please install @checksum-ai/runtime package");["checksum.config.ts","playwright.config.ts","login.ts","README.md"].forEach(t=>{(0,i.copyFileSync)((0,n.join)(this.getChecksumRootOrigin(),t),(0,n.join)(e,t))}),(0,i.mkdirSync)((0,n.join)(e,"tests"),{recursive:!0}),["esra","har","trace","log"].forEach(t=>{(0,i.mkdirSync)((0,n.join)(e,"test-data",t),{recursive:!0})})}getRootDirPath(){return(0,n.join)(process.cwd(),y)}getChecksumRootOrigin(){return(0,n.join)(process.cwd(),"node_modules","@checksum-ai","runtime","checksum-root")}};(async()=>await new u().execute())();