endorphin-ai 0.3.0 → 0.4.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 CHANGED
@@ -42,7 +42,13 @@ npm install endorphin-ai
42
42
  npx endorphin run test HEALTH-001
43
43
  ```
44
44
 
45
- That's it! Your project is ready with a sample test, configuration, and all necessary directories.
45
+ 4. Generate an interactive HTML report:
46
+ ```bash
47
+ npx endorphin generate report
48
+ npx endorphin open report
49
+ ```
50
+
51
+ That's it! Your project is ready with a sample test, configuration, all necessary directories, and beautiful HTML reporting.
46
52
 
47
53
  ### Manual Setup (Alternative)
48
54
  If you prefer manual setup:
@@ -227,6 +233,70 @@ npm run test:record
227
233
  npx endorphin run test-recorder
228
234
  ```
229
235
 
236
+ ## šŸ“Š HTML Reports & Analytics
237
+
238
+ Endorphin AI generates beautiful, interactive HTML reports that provide comprehensive insights into your test execution results.
239
+
240
+ ### šŸš€ Quick Report Generation
241
+
242
+ ```bash
243
+ # Generate a full interactive HTML report
244
+ npx endorphin generate report
245
+
246
+ # Generate a lightweight summary report
247
+ npx endorphin generate report --summary
248
+
249
+ # Open the latest report in your browser
250
+ npx endorphin open report
251
+
252
+ # Open a specific report file
253
+ npx endorphin open report report-2025-06-22.html
254
+ ```
255
+
256
+ ### ✨ Report Features
257
+
258
+ #### šŸ“ˆ **Interactive Dashboard**
259
+ - **Real-time Statistics**: Success rates, test counts, execution trends
260
+ - **Visual Progress Bars**: Easy-to-understand success rate indicators
261
+ - **Summary Cards**: Quick overview of test health
262
+
263
+ #### šŸ” **Advanced Search & Filtering**
264
+ - **Real-time Search**: Find tests by name or ID instantly
265
+ - **Status Filtering**: Filter by passed/failed tests with one click
266
+ - **Smart Results**: Shows "5 of 25 tests matching 'login' with status 'failed'"
267
+ - **Keyboard Shortcuts**: `Ctrl+F` to search, `Ctrl+3` for failed tests only
268
+
269
+ #### šŸŽÆ **Detailed Test Analysis**
270
+ - **Step-by-Step Timeline**: See exactly what happened during test execution
271
+ - **Screenshot Galleries**: Visual debugging with click-to-zoom screenshots
272
+ - **Interactive Modals**: Deep dive into test execution details
273
+ - **Tool Call Tracking**: See which browser actions were performed
274
+
275
+ #### āŒØļø **Productivity Features**
276
+ - **Export to JSON**: Data-driven analysis and custom reporting
277
+ - **Print Support**: Documentation-ready printed reports
278
+ - **Responsive Design**: Works on desktop, tablet, and mobile
279
+ - **Performance Optimized**: Fast loading even with large test suites
280
+
281
+ ### šŸ› ļø Report Management
282
+
283
+ ```bash
284
+ # Clean up old test results (keep 10 most recent per test)
285
+ npx endorphin cleanup results
286
+
287
+ # Keep only 5 most recent results per test
288
+ npx endorphin cleanup results 5
289
+
290
+ # Clean up old report files (older than 30 days)
291
+ npx endorphin cleanup reports
292
+
293
+ # Clean up report files older than 7 days
294
+ npx endorphin cleanup reports 7
295
+ ```
296
+
297
+ ### šŸ“– Complete Guide
298
+ For detailed usage instructions, advanced features, and best practices, see the **[HTML Reporter User Guide](./doc/user-guide/HTML-Reporter-Guide.md)**.
299
+
230
300
  ## šŸ—ļø Framework Architecture
231
301
 
232
302
  Endorphin AI is built with a modular, extensible architecture designed for reliability and maintainability.
@@ -412,6 +482,145 @@ Intelligent AI-powered tools for navigation, interaction, verification, and util
412
482
 
413
483
  The framework is production-ready and provides a solid foundation for scalable browser automation testing!
414
484
 
485
+ ## šŸŽ® Complete CLI Reference
486
+
487
+ ### Core Commands
488
+
489
+ #### Test Execution
490
+ ```bash
491
+ # Run a specific test
492
+ npx endorphin run test TEST-001
493
+
494
+ # Run all tests
495
+ npx endorphin run test all
496
+
497
+ # Run tests by tag
498
+ npx endorphin run test --tag smoke
499
+ npx endorphin run test --tag authentication
500
+
501
+ # Run tests by priority
502
+ npx endorphin run test --priority High
503
+ npx endorphin run test --priority Medium
504
+ ```
505
+
506
+ #### Test Creation & Recording
507
+ ```bash
508
+ # Start interactive test recorder
509
+ npx endorphin run test-recorder
510
+
511
+ # List all available tests
512
+ npx endorphin list
513
+ ```
514
+
515
+ #### Project Setup
516
+ ```bash
517
+ # Initialize new project (recommended for new projects)
518
+ npx endorphin init
519
+
520
+ # Show help and available commands
521
+ npx endorphin --help
522
+ npx endorphin help
523
+
524
+ # Check current version
525
+ npx endorphin --version
526
+ ```
527
+
528
+ ### HTML Reports & Analytics
529
+
530
+ #### Report Generation
531
+ ```bash
532
+ # Generate full interactive HTML report
533
+ npx endorphin generate report
534
+
535
+ # Generate lightweight summary report
536
+ npx endorphin generate report --summary
537
+ ```
538
+
539
+ #### Report Management
540
+ ```bash
541
+ # Open latest report in browser
542
+ npx endorphin open report
543
+
544
+ # Open specific report file
545
+ npx endorphin open report report-2025-06-22.html
546
+ npx endorphin open report summary-report.html
547
+ ```
548
+
549
+ #### Cleanup Commands
550
+ ```bash
551
+ # Clean old test results (keep 10 most recent per test)
552
+ npx endorphin cleanup results
553
+
554
+ # Keep only 5 most recent results per test
555
+ npx endorphin cleanup results 5
556
+
557
+ # Clean old report files (older than 30 days)
558
+ npx endorphin cleanup reports
559
+
560
+ # Clean report files older than 7 days
561
+ npx endorphin cleanup reports 7
562
+ ```
563
+
564
+ ### Advanced Options
565
+
566
+ #### Browser Configuration
567
+ ```bash
568
+ # Use different browsers
569
+ npx endorphin run test all --browser firefox
570
+ npx endorphin run test all --browser webkit
571
+
572
+ # Headless/headed mode
573
+ npx endorphin run test all --no-headless
574
+ npx endorphin run test all --headless
575
+
576
+ # Custom viewport
577
+ npx endorphin run test all --viewport 1920x1080
578
+ npx endorphin run test all --viewport 1366x768
579
+ ```
580
+
581
+ #### AI & Performance
582
+ ```bash
583
+ # Use different AI models
584
+ npx endorphin run test all --model gpt-4
585
+ npx endorphin run test all --model gpt-4o-mini
586
+
587
+ # Parallel execution
588
+ npx endorphin run test all --parallel 3
589
+ npx endorphin run test all --parallel 5
590
+
591
+ # Environment selection
592
+ npx endorphin run test all --env staging
593
+ npx endorphin run test all --env production
594
+ ```
595
+
596
+ ### npm Scripts Integration
597
+
598
+ Add these to your `package.json`:
599
+
600
+ ```json
601
+ {
602
+ "scripts": {
603
+ "test": "endorphin run test all",
604
+ "test:smoke": "endorphin run test --tag smoke",
605
+ "test:auth": "endorphin run test --tag authentication",
606
+ "test:single": "endorphin run test",
607
+ "test:record": "endorphin run test-recorder",
608
+ "test:report": "endorphin generate report",
609
+ "test:summary": "endorphin generate report --summary",
610
+ "test:open": "endorphin open report",
611
+ "test:cleanup": "endorphin cleanup results"
612
+ }
613
+ }
614
+ ```
615
+
616
+ Then use npm scripts:
617
+ ```bash
618
+ npm test # Run all tests
619
+ npm run test:smoke # Run smoke tests
620
+ npm run test:report # Generate HTML report
621
+ npm run test:open # Open latest report
622
+ ```
623
+
415
624
  ## šŸ”„ Staying Updated
416
625
 
417
626
  ### Check Your Version
package/bin/endorphin.js CHANGED
@@ -110,14 +110,19 @@ Usage:
110
110
  endorphin <command> [options]
111
111
 
112
112
  Commands:
113
- init Initialize new project with examples
114
- run test <test-id> Run a specific test (e.g., QE-001)
115
- run test all Run all tests
116
- run test --tag <tag> Run tests by tag (e.g., authentication)
117
- run test --priority <level> Run tests by priority (High, Medium, Low)
118
- run test-recorder Start interactive test recorder
119
- list List all available tests
120
- help Show this help message
113
+ init Initialize new project with examples
114
+ run test <test-id> Run a specific test (e.g., QE-001)
115
+ run test all Run all tests
116
+ run test --tag <tag> Run tests by tag (e.g., authentication)
117
+ run test --priority <level> Run tests by priority (High, Medium, Low)
118
+ run test-recorder Start interactive test recorder
119
+ list List all available tests
120
+ generate report Generate HTML test report
121
+ generate report --summary Generate lightweight summary report
122
+ open report [file] Open latest (or specific) test report in browser
123
+ cleanup results [count] Clean up old test results (keep N per test, default: 10)
124
+ cleanup reports [days] Clean up old report files (older than N days, default: 30)
125
+ help Show this help message
121
126
 
122
127
  Options:
123
128
  --headless Run browser in headless mode
@@ -136,6 +141,12 @@ Examples:
136
141
  endorphin run test --priority High --env staging # Run high priority tests on staging
137
142
  endorphin run test-recorder # Start test recorder
138
143
  endorphin list # Show all available tests
144
+ endorphin generate report # Generate interactive HTML report
145
+ endorphin generate report --summary # Generate lightweight summary report
146
+ endorphin generate report --file custom.html # Generate report with custom filename
147
+ endorphin open report # Open latest report in browser
148
+ endorphin cleanup results 5 # Keep only 5 recent results per test
149
+ endorphin cleanup reports 7 # Remove reports older than 7 days
139
150
 
140
151
  Configuration:
141
152
  Create endorphin.config.js in your project root for default settings
@@ -159,6 +170,18 @@ async function main() {
159
170
  process.exit(0);
160
171
  }
161
172
 
173
+ // Display Endorphin molecular structure for test commands
174
+ const command = args[0];
175
+ const subcommand = args[1];
176
+ const target = args[2];
177
+
178
+ if (command === 'run' && (subcommand === 'test' || subcommand === 'test-recorder')) {
179
+ // Import ConsoleReporter and display molecular structure
180
+ const { ConsoleReporter } = await import('../framework/core/console-reporter.js');
181
+ const reporter = new ConsoleReporter();
182
+ reporter.displayEndorphinMolecule();
183
+ }
184
+
162
185
  // Load configuration with CLI flag overrides
163
186
  const cliFlags = parseCliFlags(args);
164
187
  const config = await getConfig({ cwd: process.cwd(), cliFlags });
@@ -168,10 +191,6 @@ async function main() {
168
191
  console.log('šŸ”§ Loaded configuration:', JSON.stringify(config, null, 2));
169
192
  }
170
193
 
171
- const command = args[0];
172
- const subcommand = args[1];
173
- const target = args[2];
174
-
175
194
  // Handle list command
176
195
  if (command === 'list') {
177
196
  console.log('šŸ“‹ Available Tests:');
@@ -247,6 +266,81 @@ async function main() {
247
266
  process.exit(1);
248
267
  }
249
268
 
269
+ // Handle generate command
270
+ if (command === 'generate') {
271
+ if (subcommand === 'report') {
272
+ console.log('šŸ“Š Generating HTML test report...');
273
+ const { HTMLReporter } = await import('../framework/core/reporter.js');
274
+ const reporter = new HTMLReporter();
275
+
276
+ const options = {};
277
+
278
+ // Parse additional flags for report generation
279
+ if (args.includes('--summary')) {
280
+ const reportPath = await reporter.generateSummaryReport(options);
281
+ console.log(`āœ… Summary report generated: ${reportPath}`);
282
+ } else {
283
+ // Check for custom filename
284
+ const fileIndex = args.indexOf('--file');
285
+ if (fileIndex !== -1 && args[fileIndex + 1]) {
286
+ options.filename = args[fileIndex + 1];
287
+ }
288
+
289
+ const reportPath = await reporter.generateReport(options);
290
+ console.log(`🌐 Open report: ${reportPath}`);
291
+ }
292
+ process.exit(0);
293
+ }
294
+
295
+ console.error(`āŒ Unknown generate command: ${subcommand}`);
296
+ console.log('Use "endorphin help" for usage information');
297
+ process.exit(1);
298
+ }
299
+
300
+ // Handle open command
301
+ if (command === 'open') {
302
+ if (subcommand === 'report') {
303
+ console.log('🌐 Opening latest test report...');
304
+ const { HTMLReporter } = await import('../framework/core/reporter.js');
305
+ const reporter = new HTMLReporter();
306
+
307
+ // Check for specific report file
308
+ const reportPath = target || null;
309
+ await reporter.openReport(reportPath);
310
+ process.exit(0);
311
+ }
312
+
313
+ console.error(`āŒ Unknown open command: ${subcommand}`);
314
+ console.log('Use "endorphin help" for usage information');
315
+ process.exit(1);
316
+ }
317
+
318
+ // Handle cleanup command
319
+ if (command === 'cleanup') {
320
+ const { HTMLReporter } = await import('../framework/core/reporter.js');
321
+ const reporter = new HTMLReporter();
322
+
323
+ if (subcommand === 'results') {
324
+ console.log('🧹 Cleaning up old test results...');
325
+ const keepCount = parseInt(target) || 10;
326
+ const cleanup = await reporter.cleanupResults(keepCount);
327
+ console.log(`āœ… Cleanup completed: ${cleanup.removedCount} directories removed`);
328
+ process.exit(0);
329
+ }
330
+
331
+ if (subcommand === 'reports') {
332
+ console.log('🧹 Cleaning up old report files...');
333
+ const maxAge = parseInt(target) || 30;
334
+ const cleanup = await reporter.cleanupOldReports(maxAge);
335
+ console.log(`āœ… Cleanup completed: ${cleanup.removedCount} report files removed`);
336
+ process.exit(0);
337
+ }
338
+
339
+ console.error(`āŒ Unknown cleanup command: ${subcommand}`);
340
+ console.log('Available: cleanup results [count], cleanup reports [days]');
341
+ process.exit(1);
342
+ }
343
+
250
344
  console.error(`āŒ Unknown command: ${command}`);
251
345
  console.log('Use "endorphin help" for usage information');
252
346
  process.exit(1);
@@ -0,0 +1,13 @@
1
+ {
2
+ "testName": "Framework Health Check",
3
+ "sessionId": "HEALTH-001",
4
+ "status": "FAILED",
5
+ "startTime": "2025-06-22T22:39:35.384Z",
6
+ "endTime": "2025-06-22T22:39:35.386Z",
7
+ "duration": 2,
8
+ "totalSteps": 2,
9
+ "successfulSteps": 1,
10
+ "failedSteps": 1,
11
+ "totalScreenshots": 0,
12
+ "finalResult": "The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' })."
13
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "sessionId": "HEALTH-001",
3
+ "sessionName": "HEALTH-001_2025-06-22T22-39-35-383Z",
4
+ "testName": "Framework Health Check",
5
+ "testId": "HEALTH-001",
6
+ "startTime": "2025-06-22T22:39:35.384Z",
7
+ "endTime": "2025-06-22T22:39:35.386Z",
8
+ "sessionDir": "/Users/papapin777/Documents/CODE/AI/endorphin-ai/examples/test-results/HEALTH-001_2025-06-22T22-39-35-383Z",
9
+ "screenshotsDir": "/Users/papapin777/Documents/CODE/AI/endorphin-ai/examples/test-results/HEALTH-001_2025-06-22T22-39-35-383Z/screenshots",
10
+ "steps": [
11
+ {
12
+ "stepNumber": 1,
13
+ "timestamp": "2025-06-22T22:39:35.384Z",
14
+ "description": "Starting test execution: Framework Health Check",
15
+ "toolName": null,
16
+ "toolArgs": null,
17
+ "result": "Test ID: HEALTH-001",
18
+ "status": "SUCCESS",
19
+ "screenshots": []
20
+ },
21
+ {
22
+ "stepNumber": 2,
23
+ "timestamp": "2025-06-22T22:39:35.386Z",
24
+ "description": "Test execution failed",
25
+ "toolName": null,
26
+ "toolArgs": null,
27
+ "result": "The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).",
28
+ "status": "FAILED",
29
+ "screenshots": []
30
+ }
31
+ ],
32
+ "toolCalls": [],
33
+ "stepCounter": 2,
34
+ "screenshotCounter": 0,
35
+ "status": "FAILED",
36
+ "finalResult": "The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).",
37
+ "duration": 2
38
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "testName": "Basic Login Test",
3
+ "sessionId": "QE-001",
4
+ "status": "FAILED",
5
+ "startTime": "2025-06-22T22:39:35.370Z",
6
+ "endTime": "2025-06-22T22:39:35.383Z",
7
+ "duration": 13,
8
+ "totalSteps": 2,
9
+ "successfulSteps": 1,
10
+ "failedSteps": 1,
11
+ "totalScreenshots": 0,
12
+ "finalResult": "The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' })."
13
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "sessionId": "QE-001",
3
+ "sessionName": "QE-001_2025-06-22T22-39-35-364Z",
4
+ "testName": "Basic Login Test",
5
+ "testId": "QE-001",
6
+ "startTime": "2025-06-22T22:39:35.370Z",
7
+ "endTime": "2025-06-22T22:39:35.383Z",
8
+ "sessionDir": "/Users/papapin777/Documents/CODE/AI/endorphin-ai/examples/test-results/QE-001_2025-06-22T22-39-35-364Z",
9
+ "screenshotsDir": "/Users/papapin777/Documents/CODE/AI/endorphin-ai/examples/test-results/QE-001_2025-06-22T22-39-35-364Z/screenshots",
10
+ "steps": [
11
+ {
12
+ "stepNumber": 1,
13
+ "timestamp": "2025-06-22T22:39:35.370Z",
14
+ "description": "Starting test execution: Basic Login Test",
15
+ "toolName": null,
16
+ "toolArgs": null,
17
+ "result": "Test ID: QE-001",
18
+ "status": "SUCCESS",
19
+ "screenshots": []
20
+ },
21
+ {
22
+ "stepNumber": 2,
23
+ "timestamp": "2025-06-22T22:39:35.383Z",
24
+ "description": "Test execution failed",
25
+ "toolName": null,
26
+ "toolArgs": null,
27
+ "result": "The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).",
28
+ "status": "FAILED",
29
+ "screenshots": []
30
+ }
31
+ ],
32
+ "toolCalls": [],
33
+ "stepCounter": 2,
34
+ "screenshotCounter": 0,
35
+ "status": "FAILED",
36
+ "finalResult": "The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).",
37
+ "duration": 13
38
+ }
@@ -480,10 +480,15 @@ Current Task: ${taskDescription}`;
480
480
  }
481
481
 
482
482
  async runSingleTest(test) {
483
- console.log(`\nšŸš€ Starting test: ${test.id} - ${test.name}`);
484
- console.log(`šŸ“ Description: ${test.description}`);
485
- console.log(`šŸŽÆ Priority: ${test.priority}`);
486
- console.log(`šŸ·ļø Tags: ${test.tags ? test.tags.join(', ') : 'None'}`);
483
+ // Only show detailed logs if not using console reporter (for backwards compatibility)
484
+ const useDetailedLogs = !process.env.ENDORPHIN_CONSOLE_REPORTER;
485
+
486
+ if (useDetailedLogs) {
487
+ console.log(`\nšŸš€ Starting test: ${test.id} - ${test.name}`);
488
+ console.log(`šŸ“ Description: ${test.description}`);
489
+ console.log(`šŸŽÆ Priority: ${test.priority}`);
490
+ console.log(`šŸ·ļø Tags: ${test.tags ? test.tags.join(', ') : 'None'}`);
491
+ }
487
492
 
488
493
  // Create test session with detailed tracking
489
494
  this.createTestSession(test.name, test.id);
@@ -516,11 +521,15 @@ Current Task: ${taskDescription}`;
516
521
  // Finish the test session
517
522
  const session = await this.finishTestSession('SUCCESS', 'Test completed successfully');
518
523
 
519
- console.log(`āœ… Test ${test.id} completed successfully!`);
524
+ if (useDetailedLogs) {
525
+ console.log(`āœ… Test ${test.id} completed successfully!`);
526
+ }
520
527
  return { success: true, session };
521
528
 
522
529
  } catch (error) {
523
- console.error(`āŒ Test ${test.id} failed:`, error.message);
530
+ if (useDetailedLogs) {
531
+ console.error(`āŒ Test ${test.id} failed:`, error.message);
532
+ }
524
533
 
525
534
  this.logTestStep('Test execution failed', null, null, error.message, false);
526
535
  const session = await this.finishTestSession('FAILED', error.message);