capydash 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +39 -245
- data/lib/capydash/instrumentation.rb +21 -2
- data/lib/capydash/test_data_collector.rb +76 -0
- data/lib/capydash/version.rb +1 -1
- data/lib/capydash.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72ac597d4f4b57d15d412dcdfa56e2cba5600a045e62278d44a082c9ca2e6eff
|
4
|
+
data.tar.gz: c0fb3be58f53129bc4f048f6ea591f1250ef0cc03ca6d004322d86848002b953
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 634aabfc97331a3d68d452ac8806bb4a6b979549791c18344725bfdf5ed0bfbee41e27b39afb050d56b87dc6bff06e7b8790afcb231a877acd46fa9e487a2ae3
|
7
|
+
data.tar.gz: 9eddf128a30f7317483eeddc385c1170ec7a14701e0f077100d06e72dcdf63aea188b440483fac9c75502408aad64e2b284f103353693c8f7e09972f1bb5b4e0
|
data/README.md
CHANGED
@@ -1,286 +1,80 @@
|
|
1
1
|
# CapyDash
|
2
2
|
|
3
|
-
A
|
3
|
+
A live dashboard for Capybara tests that provides real-time visualization of test execution with screenshots, step-by-step tracking, comprehensive error reporting, and search capabilities. Perfect for debugging test failures and understanding test behavior.
|
4
4
|
|
5
|
-
##
|
6
|
-
|
7
|
-
- **Real-time Test Monitoring**: Watch tests execute live with WebSocket updates
|
8
|
-
- **Visual Test Flow**: See each test step with screenshots and detailed information
|
9
|
-
- **Hierarchical Organization**: Test classes → methods → individual steps
|
10
|
-
- **Screenshot Capture**: Automatic screenshots at each test step
|
11
|
-
- **Error Tracking**: Comprehensive error reporting and logging
|
12
|
-
- **Configurable**: YAML-based configuration system
|
13
|
-
- **Production Ready**: Built-in logging, error handling, and persistence
|
14
|
-
|
15
|
-
## Quick Start
|
16
|
-
|
17
|
-
### 1. Installation
|
18
|
-
|
19
|
-
#### Option A: Install from RubyGems (Recommended)
|
5
|
+
## Installation
|
20
6
|
|
21
7
|
Add to your Gemfile:
|
22
8
|
|
23
9
|
```ruby
|
24
|
-
gem
|
10
|
+
gem "capydash"
|
25
11
|
```
|
26
12
|
|
27
|
-
|
13
|
+
Or run:
|
28
14
|
|
29
15
|
```bash
|
30
|
-
bundle
|
31
|
-
```
|
32
|
-
|
33
|
-
#### Option B: Install from source
|
34
|
-
|
35
|
-
```bash
|
36
|
-
git clone https://github.com/damonclark/capydash.git
|
37
|
-
cd capydash
|
38
|
-
bundle install
|
39
|
-
```
|
40
|
-
|
41
|
-
#### Option C: Local development
|
42
|
-
|
43
|
-
For local development, add to your Gemfile:
|
44
|
-
|
45
|
-
```ruby
|
46
|
-
gem 'capydash', path: '/path/to/capydash'
|
47
|
-
```
|
48
|
-
|
49
|
-
### 2. Configuration
|
50
|
-
|
51
|
-
Create a configuration file at `config/capydash.yml`:
|
52
|
-
|
53
|
-
```yaml
|
54
|
-
# CapyDash Configuration
|
55
|
-
server:
|
56
|
-
host: "localhost"
|
57
|
-
port: 4000
|
58
|
-
max_connections: 100
|
59
|
-
|
60
|
-
dashboard:
|
61
|
-
title: "My Test Dashboard"
|
62
|
-
auto_scroll: true
|
63
|
-
show_timestamps: true
|
64
|
-
|
65
|
-
tests:
|
66
|
-
system_tests_dir: "test/system"
|
67
|
-
feature_tests_dir: "test/features"
|
68
|
-
screenshot_dir: "tmp/capydash_screenshots"
|
69
|
-
|
70
|
-
logging:
|
71
|
-
level: "info"
|
72
|
-
file: "log/capydash.log"
|
73
|
-
|
74
|
-
security:
|
75
|
-
enable_auth: false
|
76
|
-
secret_key: "your-secret-key-here"
|
77
|
-
```
|
78
|
-
|
79
|
-
### 3. Setup in Rails
|
80
|
-
|
81
|
-
Add to your `test/test_helper.rb`:
|
82
|
-
|
83
|
-
```ruby
|
84
|
-
require 'capydash'
|
85
|
-
|
86
|
-
# CapyDash will automatically instrument your tests
|
87
|
-
```
|
88
|
-
|
89
|
-
### 4. Running Tests
|
90
|
-
|
91
|
-
#### Option A: Standalone Server (Recommended)
|
92
|
-
|
93
|
-
```bash
|
94
|
-
# Terminal 1: Start the dashboard server
|
95
|
-
bundle exec rake capydash:server
|
96
|
-
|
97
|
-
# Terminal 2: Run tests with external WebSocket
|
98
|
-
CAPYDASH_EXTERNAL_WS=1 bundle exec rails test
|
99
|
-
```
|
100
|
-
|
101
|
-
#### Option B: In-Process Server (Development)
|
102
|
-
|
103
|
-
```bash
|
104
|
-
# Just run your tests - CapyDash starts automatically
|
105
|
-
bundle exec rails test
|
106
|
-
```
|
107
|
-
|
108
|
-
### 5. View Dashboard
|
109
|
-
|
110
|
-
Open your browser to `http://localhost:4000` to see the live test dashboard.
|
111
|
-
|
112
|
-
## Configuration Options
|
113
|
-
|
114
|
-
### Server Configuration
|
115
|
-
|
116
|
-
```yaml
|
117
|
-
server:
|
118
|
-
host: "localhost" # Server host
|
119
|
-
port: 4000 # Server port
|
120
|
-
websocket_path: "/websocket" # WebSocket endpoint
|
121
|
-
max_connections: 100 # Max concurrent connections
|
122
|
-
message_history_limit: 1000 # Max messages to keep in memory
|
123
|
-
```
|
124
|
-
|
125
|
-
### Dashboard Configuration
|
126
|
-
|
127
|
-
```yaml
|
128
|
-
dashboard:
|
129
|
-
title: "CapyDash Test Monitor" # Dashboard title
|
130
|
-
refresh_interval: 1000 # UI refresh rate (ms)
|
131
|
-
auto_scroll: true # Auto-scroll to latest step
|
132
|
-
show_timestamps: true # Show timestamps in UI
|
133
|
-
screenshot_quality: 0.8 # Screenshot compression (0.0-1.0)
|
134
|
-
max_screenshot_width: 1200 # Max screenshot width (px)
|
135
|
-
```
|
136
|
-
|
137
|
-
### Test Configuration
|
138
|
-
|
139
|
-
```yaml
|
140
|
-
tests:
|
141
|
-
default_directory: "test" # Default test directory
|
142
|
-
system_tests_dir: "test/system" # System tests directory
|
143
|
-
feature_tests_dir: "test/features" # Feature tests directory
|
144
|
-
controller_tests_dir: "test/controllers" # Controller tests directory
|
145
|
-
model_tests_dir: "test/models" # Model tests directory
|
146
|
-
screenshot_dir: "tmp/capydash_screenshots" # Screenshot storage
|
147
|
-
timeout: 300 # Test timeout (seconds)
|
148
|
-
```
|
149
|
-
|
150
|
-
### Logging Configuration
|
151
|
-
|
152
|
-
```yaml
|
153
|
-
logging:
|
154
|
-
level: "info" # Log level: debug, info, warn, error
|
155
|
-
file: "log/capydash.log" # Log file path
|
156
|
-
max_file_size: "10MB" # Max log file size
|
157
|
-
max_files: 5 # Number of log files to keep
|
158
|
-
```
|
159
|
-
|
160
|
-
### Security Configuration
|
161
|
-
|
162
|
-
```yaml
|
163
|
-
security:
|
164
|
-
enable_auth: false # Enable authentication
|
165
|
-
secret_key: "your-secret-key-here" # Secret key for tokens
|
166
|
-
session_timeout: 3600 # Session timeout (seconds)
|
16
|
+
bundle add capydash
|
167
17
|
```
|
168
18
|
|
169
19
|
## Usage
|
170
20
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
1. Detects the test class name from the test method names
|
176
|
-
2. Generates the appropriate file path (e.g., `NavigationTest` → `test/system/navigation_test.rb`)
|
177
|
-
3. Executes the test with proper environment setup
|
21
|
+
1. **Start the dashboard server** in one terminal:
|
22
|
+
```bash
|
23
|
+
bundle exec rake capydash:server
|
24
|
+
```
|
178
25
|
|
179
|
-
|
26
|
+
2. **Start the frontend** in another terminal:
|
27
|
+
```bash
|
28
|
+
npx vite
|
29
|
+
```
|
180
30
|
|
181
|
-
|
31
|
+
3. **Open your browser** to `http://localhost:5173` to view the dashboard
|
182
32
|
|
183
|
-
|
33
|
+
4. **Run your tests** with external WebSocket:
|
34
|
+
```bash
|
35
|
+
CAPYDASH_EXTERNAL_WS=1 bundle exec rails test
|
36
|
+
```
|
184
37
|
|
185
|
-
|
186
|
-
- **Test Methods**: Individual test methods within each class
|
187
|
-
- **Test Steps**: Detailed step-by-step execution with screenshots
|
188
|
-
- **Status Indicators**: Visual status for each level (PASSED/FAILED/RUNNING)
|
189
|
-
- **Error Details**: Comprehensive error information for failed tests
|
38
|
+
The dashboard will show your tests running in real-time with screenshots, detailed step information, and search functionality to filter tests by name, status, or content.
|
190
39
|
|
191
40
|
## Development
|
192
41
|
|
193
|
-
###
|
194
|
-
|
195
|
-
```
|
196
|
-
lib/capydash/
|
197
|
-
├── engine.rb # Rails engine integration
|
198
|
-
├── instrumentation.rb # Capybara method instrumentation
|
199
|
-
├── dashboard_server.rb # WebSocket server
|
200
|
-
├── event_emitter.rb # Event broadcasting
|
201
|
-
├── forwarder.rb # External WebSocket forwarding
|
202
|
-
├── configuration.rb # Configuration management
|
203
|
-
├── logger.rb # Logging system
|
204
|
-
├── error_handler.rb # Error handling
|
205
|
-
├── persistence.rb # Data persistence
|
206
|
-
└── auth.rb # Authentication
|
42
|
+
### Testing with Dummy App
|
207
43
|
|
208
|
-
|
209
|
-
├── src/
|
210
|
-
│ └── App.jsx # React dashboard
|
211
|
-
└── public/ # Static assets
|
212
|
-
|
213
|
-
config/
|
214
|
-
└── capydash.yml # Configuration file
|
215
|
-
```
|
216
|
-
|
217
|
-
### Adding New Features
|
218
|
-
|
219
|
-
1. **Configuration**: Add new options to `Configuration` class
|
220
|
-
2. **Logging**: Use `CapyDash::Logger` for all logging
|
221
|
-
3. **Error Handling**: Use `CapyDash::ErrorHandler` for error management
|
222
|
-
4. **Persistence**: Use `CapyDash::Persistence` for data storage
|
223
|
-
|
224
|
-
### Testing
|
44
|
+
The project includes a dummy Rails app for testing. To run it:
|
225
45
|
|
226
46
|
```bash
|
227
|
-
# Run the dummy app tests
|
228
47
|
cd spec/dummy_app
|
48
|
+
bundle install
|
229
49
|
bundle exec rails test
|
230
|
-
|
231
|
-
# Run with CapyDash monitoring
|
232
|
-
CAPYDASH_EXTERNAL_WS=1 bundle exec rails test
|
233
|
-
```
|
234
|
-
|
235
|
-
## Troubleshooting
|
236
|
-
|
237
|
-
### Common Issues
|
238
|
-
|
239
|
-
1. **WebSocket Connection Failed**
|
240
|
-
- Check if port 4000 is available
|
241
|
-
- Verify firewall settings
|
242
|
-
- Check server logs for errors
|
243
|
-
|
244
|
-
2. **Tests Not Appearing**
|
245
|
-
- Ensure `CAPYDASH_EXTERNAL_WS=1` is set
|
246
|
-
- Check that tests are in the correct directories
|
247
|
-
- Verify test class naming conventions
|
248
|
-
|
249
|
-
3. **Screenshots Not Capturing**
|
250
|
-
- Check screenshot directory permissions
|
251
|
-
- Verify Capybara configuration
|
252
|
-
- Check available disk space
|
253
|
-
|
254
|
-
### Debug Mode
|
255
|
-
|
256
|
-
Enable debug logging:
|
257
|
-
|
258
|
-
```yaml
|
259
|
-
logging:
|
260
|
-
level: "debug"
|
261
50
|
```
|
262
51
|
|
263
|
-
###
|
52
|
+
### Development Setup
|
264
53
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
54
|
+
1. Clone the repository
|
55
|
+
2. Install dependencies: `bundle install`
|
56
|
+
3. Run the dummy app tests to verify everything works
|
57
|
+
4. Make your changes
|
58
|
+
5. Test with the dummy app
|
269
59
|
|
270
60
|
## Contributing
|
271
61
|
|
272
62
|
1. Fork the repository
|
273
63
|
2. Create a feature branch
|
274
64
|
3. Make your changes
|
275
|
-
4.
|
65
|
+
4. Test with the dummy app
|
276
66
|
5. Submit a pull request
|
277
67
|
|
278
|
-
##
|
68
|
+
## Publishing
|
279
69
|
|
280
|
-
|
70
|
+
Build the gem:
|
281
71
|
|
282
|
-
|
72
|
+
```bash
|
73
|
+
gem build capydash.gemspec
|
74
|
+
```
|
283
75
|
|
284
|
-
|
285
|
-
|
286
|
-
|
76
|
+
Push to RubyGems:
|
77
|
+
|
78
|
+
```bash
|
79
|
+
gem push capydash-0.1.0.gem
|
80
|
+
```
|
@@ -33,6 +33,9 @@ module CapyDash
|
|
33
33
|
safe_step = step_name.gsub(/\s+/, '_')
|
34
34
|
screenshot_path = File.join(base_dir, "#{safe_step}-#{timestamp}.png")
|
35
35
|
|
36
|
+
# Ensure we have an absolute path for Base64 encoding
|
37
|
+
absolute_screenshot_path = File.absolute_path(screenshot_path)
|
38
|
+
|
36
39
|
data_url = nil
|
37
40
|
if defined?(Capybara)
|
38
41
|
begin
|
@@ -47,9 +50,25 @@ module CapyDash
|
|
47
50
|
Capybara.current_session.save_screenshot(screenshot_path)
|
48
51
|
end
|
49
52
|
puts "[CapyDash] Saved screenshot: #{screenshot_path}"
|
50
|
-
|
51
|
-
|
53
|
+
|
54
|
+
# Try to find the actual screenshot file location
|
55
|
+
actual_screenshot_path = nil
|
56
|
+
if File.exist?(absolute_screenshot_path)
|
57
|
+
actual_screenshot_path = absolute_screenshot_path
|
58
|
+
else
|
59
|
+
# Check if it was saved in the capybara tmp directory
|
60
|
+
capybara_path = File.join(Dir.pwd, "tmp", "capybara", screenshot_path)
|
61
|
+
if File.exist?(capybara_path)
|
62
|
+
actual_screenshot_path = capybara_path
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if actual_screenshot_path && File.exist?(actual_screenshot_path)
|
67
|
+
encoded = Base64.strict_encode64(File.binread(actual_screenshot_path))
|
52
68
|
data_url = "data:image/png;base64,#{encoded}"
|
69
|
+
puts "[CapyDash] Generated data URL for screenshot from: #{actual_screenshot_path}"
|
70
|
+
else
|
71
|
+
puts "[CapyDash] Screenshot file not found. Tried: #{absolute_screenshot_path} and #{capybara_path rescue 'N/A'}"
|
53
72
|
end
|
54
73
|
end
|
55
74
|
rescue => e
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'capydash/event_emitter'
|
2
|
+
|
3
|
+
module CapyDash
|
4
|
+
class TestDataCollector
|
5
|
+
class << self
|
6
|
+
def start_test_run
|
7
|
+
CapyDash::Logger.info("Starting test run data collection")
|
8
|
+
@test_run_started = true
|
9
|
+
@test_count = 0
|
10
|
+
@passed_count = 0
|
11
|
+
@failed_count = 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def finish_test_run
|
15
|
+
return unless @test_run_started
|
16
|
+
|
17
|
+
CapyDash::Logger.info("Finishing test run data collection", {
|
18
|
+
total_tests: @test_count,
|
19
|
+
passed: @passed_count,
|
20
|
+
failed: @failed_count
|
21
|
+
})
|
22
|
+
|
23
|
+
@test_run_started = false
|
24
|
+
end
|
25
|
+
|
26
|
+
def start_test(test_name, test_class, test_method)
|
27
|
+
return unless @test_run_started
|
28
|
+
|
29
|
+
@test_count += 1
|
30
|
+
CapyDash::Logger.info("Starting test", {
|
31
|
+
test_name: test_name,
|
32
|
+
test_class: test_class,
|
33
|
+
test_method: test_method
|
34
|
+
})
|
35
|
+
|
36
|
+
# Emit test start event
|
37
|
+
CapyDash::EventEmitter.broadcast(
|
38
|
+
step_name: "test_start",
|
39
|
+
detail: "Starting test: #{test_name}",
|
40
|
+
test_name: test_name,
|
41
|
+
status: "running"
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def finish_test(test_name, status, error_message = nil)
|
46
|
+
return unless @test_run_started
|
47
|
+
|
48
|
+
if status == "passed"
|
49
|
+
@passed_count += 1
|
50
|
+
elsif status == "failed"
|
51
|
+
@failed_count += 1
|
52
|
+
end
|
53
|
+
|
54
|
+
CapyDash::Logger.info("Finishing test", {
|
55
|
+
test_name: test_name,
|
56
|
+
status: status,
|
57
|
+
error_message: error_message
|
58
|
+
})
|
59
|
+
|
60
|
+
# Emit test finish event
|
61
|
+
event_data = {
|
62
|
+
step_name: "test_finish",
|
63
|
+
detail: "Test #{status}: #{test_name}",
|
64
|
+
test_name: test_name,
|
65
|
+
status: status
|
66
|
+
}
|
67
|
+
|
68
|
+
if error_message
|
69
|
+
event_data[:error] = error_message
|
70
|
+
end
|
71
|
+
|
72
|
+
CapyDash::EventEmitter.broadcast(event_data)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/capydash/version.rb
CHANGED
data/lib/capydash.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capydash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damon Clark
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/capydash/instrumentation.rb
|
115
115
|
- lib/capydash/logger.rb
|
116
116
|
- lib/capydash/persistence.rb
|
117
|
+
- lib/capydash/test_data_collector.rb
|
117
118
|
- lib/capydash/version.rb
|
118
119
|
- lib/tasks/capydash.rake
|
119
120
|
homepage: https://github.com/damonclark/capydash
|