qa-deck-backend 1.0.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/.env.example +6 -0
- package/README.md +126 -0
- package/bin/cli.js +36 -0
- package/dashboard/index.html +1222 -0
- package/dashboard/recorder.html +1359 -0
- package/package.json +23 -0
- package/recorder/cicd.js +760 -0
- package/recorder/converter.js +539 -0
- package/recorder/recorder.js +294 -0
- package/server.js +4616 -0
package/.env.example
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# QA Deck ā Backend API
|
|
2
|
+
|
|
3
|
+
Local Node.js backend for the QA Deck Chrome extension.
|
|
4
|
+
|
|
5
|
+
It provides:
|
|
6
|
+
- AI generation endpoints used by the extension
|
|
7
|
+
- disk-backed project storage
|
|
8
|
+
- a Playwright-powered recorder
|
|
9
|
+
- static dashboard pages for projects and recording
|
|
10
|
+
|
|
11
|
+
The server entry point is `server.js`.
|
|
12
|
+
|
|
13
|
+
## Start
|
|
14
|
+
|
|
15
|
+
In a clean checkout, install dependencies first:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install
|
|
19
|
+
npm start
|
|
20
|
+
# or
|
|
21
|
+
./start.sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Server starts on `http://localhost:3747`.
|
|
25
|
+
|
|
26
|
+
## Endpoints
|
|
27
|
+
|
|
28
|
+
| Method | Path | Description |
|
|
29
|
+
|--------|------|-------------|
|
|
30
|
+
| GET | `/api/health` | Health check and project count |
|
|
31
|
+
| POST | `/api/generate-tests` | Generate test cases from extracted page data |
|
|
32
|
+
| POST | `/api/generate-script` | Generate automation scripts |
|
|
33
|
+
| POST | `/api/save-project` | Save a project to disk |
|
|
34
|
+
| GET | `/api/projects` | List saved projects |
|
|
35
|
+
| GET | `/api/projects/:id` | Fetch a specific project |
|
|
36
|
+
| POST | `/api/generate-cicd` | Generate CI/CD starter files |
|
|
37
|
+
| POST | `/api/record/start` | Start a recorder session |
|
|
38
|
+
| GET | `/api/record/sessions` | List recorder sessions |
|
|
39
|
+
| GET | `/api/proxy` | Proxy a page into the recorder dashboard |
|
|
40
|
+
|
|
41
|
+
## Request format
|
|
42
|
+
|
|
43
|
+
### POST /api/generate-tests
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"pageData": { "...": "From the extension content script" },
|
|
48
|
+
"apiKey": "provider-specific key"
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### POST /api/generate-script
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"testCases": [],
|
|
57
|
+
"pageData": {},
|
|
58
|
+
"framework": "selenium-python | selenium-java | playwright-python | playwright-typescript",
|
|
59
|
+
"apiKey": "provider-specific key"
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Architecture
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
Extension Backend Provider API
|
|
67
|
+
| | |
|
|
68
|
+
|- SCAN_PAGE ---------------> | not involved |
|
|
69
|
+
| | |
|
|
70
|
+
|- GENERATE_TESTS ----------> | POST /api/generate-tests |
|
|
71
|
+
| |-------------------------->|
|
|
72
|
+
| |<--------------------------|
|
|
73
|
+
|<----------------------------| { testCases: [...] } |
|
|
74
|
+
| | |
|
|
75
|
+
|- GENERATE_SCRIPT ---------> | POST /api/generate-script |
|
|
76
|
+
| |-------------------------->|
|
|
77
|
+
| |<--------------------------|
|
|
78
|
+
|<----------------------------| { scripts: {...} } |
|
|
79
|
+
| | |
|
|
80
|
+
|- RECORD / CI-CD ----------> | local-only routes |
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If the backend is offline, the extension falls back to direct browser-side provider calls for test generation, script generation, and local project storage. Recorder features remain backend-only.
|
|
84
|
+
|
|
85
|
+
## Offline / Fallback mode
|
|
86
|
+
|
|
87
|
+
When the backend is unreachable:
|
|
88
|
+
- generation calls are made directly from the extension service worker
|
|
89
|
+
- projects are saved in `chrome.storage.local` instead of disk
|
|
90
|
+
- the side panel shows `Direct API mode`
|
|
91
|
+
- recorder and dashboard features are unavailable
|
|
92
|
+
|
|
93
|
+
## Projects storage
|
|
94
|
+
|
|
95
|
+
Projects are saved as JSON files in `./projects/`:
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
projects/
|
|
99
|
+
abc123.json
|
|
100
|
+
def456.json
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Rate limiting
|
|
104
|
+
|
|
105
|
+
The current code allows up to 300 requests/minute per non-local IP and skips rate limiting for localhost recorder traffic. If you change that behavior, update this document at the same time.
|
|
106
|
+
|
|
107
|
+
## Port
|
|
108
|
+
|
|
109
|
+
Default:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
PORT=3747 npm start
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Override:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
PORT=4000 npm start
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Notes for contributors
|
|
122
|
+
|
|
123
|
+
- `package.json` includes convenience scripts for `start` and `dev`
|
|
124
|
+
- `.env.example` documents only the environment variables currently used by the server
|
|
125
|
+
- `playwright` is required for recorder functionality
|
|
126
|
+
- generated project files and `node_modules/` should not be treated as source files
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync, spawn } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
|
|
7
|
+
const serverPath = path.join(__dirname, "..", "server.js");
|
|
8
|
+
|
|
9
|
+
// Check if Playwright Chromium is installed, install if not
|
|
10
|
+
function ensurePlaywright() {
|
|
11
|
+
try {
|
|
12
|
+
const cacheDir = path.join(require("os").homedir(), ".cache", "ms-playwright");
|
|
13
|
+
const hasChromium = fs.existsSync(cacheDir) &&
|
|
14
|
+
fs.readdirSync(cacheDir).some(d => d.startsWith("chromium"));
|
|
15
|
+
if (!hasChromium) {
|
|
16
|
+
console.log("Installing Playwright browser (first run only)...");
|
|
17
|
+
execSync("npx playwright install chromium", { stdio: "inherit" });
|
|
18
|
+
}
|
|
19
|
+
} catch {
|
|
20
|
+
// Non-fatal ā server will show error when Capture is used
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
ensurePlaywright();
|
|
25
|
+
|
|
26
|
+
console.log("\nš QA Deck Backend starting...");
|
|
27
|
+
console.log(" Keep this Terminal window open while using Capture.\n");
|
|
28
|
+
|
|
29
|
+
const server = spawn("node", [serverPath], { stdio: "inherit" });
|
|
30
|
+
|
|
31
|
+
server.on("exit", (code) => process.exit(code ?? 0));
|
|
32
|
+
|
|
33
|
+
process.on("SIGINT", () => {
|
|
34
|
+
server.kill("SIGINT");
|
|
35
|
+
process.exit(0);
|
|
36
|
+
});
|