9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/capydash/report_generator.rb', line 9
def generate_report
test_runs = CapyDash::Persistence.list_test_runs(1)
return nil if test_runs.empty?
latest_run = test_runs.first
test_data = CapyDash::Persistence.load_test_run(latest_run[:id])
return nil unless test_data
report_dir = File.join(Dir.pwd, "capydash_report")
FileUtils.mkdir_p(report_dir)
assets_dir = File.join(report_dir, "assets")
FileUtils.mkdir_p(assets_dir)
screenshots_dir = File.join(report_dir, "screenshots")
FileUtils.mkdir_p(screenshots_dir)
copy_screenshots(test_data, screenshots_dir)
html_content = generate_html(test_data, latest_run[:created_at])
html_path = File.join(report_dir, "index.html")
File.write(html_path, html_content)
css_content = generate_css
css_path = File.join(assets_dir, "dashboard.css")
File.write(css_path, css_content)
js_content = generate_javascript
js_path = File.join(assets_dir, "dashboard.js")
File.write(js_path, js_content)
html_path
end
|