@cutleryapp/agent 1.0.3

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 ADDED
@@ -0,0 +1,465 @@
1
+ # Cutlery Test Agent - Standalone Test Executor
2
+
3
+ A standalone, downloadable AI-powered test execution agent that developers and testers can run locally without needing the full Cutlery platform.
4
+
5
+ ## 🎯 What is This?
6
+
7
+ The Cutlery Test Agent is a command-line tool that executes test cases defined in simple JSON files. It uses Playwright for browser automation and can run tests on any machine without requiring the full Cutlery web application.
8
+
9
+ ## 📦 Installation
10
+
11
+ ### Download Pre-built Binary (Easiest)
12
+
13
+ **macOS:**
14
+
15
+ ```bash
16
+ curl -L https://github.com/yourorg/cutlery-test-agent/releases/download/v1.0.0/cutlery-agent-macos -o cutlery-agent
17
+ chmod +x cutlery-agent
18
+ sudo mv cutlery-agent /usr/local/bin/
19
+ ```
20
+
21
+ **Linux:**
22
+
23
+ ```bash
24
+ curl -L https://github.com/yourorg/cutlery-test-agent/releases/download/v1.0.0/cutlery-agent-linux -o cutlery-agent
25
+ chmod +x cutlery-agent
26
+ sudo mv cutlery-agent /usr/local/bin/
27
+ ```
28
+
29
+ **Windows:**
30
+ Download `cutlery-agent-win.exe` from releases and add to PATH.
31
+
32
+ ### Install via npm
33
+
34
+ ```bash
35
+ npm install -g @cutlery/test-agent
36
+ ```
37
+
38
+ ### Install Playwright Browsers
39
+
40
+ After installation, install required browsers:
41
+
42
+ ```bash
43
+ npx playwright install chromium
44
+ # Optional: install other browsers
45
+ npx playwright install firefox webkit
46
+ ```
47
+
48
+ ## 🚀 Quick Start
49
+
50
+ ### 1. Create a Test Case
51
+
52
+ Create a file `my-test.json`:
53
+
54
+ ```json
55
+ {
56
+ "name": "Login Test",
57
+ "test_case_id": "TC_001",
58
+ "automated_steps": [
59
+ "Navigate to https://example.com/login",
60
+ "Wait 1 second",
61
+ "Fill \"user@example.com\" in \"email\"",
62
+ "Fill \"password123\" in \"password\"",
63
+ "Click \"Login\"",
64
+ "Wait for \"Welcome\" to be visible",
65
+ "Check if \"Dashboard\" is visible"
66
+ ],
67
+ "test_variables": {
68
+ "email": "user@example.com",
69
+ "password": "password123"
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### 2. Run the Test
75
+
76
+ ```bash
77
+ cutlery-agent run my-test.json
78
+ ```
79
+
80
+ ### 3. See Browser in Action (Non-Headless)
81
+
82
+ ```bash
83
+ cutlery-agent run my-test.json --no-headless
84
+ ```
85
+
86
+ ## 📋 Command Reference
87
+
88
+ ### Run a Test
89
+
90
+ ```bash
91
+ cutlery-agent run <test-file.json> [options]
92
+ ```
93
+
94
+ **Options:**
95
+
96
+ - `-h, --headless` - Run in headless mode (default: false)
97
+ - `-b, --browser <type>` - Browser type: chromium, firefox, webkit (default: chromium)
98
+ - `-u, --base-url <url>` - Base URL for the application
99
+ - `-o, --output <path>` - Output directory for screenshots/videos (default: ./test-results)
100
+ - `-v, --verbose` - Verbose output
101
+ - `--openai-key <key>` - OpenAI API key for AI features
102
+
103
+ **Examples:**
104
+
105
+ ```bash
106
+ # Run with visible browser
107
+ cutlery-agent run test.json
108
+
109
+ # Run in headless mode
110
+ cutlery-agent run test.json --headless
111
+
112
+ # Use Firefox browser
113
+ cutlery-agent run test.json --browser firefox
114
+
115
+ # Custom output directory
116
+ cutlery-agent run test.json --output ./my-results
117
+
118
+ # Verbose output
119
+ cutlery-agent run test.json --verbose
120
+ ```
121
+
122
+ ### Validate a Test Case
123
+
124
+ ```bash
125
+ cutlery-agent validate <test-file.json>
126
+ ```
127
+
128
+ Checks if your test case JSON is valid before running it.
129
+
130
+ ### Generate Example
131
+
132
+ ```bash
133
+ cutlery-agent example [output-file.json]
134
+ ```
135
+
136
+ Creates an example test case file you can modify.
137
+
138
+ ## 📝 Test Case Format
139
+
140
+ ### Basic Structure
141
+
142
+ ```json
143
+ {
144
+ "name": "Test Name",
145
+ "test_case_id": "TC_ID",
146
+ "automated_steps": ["step 1", "step 2"],
147
+ "test_variables": {
148
+ "variable1": "value1"
149
+ }
150
+ }
151
+ ```
152
+
153
+ ### Supported Step Types
154
+
155
+ #### Navigation
156
+
157
+ ```json
158
+ "Navigate to https://example.com"
159
+ "Go to https://example.com/page"
160
+ ```
161
+
162
+ #### Waiting
163
+
164
+ ```json
165
+ "Wait 2 seconds"
166
+ "Wait for \"#button\" to be visible"
167
+ "Wait for \".loading\" to be visible"
168
+ ```
169
+
170
+ #### Filling Forms
171
+
172
+ ```json
173
+ "Fill \"text\" in \"selector\""
174
+ "Fill \"user@example.com\" in \"input[name='email']\""
175
+ "Fill \"password\" in \"#password\""
176
+ ```
177
+
178
+ Smart field matching (no selector needed):
179
+
180
+ ```json
181
+ "Fill \"user@example.com\" in \"email\""
182
+ "Fill \"password123\" in \"password\""
183
+ ```
184
+
185
+ #### Clicking Elements
186
+
187
+ ```json
188
+ "Click \"button[type='submit'\""
189
+ "Click \"#login-button\""
190
+ ```
191
+
192
+ Smart button matching (no selector needed):
193
+
194
+ ```json
195
+ "Click \"Login\""
196
+ "Click \"Submit\""
197
+ "Click \"Sign Up\""
198
+ ```
199
+
200
+ #### Checking Visibility
201
+
202
+ ```json
203
+ "Check if \"Welcome\" is visible"
204
+ "Check if \"Error message\" is visible"
205
+ ```
206
+
207
+ #### Screenshots
208
+
209
+ ```json
210
+ "Take screenshot"
211
+ "Capture screen"
212
+ ```
213
+
214
+ ### Using Variables
215
+
216
+ Define variables and use them in steps:
217
+
218
+ ```json
219
+ {
220
+ "test_variables": {
221
+ "username": "testuser",
222
+ "password": "secret123",
223
+ "url": "https://example.com"
224
+ },
225
+ "automated_steps": [
226
+ "Navigate to {{url}}",
227
+ "Fill \"{{username}}\" in \"username\"",
228
+ "Fill \"{{password}}\" in \"password\""
229
+ ]
230
+ }
231
+ ```
232
+
233
+ ## 🔧 Configuration
234
+
235
+ ### Environment Variables
236
+
237
+ Create a `.env` file in your project:
238
+
239
+ ```bash
240
+ # OpenAI API Key (optional, for AI features)
241
+ OPENAI_API_KEY=sk-...
242
+
243
+ # Default base URL
244
+ BASE_URL=http://localhost:3000
245
+
246
+ # Default browser
247
+ BROWSER_TYPE=chromium
248
+
249
+ # Headless mode
250
+ HEADLESS=true
251
+ ```
252
+
253
+ ### OpenAI Integration (Optional)
254
+
255
+ For AI-enhanced test execution, provide an OpenAI API key:
256
+
257
+ ```bash
258
+ export OPENAI_API_KEY=sk-...
259
+ ```
260
+
261
+ Or use the flag:
262
+
263
+ ```bash
264
+ cutlery-agent run test.json --openai-key sk-...
265
+ ```
266
+
267
+ ## 📊 Output
268
+
269
+ ### Console Output
270
+
271
+ ```
272
+ 📊 Test Case: Login Test
273
+ Steps: 7
274
+ Browser: chromium
275
+ Headless: false
276
+ Base URL: http://localhost:3000
277
+
278
+ ✅ Test PASSED
279
+
280
+ 📊 Test Results:
281
+ Total Steps: 7
282
+ Passed: 7
283
+ Screenshots: 2
284
+ ```
285
+
286
+ ### Screenshots
287
+
288
+ Screenshots are saved to the output directory:
289
+
290
+ - `test-results/step-1-<timestamp>.png`
291
+ - `test-results/error-step-3-<timestamp>.png`
292
+ - `test-results/final-<timestamp>.png`
293
+
294
+ ## 🔄 CI/CD Integration
295
+
296
+ ### GitHub Actions
297
+
298
+ ```yaml
299
+ name: Run Tests
300
+
301
+ on: [push, pull_request]
302
+
303
+ jobs:
304
+ test:
305
+ runs-on: ubuntu-latest
306
+ steps:
307
+ - uses: actions/checkout@v3
308
+
309
+ - name: Setup Node.js
310
+ uses: actions/setup-node@v3
311
+ with:
312
+ node-version: "18"
313
+
314
+ - name: Install Cutlery Agent
315
+ run: npm install -g @cutlery/test-agent
316
+
317
+ - name: Install Playwright browsers
318
+ run: npx playwright install --with-deps chromium
319
+
320
+ - name: Run tests
321
+ run: cutlery-agent run tests/my-test.json --headless --verbose
322
+
323
+ - name: Upload screenshots
324
+ if: always()
325
+ uses: actions/upload-artifact@v3
326
+ with:
327
+ name: test-screenshots
328
+ path: test-results/
329
+ ```
330
+
331
+ ### Jenkins
332
+
333
+ ```groovy
334
+ pipeline {
335
+ agent any
336
+ stages {
337
+ stage('Setup') {
338
+ steps {
339
+ sh 'npm install -g @cutlery/test-agent'
340
+ sh 'npx playwright install chromium'
341
+ }
342
+ }
343
+ stage('Test') {
344
+ steps {
345
+ sh 'cutlery-agent run tests/*.json --headless --verbose'
346
+ }
347
+ }
348
+ }
349
+ post {
350
+ always {
351
+ archiveArtifacts artifacts: 'test-results/**/*', fingerprint: true
352
+ }
353
+ }
354
+ }
355
+ ```
356
+
357
+ ## 🎓 Examples
358
+
359
+ ### Example 1: Simple Login Test
360
+
361
+ ```json
362
+ {
363
+ "name": "Login Flow",
364
+ "automated_steps": [
365
+ "Navigate to https://app.example.com",
366
+ "Fill \"user@test.com\" in \"email\"",
367
+ "Fill \"password123\" in \"password\"",
368
+ "Click \"Sign In\"",
369
+ "Check if \"Dashboard\" is visible"
370
+ ]
371
+ }
372
+ ```
373
+
374
+ ### Example 2: E-commerce Checkout
375
+
376
+ ```json
377
+ {
378
+ "name": "Checkout Flow",
379
+ "test_variables": {
380
+ "product_url": "https://shop.example.com/products/123"
381
+ },
382
+ "automated_steps": [
383
+ "Navigate to {{product_url}}",
384
+ "Click \"Add to Cart\"",
385
+ "Wait 1 second",
386
+ "Click \"View Cart\"",
387
+ "Click \"Proceed to Checkout\"",
388
+ "Fill \"John Doe\" in \"input[name='name']\"",
389
+ "Fill \"john@example.com\" in \"input[name='email']\"",
390
+ "Click \"Place Order\"",
391
+ "Check if \"Order Confirmed\" is visible"
392
+ ]
393
+ }
394
+ ```
395
+
396
+ ### Example 3: Form Validation
397
+
398
+ ```json
399
+ {
400
+ "name": "Form Validation Test",
401
+ "automated_steps": [
402
+ "Navigate to https://example.com/signup",
403
+ "Click \"Submit\"",
404
+ "Check if \"Email is required\" is visible",
405
+ "Fill \"invalid-email\" in \"email\"",
406
+ "Click \"Submit\"",
407
+ "Check if \"Invalid email format\" is visible",
408
+ "Fill \"valid@email.com\" in \"email\"",
409
+ "Fill \"short\" in \"password\"",
410
+ "Click \"Submit\"",
411
+ "Check if \"Password must be at least 8 characters\" is visible"
412
+ ]
413
+ }
414
+ ```
415
+
416
+ ## 🐛 Troubleshooting
417
+
418
+ ### Browsers Not Found
419
+
420
+ ```bash
421
+ # Install browsers
422
+ npx playwright install chromium firefox webkit
423
+ ```
424
+
425
+ ### Permission Denied (macOS/Linux)
426
+
427
+ ```bash
428
+ chmod +x cutlery-agent
429
+ ```
430
+
431
+ ### PATH Issues
432
+
433
+ Make sure `/usr/local/bin` is in your PATH:
434
+
435
+ ```bash
436
+ echo $PATH
437
+ export PATH="/usr/local/bin:$PATH"
438
+ ```
439
+
440
+ ### Test Fails with "Could not interpret step"
441
+
442
+ - Check step syntax matches examples above
443
+ - Use `--verbose` flag to see detailed error messages
444
+ - Try using explicit selectors instead of text matching
445
+
446
+ ## 🤝 Contributing
447
+
448
+ 1. Fork the repository
449
+ 2. Create a feature branch
450
+ 3. Make your changes
451
+ 4. Submit a pull request
452
+
453
+ ## 📄 License
454
+
455
+ MIT License - see LICENSE file for details
456
+
457
+ ## 🆘 Support
458
+
459
+ - GitHub Issues: https://github.com/yourorg/cutlery-test-agent/issues
460
+ - Documentation: https://docs.cutlery.dev
461
+ - Discord: https://discord.gg/cutlery
462
+
463
+ ---
464
+
465
+ **Made with ❤️ by the Cutlery Team**