lookbook_visual_tester 0.1.3 → 0.1.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc6d36810c9ef2a567bcf6fd89685b3d2cc6cf70ef73151d0fc7cf2a284f0d65
|
4
|
+
data.tar.gz: e16804e522edb44ac1751317b21e9fcf8ed92665bf88f02318f3f816b32aa46f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41d15e7bff1c2d1634a0adddb580b5aa97bb0b869ee8ce91e1b71d6b751addfd00d5349a458a41c7c023487ea6a4a5ffde4129c57a284a3f4af35b30e2cf9cb2
|
7
|
+
data.tar.gz: c8f00b84c80303323689404c89cea2b2f6dabf94ac501eae16278ef51484206bf5007b9b18c55394a3d52b6fef4fb7c9047a8c562430f836887da9787eddd325
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
## [0.1.
|
3
|
+
## [0.1.4] - 2025-02-20
|
4
|
+
### Added
|
5
|
+
- Extracted `n_threads` configuration for improved concurrency.
|
6
|
+
- Introduced `save_to_clipboard` functionality.
|
7
|
+
- Extracted configuration and scenario run logic into separate classes.
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
- Migrated to **Concurrent Ruby** for better parallel execution.
|
11
|
+
- Refactored `report_generator`, `screenshot_taker`, and `session_manager`.
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
- Minor fixes in `report_generator` and `tasks`.
|
15
|
+
|
16
|
+
---
|
4
17
|
|
5
|
-
-
|
18
|
+
## [0.1.1] - 2024-12-18
|
19
|
+
### Added
|
20
|
+
- Instructions added to the README.
|
21
|
+
- Initial version bump to `0.1.1`.
|
22
|
+
|
23
|
+
---
|
24
|
+
|
25
|
+
## [0.1.0] - 2024-12-18
|
26
|
+
### Added
|
27
|
+
- Initial working version.
|
28
|
+
- Set up **Capybara**, **Railtie**, and core functionalities.
|
29
|
+
- Added basic documentation and CI/CD setup.
|
data/README.md
CHANGED
@@ -30,6 +30,14 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
30
30
|
|
31
31
|
Bug reports and pull requests are welcome on GitHub at https://github.com/muriloime/lookbook_visual_tester. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/lookbook_visual_tester/blob/main/CODE_OF_CONDUCT.md).
|
32
32
|
|
33
|
+
|
34
|
+
## Deployment
|
35
|
+
|
36
|
+
`git log --pretty=format:"%h %ad | %s [%an]" --date=short --no-merges --name-only | xclip -selection clipboard`
|
37
|
+
|
38
|
+
Update changelog
|
39
|
+
`rake realease`
|
40
|
+
|
33
41
|
## Code of Conduct
|
34
42
|
|
35
43
|
Everyone interacting in the LookbookVisualTester project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lookbook_visual_tester/blob/main/CODE_OF_CONDUCT.md).
|
@@ -1,11 +1,19 @@
|
|
1
1
|
# lib/lookbook_visual_tester/railtie.rb
|
2
2
|
|
3
3
|
require "lookbook_visual_tester/capybara_setup"
|
4
|
+
require "lookbook_visual_tester/update_previews"
|
4
5
|
|
5
6
|
module LookbookVisualTester
|
6
7
|
class Railtie < ::Rails::Railtie
|
7
8
|
rake_tasks do
|
8
9
|
load "tasks/lookbook_visual_tester.rake"
|
9
10
|
end
|
11
|
+
|
12
|
+
initializer "LookbookVisualTester.lookbook_after_change" do |app1|
|
13
|
+
puts " >>>>> lookbook_after_change initialized: #{app1.inspect}"
|
14
|
+
Lookbook.after_change do |app, changes|
|
15
|
+
LookbookVisualTester::UpdatePreviews.call(app, changes)
|
16
|
+
end
|
17
|
+
end
|
10
18
|
end
|
11
19
|
end
|
@@ -6,7 +6,7 @@ module LookbookVisualTester
|
|
6
6
|
class ScreenshotTaker
|
7
7
|
attr_reader :session, :logger
|
8
8
|
|
9
|
-
CLIPBOARD =
|
9
|
+
CLIPBOARD = "clipboard"
|
10
10
|
|
11
11
|
def initialize(logger: Kernel)
|
12
12
|
Capybara.register_driver :cuprite do |app|
|
@@ -25,7 +25,7 @@ module LookbookVisualTester
|
|
25
25
|
@logger = logger
|
26
26
|
end
|
27
27
|
|
28
|
-
def capture(preview_url, path = CLIPBOARD)
|
28
|
+
def capture(preview_url, path = CLIPBOARD, crop: true)
|
29
29
|
FileUtils.mkdir_p(File.dirname(path))
|
30
30
|
|
31
31
|
session.visit(preview_url)
|
@@ -33,30 +33,41 @@ module LookbookVisualTester
|
|
33
33
|
# Wait for network requests to complete
|
34
34
|
# session.driver.network_idle?
|
35
35
|
|
36
|
-
#
|
37
|
-
|
36
|
+
# # Wait for any loading indicators to disappear
|
37
|
+
# begin
|
38
|
+
# session.has_no_css?(".loading", wait: 10)
|
39
|
+
# rescue StandardError
|
40
|
+
# nil
|
41
|
+
# end
|
38
42
|
if path == CLIPBOARD
|
39
|
-
save_to_clipboard
|
43
|
+
save_to_clipboard(crop: crop)
|
40
44
|
else
|
41
|
-
|
45
|
+
save_printscreen(path: path, crop: crop)
|
42
46
|
end
|
47
|
+
# Additional wait for any JavaScript animations
|
48
|
+
sleep 1
|
43
49
|
rescue StandardError => e
|
44
50
|
logger.puts "Error capturing screenshot for #{preview_url}: #{e.message}"
|
45
51
|
raise e
|
46
52
|
end
|
47
53
|
|
48
54
|
private
|
49
|
-
|
50
|
-
|
51
|
-
|
55
|
+
|
56
|
+
def save_to_clipboard(crop: false)
|
57
|
+
Tempfile.create(["screenshot", ".png"]) do |file|
|
58
|
+
session.save_screenshot(file.path, crop: crop)
|
52
59
|
|
53
60
|
# Example: Copy to clipboard (Linux xclip)
|
54
61
|
system("xclip -selection clipboard -t image/png -i #{file.path}")
|
55
62
|
end
|
56
63
|
end
|
57
64
|
|
58
|
-
def
|
65
|
+
def save_printscreen(path: nil, crop: false)
|
59
66
|
session.save_screenshot(path)
|
67
|
+
|
68
|
+
# remove white space
|
69
|
+
system("convert #{path} -trim -bordercolor white -border 10x10 #{path}") if crop
|
70
|
+
|
60
71
|
logger.puts " Screenshot saved to #{path}"
|
61
72
|
end
|
62
73
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module LookbookVisualTester
|
2
|
+
class UpdatePreviews
|
3
|
+
def self.call(...)
|
4
|
+
new(...).call
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_reader :app, :changes
|
8
|
+
|
9
|
+
def initialize(app, changes)
|
10
|
+
@app = app
|
11
|
+
@changes = changes[:modified]
|
12
|
+
@changes_hash = changes
|
13
|
+
end
|
14
|
+
|
15
|
+
def update_app_data
|
16
|
+
app.data.last_changed_files = changes.presence || []
|
17
|
+
app.data.last_changed_previews = previews
|
18
|
+
end
|
19
|
+
|
20
|
+
def call
|
21
|
+
Rails.logger.info "LookbookVisualTester: Processing changes for #{should_process?} #{selected_changes.inspect}, #{changes.inspect}"
|
22
|
+
return unless should_process?
|
23
|
+
|
24
|
+
process_changes
|
25
|
+
rescue StandardError => e
|
26
|
+
Rails.logger.error "LookbookVisualTester: Error processing changes: #{e.message}"
|
27
|
+
Rails.logger.error e.backtrace.join("\n")
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def selected_changes
|
33
|
+
@selected_changes ||= changes.select { |change| process_change?(change) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def process_change?(change)
|
37
|
+
change.to_s.downcase.include?("preview.rb") || change.to_s.downcase.match?(/component\.(html|haml|rb|erb)/)
|
38
|
+
end
|
39
|
+
|
40
|
+
def should_process?
|
41
|
+
return false if changes.nil? || changes.empty?
|
42
|
+
|
43
|
+
selected_changes.any?
|
44
|
+
end
|
45
|
+
|
46
|
+
def clean_file_name(file)
|
47
|
+
file.split("/")[-1].split(".")[0]
|
48
|
+
end
|
49
|
+
|
50
|
+
def previews
|
51
|
+
@previews ||= Lookbook.previews.select do |preview|
|
52
|
+
selected_changes.any? { |file| preview.file_path.to_s.include?(clean_file_name(file)) }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def process_changes
|
57
|
+
Rails.logger.info "LookbookVisualTester: previws #{previews.count}"
|
58
|
+
previews.each do |preview|
|
59
|
+
Rails.logger.info "LookbookVisualTester: entering #{preview.inspect}"
|
60
|
+
|
61
|
+
preview.scenarios.each do |scenario|
|
62
|
+
scenario_run = LookbookVisualTester::ScenarioRun.new(scenario)
|
63
|
+
Rails.logger.info "LookbookVisualTester: Processing scenario #{scenario_run.inspect}"
|
64
|
+
LookbookVisualTester::ScreenshotTaker.new.capture(scenario_run.preview_url, scenario_run.current_path)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lookbook_visual_tester
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Murilo Vasconcelos
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- lib/lookbook_visual_tester/scenario_run.rb
|
174
174
|
- lib/lookbook_visual_tester/screenshot_taker.rb
|
175
175
|
- lib/lookbook_visual_tester/session_manager.rb
|
176
|
+
- lib/lookbook_visual_tester/update_previews.rb
|
176
177
|
- lib/lookbook_visual_tester/version.rb
|
177
178
|
- lib/tasks/lookbook_visual_tester.rake
|
178
179
|
- sig/lookbook_visual_tester.rbs
|