pw-automation-framework 2.0.1
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/README.md +93 -0
- package/bin/lexxit-automation-framework.js +427 -0
- package/dist/app.d.ts +2 -0
- package/dist/app.js +26 -0
- package/dist/app.js.map +1 -0
- package/dist/controllers/controller.d.ts +57 -0
- package/dist/controllers/controller.js +263 -0
- package/dist/controllers/controller.js.map +1 -0
- package/dist/core/BrowserManager.d.ts +46 -0
- package/dist/core/BrowserManager.js +377 -0
- package/dist/core/BrowserManager.js.map +1 -0
- package/dist/core/PlaywrightEngine.d.ts +16 -0
- package/dist/core/PlaywrightEngine.js +246 -0
- package/dist/core/PlaywrightEngine.js.map +1 -0
- package/dist/core/ScreenshotManager.d.ts +10 -0
- package/dist/core/ScreenshotManager.js +28 -0
- package/dist/core/ScreenshotManager.js.map +1 -0
- package/dist/core/TestData.d.ts +12 -0
- package/dist/core/TestData.js +29 -0
- package/dist/core/TestData.js.map +1 -0
- package/dist/core/TestExecutor.d.ts +16 -0
- package/dist/core/TestExecutor.js +355 -0
- package/dist/core/TestExecutor.js.map +1 -0
- package/dist/core/handlers/AllHandlers.d.ts +116 -0
- package/dist/core/handlers/AllHandlers.js +648 -0
- package/dist/core/handlers/AllHandlers.js.map +1 -0
- package/dist/core/handlers/BaseHandler.d.ts +16 -0
- package/dist/core/handlers/BaseHandler.js +27 -0
- package/dist/core/handlers/BaseHandler.js.map +1 -0
- package/dist/core/handlers/ClickHandler.d.ts +34 -0
- package/dist/core/handlers/ClickHandler.js +359 -0
- package/dist/core/handlers/ClickHandler.js.map +1 -0
- package/dist/core/handlers/CustomCodeHandler.d.ts +35 -0
- package/dist/core/handlers/CustomCodeHandler.js +102 -0
- package/dist/core/handlers/CustomCodeHandler.js.map +1 -0
- package/dist/core/handlers/DropdownHandler.d.ts +43 -0
- package/dist/core/handlers/DropdownHandler.js +304 -0
- package/dist/core/handlers/DropdownHandler.js.map +1 -0
- package/dist/core/handlers/InputHandler.d.ts +24 -0
- package/dist/core/handlers/InputHandler.js +197 -0
- package/dist/core/handlers/InputHandler.js.map +1 -0
- package/dist/core/registry/ActionRegistry.d.ts +8 -0
- package/dist/core/registry/ActionRegistry.js +35 -0
- package/dist/core/registry/ActionRegistry.js.map +1 -0
- package/dist/installer/frameworkLauncher.d.ts +31 -0
- package/dist/installer/frameworkLauncher.js +198 -0
- package/dist/installer/frameworkLauncher.js.map +1 -0
- package/dist/queue/ExecutionQueue.d.ts +52 -0
- package/dist/queue/ExecutionQueue.js +175 -0
- package/dist/queue/ExecutionQueue.js.map +1 -0
- package/dist/routes/api.routes.d.ts +2 -0
- package/dist/routes/api.routes.js +16 -0
- package/dist/routes/api.routes.js.map +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +30 -0
- package/dist/server.js.map +1 -0
- package/dist/types/types.d.ts +135 -0
- package/dist/types/types.js +4 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/elementHighlight.d.ts +35 -0
- package/dist/utils/elementHighlight.js +136 -0
- package/dist/utils/elementHighlight.js.map +1 -0
- package/dist/utils/locatorHelper.d.ts +7 -0
- package/dist/utils/locatorHelper.js +53 -0
- package/dist/utils/locatorHelper.js.map +1 -0
- package/dist/utils/logger.d.ts +12 -0
- package/dist/utils/logger.js +35 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/response.d.ts +4 -0
- package/dist/utils/response.js +25 -0
- package/dist/utils/response.js.map +1 -0
- package/dist/utils/responseFormatter.d.ts +78 -0
- package/dist/utils/responseFormatter.js +123 -0
- package/dist/utils/responseFormatter.js.map +1 -0
- package/dist/utils/sseManager.d.ts +32 -0
- package/dist/utils/sseManager.js +122 -0
- package/dist/utils/sseManager.js.map +1 -0
- package/lexxit-automation-framework-2.0.0.tgz +0 -0
- package/npmignore +5 -0
- package/package.json +36 -0
- package/scripts/postinstall.js +52 -0
- package/src/app.ts +27 -0
- package/src/controllers/controller.ts +282 -0
- package/src/core/BrowserManager.ts +398 -0
- package/src/core/PlaywrightEngine.ts +371 -0
- package/src/core/ScreenshotManager.ts +25 -0
- package/src/core/TestData.ts +25 -0
- package/src/core/TestExecutor.ts +436 -0
- package/src/core/handlers/AllHandlers.ts +626 -0
- package/src/core/handlers/BaseHandler.ts +41 -0
- package/src/core/handlers/ClickHandler.ts +482 -0
- package/src/core/handlers/CustomCodeHandler.ts +123 -0
- package/src/core/handlers/DropdownHandler.ts +438 -0
- package/src/core/handlers/InputHandler.ts +192 -0
- package/src/core/registry/ActionRegistry.ts +31 -0
- package/src/installer/frameworkLauncher.ts +242 -0
- package/src/installer/install.sh +107 -0
- package/src/public/dashboard.html +540 -0
- package/src/public/queue-monitor.html +190 -0
- package/src/queue/ExecutionQueue.ts +200 -0
- package/src/routes/api.routes.ts +16 -0
- package/src/server.ts +29 -0
- package/src/types/types.ts +169 -0
- package/src/utils/elementHighlight.ts +174 -0
- package/src/utils/locatorHelper.ts +49 -0
- package/src/utils/logger.ts +40 -0
- package/src/utils/response.ts +27 -0
- package/src/utils/responseFormatter.ts +167 -0
- package/src/utils/sseManager.ts +127 -0
- package/tsconfig.json +18 -0
- package/videos/fb1b94b6-6639-4c9a-82bb-63572606f403/page@5bd5c6c8b62baa700e9810cdd64f5c49.webm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Playwright_V1_framework
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
* [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
|
|
14
|
+
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin https://gitlab.letitbexai.com/lexxit/playwright_v1_framework.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
* [Set up project integrations](https://gitlab.letitbexai.com/lexxit/playwright_v1_framework/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
|
|
30
|
+
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
|
|
31
|
+
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
|
|
32
|
+
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
|
|
33
|
+
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
|
|
40
|
+
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
|
|
41
|
+
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
|
|
42
|
+
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
|
|
43
|
+
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
|
|
53
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
|
+
|
|
55
|
+
## Name
|
|
56
|
+
Choose a self-explaining name for your project.
|
|
57
|
+
|
|
58
|
+
## Description
|
|
59
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
|
+
|
|
61
|
+
## Badges
|
|
62
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
|
+
|
|
64
|
+
## Visuals
|
|
65
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
|
+
|
|
73
|
+
## Support
|
|
74
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
|
+
|
|
76
|
+
## Roadmap
|
|
77
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
+
|
|
82
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
|
+
|
|
84
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
|
+
|
|
86
|
+
## Authors and acknowledgment
|
|
87
|
+
Show your appreciation to those who have contributed to the project.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
For open source projects, say how it is licensed.
|
|
91
|
+
|
|
92
|
+
## Project status
|
|
93
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const { execSync, spawn } = require('child_process');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const os = require('os');
|
|
9
|
+
const http = require('http');
|
|
10
|
+
|
|
11
|
+
const args = process.argv.slice(2);
|
|
12
|
+
const command = args[0];
|
|
13
|
+
|
|
14
|
+
const COLORS = {
|
|
15
|
+
reset: '\x1b[0m',
|
|
16
|
+
green: '\x1b[32m',
|
|
17
|
+
yellow: '\x1b[33m',
|
|
18
|
+
red: '\x1b[31m',
|
|
19
|
+
cyan: '\x1b[36m',
|
|
20
|
+
bold: '\x1b[1m',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function info(msg) { console.log(`${COLORS.cyan}[lexxit]${COLORS.reset} ${msg}`); }
|
|
24
|
+
function success(msg) { console.log(`${COLORS.green}✔${COLORS.reset} ${msg}`); }
|
|
25
|
+
function warn(msg) { console.log(`${COLORS.yellow}⚠${COLORS.reset} ${msg}`); }
|
|
26
|
+
function error(msg) { console.log(`${COLORS.red}✖${COLORS.reset} ${msg}`); }
|
|
27
|
+
|
|
28
|
+
// ── Package root = one level up from /bin ──────────────────────────────────
|
|
29
|
+
const PKG_ROOT = path.join(__dirname, '..');
|
|
30
|
+
const DIST_SERVER = path.join(PKG_ROOT, 'dist', 'server.js');
|
|
31
|
+
const PID_FILE = path.join(os.tmpdir(), 'lexxit-automation-framework.pid');
|
|
32
|
+
const PORT = 3000;
|
|
33
|
+
|
|
34
|
+
// ── Command router ─────────────────────────────────────────────────────────
|
|
35
|
+
if (command === 'start') {
|
|
36
|
+
startFramework();
|
|
37
|
+
} else if (command === 'stop') {
|
|
38
|
+
stopFramework();
|
|
39
|
+
} else if (command === 'status') {
|
|
40
|
+
checkStatus();
|
|
41
|
+
} else {
|
|
42
|
+
printHelp();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function printHelp() {
|
|
46
|
+
console.log(`
|
|
47
|
+
${COLORS.bold}lexxit-automation-framework${COLORS.reset}
|
|
48
|
+
|
|
49
|
+
Usage:
|
|
50
|
+
lexxit-automation-framework start Start the local agent on port ${PORT}
|
|
51
|
+
lexxit-automation-framework stop Stop the running agent
|
|
52
|
+
lexxit-automation-framework status Check if agent is running
|
|
53
|
+
`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ── START ───────────────────────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
function startFramework() {
|
|
59
|
+
info('Starting lexxit-automation-framework...');
|
|
60
|
+
|
|
61
|
+
// 1. Check if already running
|
|
62
|
+
pingHealth((isRunning) => {
|
|
63
|
+
if (isRunning) {
|
|
64
|
+
success(`Framework already running on http://localhost:${PORT}`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 2. Ensure dist/server.js exists
|
|
69
|
+
if (!fs.existsSync(DIST_SERVER)) {
|
|
70
|
+
info('dist/server.js not found — building project first...');
|
|
71
|
+
try {
|
|
72
|
+
execSync('npm run build', {
|
|
73
|
+
cwd: PKG_ROOT,
|
|
74
|
+
stdio: 'inherit',
|
|
75
|
+
});
|
|
76
|
+
success('Build complete.');
|
|
77
|
+
} catch (e) {
|
|
78
|
+
error('Build failed. Please run "npm run build" manually inside the framework folder.');
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!fs.existsSync(DIST_SERVER)) {
|
|
84
|
+
error(`Still cannot find: ${DIST_SERVER}`);
|
|
85
|
+
error('Please run "npm run build" inside your lexxit-automation-framework folder.');
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 3. Launch server
|
|
90
|
+
info(`Launching server: ${DIST_SERVER}`);
|
|
91
|
+
|
|
92
|
+
const isWindows = os.platform() === 'win32';
|
|
93
|
+
|
|
94
|
+
// On Windows we use a slightly different spawn approach
|
|
95
|
+
const child = isWindows
|
|
96
|
+
? spawn(process.execPath, [DIST_SERVER], {
|
|
97
|
+
detached: true,
|
|
98
|
+
stdio: 'ignore',
|
|
99
|
+
cwd: PKG_ROOT,
|
|
100
|
+
env: { ...process.env, PORT: String(PORT) },
|
|
101
|
+
windowsHide: true,
|
|
102
|
+
})
|
|
103
|
+
: spawn(process.execPath, [DIST_SERVER], {
|
|
104
|
+
detached: true,
|
|
105
|
+
stdio: 'ignore',
|
|
106
|
+
cwd: PKG_ROOT,
|
|
107
|
+
env: { ...process.env, PORT: String(PORT) },
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
child.unref();
|
|
111
|
+
|
|
112
|
+
// Save PID for stop command
|
|
113
|
+
try {
|
|
114
|
+
fs.writeFileSync(PID_FILE, String(child.pid));
|
|
115
|
+
info(`PID ${child.pid} saved to ${PID_FILE}`);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
warn('Could not save PID file.');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 4. Wait up to 30 seconds for server to be ready
|
|
121
|
+
info(`Waiting for framework on http://localhost:${PORT}/api/health ...`);
|
|
122
|
+
waitForHealth(30, 1000, () => {
|
|
123
|
+
success(`lexxit-automation-framework is running on http://localhost:${PORT}`);
|
|
124
|
+
success('You can now use the web app to run tests.');
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ── STOP ────────────────────────────────────────────────────────────────────
|
|
130
|
+
|
|
131
|
+
function stopFramework() {
|
|
132
|
+
if (!fs.existsSync(PID_FILE)) {
|
|
133
|
+
warn('No PID file found — framework may not be running.');
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const pid = parseInt(fs.readFileSync(PID_FILE, 'utf8').trim(), 10);
|
|
138
|
+
|
|
139
|
+
if (isNaN(pid)) {
|
|
140
|
+
warn('Invalid PID file. Deleting it.');
|
|
141
|
+
fs.unlinkSync(PID_FILE);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
process.kill(pid, 'SIGTERM');
|
|
147
|
+
fs.unlinkSync(PID_FILE);
|
|
148
|
+
success(`Framework stopped (PID: ${pid})`);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
// Process may have already exited
|
|
151
|
+
warn(`Could not kill PID ${pid} — it may have already stopped.`);
|
|
152
|
+
if (fs.existsSync(PID_FILE)) fs.unlinkSync(PID_FILE);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ── STATUS ──────────────────────────────────────────────────────────────────
|
|
157
|
+
|
|
158
|
+
function checkStatus() {
|
|
159
|
+
info('Checking framework status...');
|
|
160
|
+
pingHealth((isRunning) => {
|
|
161
|
+
if (isRunning) {
|
|
162
|
+
success(`Framework is RUNNING on http://localhost:${PORT}`);
|
|
163
|
+
} else {
|
|
164
|
+
warn('Framework is NOT running.');
|
|
165
|
+
info('Start it with: lexxit-automation-framework start');
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// ── HELPERS ─────────────────────────────────────────────────────────────────
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Single health ping — calls callback(true/false)
|
|
174
|
+
*/
|
|
175
|
+
function pingHealth(callback) {
|
|
176
|
+
const req = http.get(
|
|
177
|
+
`http://localhost:${PORT}/api/health`,
|
|
178
|
+
{ timeout: 1500 },
|
|
179
|
+
(res) => {
|
|
180
|
+
callback(res.statusCode === 200);
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
req.on('error', () => callback(false));
|
|
184
|
+
req.on('timeout', () => {
|
|
185
|
+
req.destroy();
|
|
186
|
+
callback(false);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Retries health check every `intervalMs` up to `maxRetries` times.
|
|
192
|
+
* Calls onSuccess() when server responds, exits process on timeout.
|
|
193
|
+
*/
|
|
194
|
+
function waitForHealth(maxRetries, intervalMs, onSuccess) {
|
|
195
|
+
let attempts = 0;
|
|
196
|
+
|
|
197
|
+
const interval = setInterval(() => {
|
|
198
|
+
attempts++;
|
|
199
|
+
process.stdout.write(`\r${COLORS.cyan}[lexxit]${COLORS.reset} Attempt ${attempts}/${maxRetries}...`);
|
|
200
|
+
|
|
201
|
+
pingHealth((isRunning) => {
|
|
202
|
+
if (isRunning) {
|
|
203
|
+
clearInterval(interval);
|
|
204
|
+
process.stdout.write('\n');
|
|
205
|
+
onSuccess();
|
|
206
|
+
} else if (attempts >= maxRetries) {
|
|
207
|
+
clearInterval(interval);
|
|
208
|
+
process.stdout.write('\n');
|
|
209
|
+
error('Framework did not start in time.');
|
|
210
|
+
error(`Try running directly to see errors:`);
|
|
211
|
+
console.log(` node "${DIST_SERVER}"`);
|
|
212
|
+
process.exit(1);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}, intervalMs);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
// #!/usr/bin/env node
|
|
221
|
+
|
|
222
|
+
// /**
|
|
223
|
+
// * lexxit-automation-framework CLI
|
|
224
|
+
// * Usage: lexxit-automation-framework start
|
|
225
|
+
// */
|
|
226
|
+
|
|
227
|
+
// const { execSync, spawn } = require("child_process");
|
|
228
|
+
// const path = require("path");
|
|
229
|
+
// const os = require("os");
|
|
230
|
+
// const fs = require("fs");
|
|
231
|
+
|
|
232
|
+
// const args = process.argv.slice(2);
|
|
233
|
+
// const command = args[0];
|
|
234
|
+
|
|
235
|
+
// const COLORS = {
|
|
236
|
+
// reset: "\x1b[0m",
|
|
237
|
+
// green: "\x1b[32m",
|
|
238
|
+
// yellow: "\x1b[33m",
|
|
239
|
+
// red: "\x1b[31m",
|
|
240
|
+
// cyan: "\x1b[36m",
|
|
241
|
+
// bold: "\x1b[1m",
|
|
242
|
+
// };
|
|
243
|
+
|
|
244
|
+
// function log(color, prefix, msg) {
|
|
245
|
+
// console.log(`${color}${prefix}${COLORS.reset} ${msg}`);
|
|
246
|
+
// }
|
|
247
|
+
|
|
248
|
+
// function info(msg) { log(COLORS.cyan, "[lexxit]", msg); }
|
|
249
|
+
// function success(msg) { log(COLORS.green, "✔", msg); }
|
|
250
|
+
// function warn(msg) { log(COLORS.yellow, "⚠", msg); }
|
|
251
|
+
// function error(msg) { log(COLORS.red, "✖", msg); }
|
|
252
|
+
|
|
253
|
+
// // ─── COMMANDS ────────────────────────────────────────────────────────────────
|
|
254
|
+
|
|
255
|
+
// if (command === "start") {
|
|
256
|
+
// startFramework();
|
|
257
|
+
// } else if (command === "stop") {
|
|
258
|
+
// stopFramework();
|
|
259
|
+
// } else if (command === "status") {
|
|
260
|
+
// checkStatus();
|
|
261
|
+
// } else {
|
|
262
|
+
// console.log(`
|
|
263
|
+
// ${COLORS.bold}lexxit-automation-framework${COLORS.reset}
|
|
264
|
+
|
|
265
|
+
// Usage:
|
|
266
|
+
// lexxit-automation-framework start Start the local agent on port 3000
|
|
267
|
+
// lexxit-automation-framework stop Stop the running agent
|
|
268
|
+
// lexxit-automation-framework status Check if agent is running
|
|
269
|
+
// `);
|
|
270
|
+
// process.exit(0);
|
|
271
|
+
// }
|
|
272
|
+
|
|
273
|
+
// // ─── START ───────────────────────────────────────────────────────────────────
|
|
274
|
+
|
|
275
|
+
// function startFramework() {
|
|
276
|
+
// info("Starting lexxit-automation-framework...");
|
|
277
|
+
|
|
278
|
+
// // Check if already running
|
|
279
|
+
// try {
|
|
280
|
+
// const http = require("http");
|
|
281
|
+
// const req = http.get("http://localhost:3000/api/health", (res) => {
|
|
282
|
+
// if (res.statusCode === 200) {
|
|
283
|
+
// success("Framework already running on http://localhost:3000");
|
|
284
|
+
// process.exit(0);
|
|
285
|
+
// }
|
|
286
|
+
// });
|
|
287
|
+
// req.on("error", () => {
|
|
288
|
+
// // Not running — proceed to start
|
|
289
|
+
// launchServer();
|
|
290
|
+
// });
|
|
291
|
+
// req.setTimeout(1000, () => {
|
|
292
|
+
// req.destroy();
|
|
293
|
+
// launchServer();
|
|
294
|
+
// });
|
|
295
|
+
// } catch {
|
|
296
|
+
// launchServer();
|
|
297
|
+
// }
|
|
298
|
+
// }
|
|
299
|
+
|
|
300
|
+
// function launchServer() {
|
|
301
|
+
// const serverEntry = resolveServerEntry();
|
|
302
|
+
|
|
303
|
+
// if (!serverEntry) {
|
|
304
|
+
// error("Could not locate framework server entry point.");
|
|
305
|
+
// process.exit(1);
|
|
306
|
+
// }
|
|
307
|
+
|
|
308
|
+
// info(`Launching server from: ${serverEntry}`);
|
|
309
|
+
|
|
310
|
+
// // Detached spawn so it survives terminal close
|
|
311
|
+
// const child = spawn(process.execPath, [serverEntry], {
|
|
312
|
+
// detached: true,
|
|
313
|
+
// stdio: "ignore",
|
|
314
|
+
// env: { ...process.env, PORT: "3000" },
|
|
315
|
+
// });
|
|
316
|
+
|
|
317
|
+
// child.unref();
|
|
318
|
+
|
|
319
|
+
// // Write PID file for stop command
|
|
320
|
+
// const pidFile = getPidFilePath();
|
|
321
|
+
// fs.writeFileSync(pidFile, String(child.pid));
|
|
322
|
+
|
|
323
|
+
// // Wait for server to be ready
|
|
324
|
+
// info("Waiting for framework to be ready...");
|
|
325
|
+
// waitForHealth(10, () => {
|
|
326
|
+
// success("lexxit-automation-framework is running on http://localhost:3000");
|
|
327
|
+
// success(`PID: ${child.pid} (saved to ${pidFile})`);
|
|
328
|
+
// });
|
|
329
|
+
// }
|
|
330
|
+
|
|
331
|
+
// function resolveServerEntry() {
|
|
332
|
+
// // Look for the framework's main server file
|
|
333
|
+
// // Adjust this path to match your lexxit-automation-framework structure
|
|
334
|
+
// const candidates = [
|
|
335
|
+
// path.join(__dirname, "../src/server.ts"),
|
|
336
|
+
// path.join(__dirname, "../index.ts"),
|
|
337
|
+
// path.join(__dirname, "../server.ts"),
|
|
338
|
+
// path.join(__dirname, "../src/index.ts"),
|
|
339
|
+
// ];
|
|
340
|
+
|
|
341
|
+
// for (const candidate of candidates) {
|
|
342
|
+
// if (fs.existsSync(candidate)) return candidate;
|
|
343
|
+
// }
|
|
344
|
+
// return null;
|
|
345
|
+
// }
|
|
346
|
+
|
|
347
|
+
// // ─── STOP ────────────────────────────────────────────────────────────────────
|
|
348
|
+
|
|
349
|
+
// function stopFramework() {
|
|
350
|
+
// const pidFile = getPidFilePath();
|
|
351
|
+
|
|
352
|
+
// if (!fs.existsSync(pidFile)) {
|
|
353
|
+
// warn("No running framework found (no PID file).");
|
|
354
|
+
// return;
|
|
355
|
+
// }
|
|
356
|
+
|
|
357
|
+
// const pid = parseInt(fs.readFileSync(pidFile, "utf8").trim(), 10);
|
|
358
|
+
|
|
359
|
+
// try {
|
|
360
|
+
// process.kill(pid, "SIGTERM");
|
|
361
|
+
// fs.unlinkSync(pidFile);
|
|
362
|
+
// success(`Framework stopped (PID: ${pid})`);
|
|
363
|
+
// } catch (e) {
|
|
364
|
+
// error(`Failed to stop framework: ${e.message}`);
|
|
365
|
+
// fs.unlinkSync(pidFile);
|
|
366
|
+
// }
|
|
367
|
+
// }
|
|
368
|
+
|
|
369
|
+
// // ─── STATUS ──────────────────────────────────────────────────────────────────
|
|
370
|
+
|
|
371
|
+
// function checkStatus() {
|
|
372
|
+
// const http = require("http");
|
|
373
|
+
|
|
374
|
+
// info("Checking framework status...");
|
|
375
|
+
|
|
376
|
+
// const req = http.get("http://localhost:3000/api/health", (res) => {
|
|
377
|
+
// let data = "";
|
|
378
|
+
// res.on("data", (chunk) => (data += chunk));
|
|
379
|
+
// res.on("end", () => {
|
|
380
|
+
// success("Framework is RUNNING on http://localhost:3000");
|
|
381
|
+
// try {
|
|
382
|
+
// const json = JSON.parse(data);
|
|
383
|
+
// console.log(" Response:", JSON.stringify(json, null, 2));
|
|
384
|
+
// } catch {}
|
|
385
|
+
// });
|
|
386
|
+
// });
|
|
387
|
+
|
|
388
|
+
// req.on("error", () => {
|
|
389
|
+
// warn("Framework is NOT running.");
|
|
390
|
+
// });
|
|
391
|
+
|
|
392
|
+
// req.setTimeout(2000, () => {
|
|
393
|
+
// req.destroy();
|
|
394
|
+
// warn("Framework is NOT responding (timeout).");
|
|
395
|
+
// });
|
|
396
|
+
// }
|
|
397
|
+
|
|
398
|
+
// // ─── HELPERS ─────────────────────────────────────────────────────────────────
|
|
399
|
+
|
|
400
|
+
// function waitForHealth(retries, onSuccess) {
|
|
401
|
+
// if (retries === 0) {
|
|
402
|
+
// error("Framework did not start in time. Check for errors.");
|
|
403
|
+
// process.exit(1);
|
|
404
|
+
// }
|
|
405
|
+
|
|
406
|
+
// const http = require("http");
|
|
407
|
+
|
|
408
|
+
// setTimeout(() => {
|
|
409
|
+
// const req = http.get("http://localhost:3000/api/health", (res) => {
|
|
410
|
+
// console.log('response is :::::::::::::::::::', res)
|
|
411
|
+
// if (res.statusCode === 200) {
|
|
412
|
+
// onSuccess();
|
|
413
|
+
// } else {
|
|
414
|
+
// waitForHealth(retries - 1, onSuccess);
|
|
415
|
+
// }
|
|
416
|
+
// });
|
|
417
|
+
// req.on("error", () => waitForHealth(retries - 1, onSuccess));
|
|
418
|
+
// req.setTimeout(1000, () => {
|
|
419
|
+
// req.destroy();
|
|
420
|
+
// waitForHealth(retries - 1, onSuccess);
|
|
421
|
+
// });
|
|
422
|
+
// }, 1000);
|
|
423
|
+
// }
|
|
424
|
+
|
|
425
|
+
// function getPidFilePath() {
|
|
426
|
+
// return path.join(os.tmpdir(), "lexxit-automation-framework.pid");
|
|
427
|
+
// }
|
package/dist/app.d.ts
ADDED
package/dist/app.js
ADDED
|
@@ -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
|
+
const express_1 = __importDefault(require("express"));
|
|
7
|
+
const cors_1 = __importDefault(require("cors"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const api_routes_1 = __importDefault(require("./routes/api.routes"));
|
|
10
|
+
const app = (0, express_1.default)();
|
|
11
|
+
app.use((0, cors_1.default)({ origin: "*" }));
|
|
12
|
+
app.use(express_1.default.json({ limit: "20mb" }));
|
|
13
|
+
app.use(express_1.default.urlencoded({ extended: true }));
|
|
14
|
+
app.use(express_1.default.static(path_1.default.join(__dirname, "public")));
|
|
15
|
+
// Live dashboard — serves the HTML shell; JS reads executionId from URL
|
|
16
|
+
app.get("/dashboard/:executionId", (_req, res) => {
|
|
17
|
+
res.sendFile(path_1.default.join(__dirname, "public", "dashboard.html"));
|
|
18
|
+
});
|
|
19
|
+
// Multi-execution queue monitor
|
|
20
|
+
app.get("/queue-monitor", (_req, res) => {
|
|
21
|
+
res.sendFile(path_1.default.join(__dirname, "public", "queue-monitor.html"));
|
|
22
|
+
});
|
|
23
|
+
app.use("/api", api_routes_1.default);
|
|
24
|
+
app.use((_req, res) => res.status(404).json({ error: "Not found" }));
|
|
25
|
+
exports.default = app;
|
|
26
|
+
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8B;AAC9B,gDAAwB;AACxB,gDAAwB;AACxB,qEAA4C;AAE5C,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;AAEtB,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AAC/B,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AACzC,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAChD,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,MAAM,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AAExD,wEAAwE;AACxE,GAAG,CAAC,GAAG,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IAC/C,GAAG,CAAC,QAAQ,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC,CAAC;AAEH,gCAAgC;AAChC,GAAG,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IACtC,GAAG,CAAC,QAAQ,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,oBAAS,CAAC,CAAC;AAE3B,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;AAErE,kBAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Request, Response } from "express";
|
|
2
|
+
export declare class ApiController {
|
|
3
|
+
/**
|
|
4
|
+
* POST /api/run-test
|
|
5
|
+
* ------------------
|
|
6
|
+
* Enqueues execution, returns 202 + executionId immediately.
|
|
7
|
+
* The caller opens the dashboard and subscribes to SSE for live updates.
|
|
8
|
+
* Call GET /api/result/:executionId when done to get the full formatted result.
|
|
9
|
+
*/
|
|
10
|
+
static runTest(req: Request, res: Response): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* GET /api/stream/:executionId
|
|
13
|
+
* ----------------------------
|
|
14
|
+
* SSE endpoint — dashboard subscribes here for live step events.
|
|
15
|
+
* Replays all past events immediately for late-connecting clients.
|
|
16
|
+
*/
|
|
17
|
+
static stream(req: Request, res: Response): void;
|
|
18
|
+
/**
|
|
19
|
+
* GET /api/result/:executionId
|
|
20
|
+
* ----------------------------
|
|
21
|
+
* Returns the FULL formatted result once execution is complete.
|
|
22
|
+
* Returns 202 if still running (poll until 200).
|
|
23
|
+
*
|
|
24
|
+
* Response matches the standard format:
|
|
25
|
+
* {
|
|
26
|
+
* "status": "pass|fail",
|
|
27
|
+
* "results": [{ "test_script_uid": "...", "status": "...", "results": [...] }]
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
static getResult(req: Request, res: Response): void;
|
|
31
|
+
/**
|
|
32
|
+
* GET /api/status/:executionId
|
|
33
|
+
* ----------------------------
|
|
34
|
+
* Lightweight status check (progress only, no full results).
|
|
35
|
+
*/
|
|
36
|
+
static getStatus(req: Request, res: Response): void;
|
|
37
|
+
/**
|
|
38
|
+
* DELETE /api/cancel/:executionId
|
|
39
|
+
*/
|
|
40
|
+
static cancelExecution(req: Request, res: Response): void;
|
|
41
|
+
/**
|
|
42
|
+
* DELETE /api/cancel-all
|
|
43
|
+
*/
|
|
44
|
+
static cancelAll(_req: Request, res: Response): void;
|
|
45
|
+
/**
|
|
46
|
+
* GET /api/queue
|
|
47
|
+
*/
|
|
48
|
+
static getQueue(_req: Request, res: Response): void;
|
|
49
|
+
/**
|
|
50
|
+
* GET /api/health
|
|
51
|
+
*/
|
|
52
|
+
static health(_req: Request, res: Response): void;
|
|
53
|
+
/**
|
|
54
|
+
* GET /api/actions
|
|
55
|
+
*/
|
|
56
|
+
static listActions(_req: Request, res: Response): void;
|
|
57
|
+
}
|