8000 Add support to generate screenshots for documentation in specs by mtancoigne · Pull Request #3981 · manyfold3d/manyfold · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support to generate screenshots for documentation in specs #3981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require:

plugins:
- rubocop-performance
- rubocop-capybara
- rubocop-rails
- rubocop-rspec
- rubocop-rspec_rails
Expand Down Expand Up @@ -35,3 +36,6 @@ RSpec/NestedGroups:
Max: 5
RSpec/MultipleMemoizedHelpers:
Max: 6
RSpec/NoExpectationExample:
Exclude:
- spec/system/documentation_screenshots_spec.rb
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,20 @@ group :development, :test do
gem "rubocop-rspec", require: false
gem "rubocop-rspec_rails", require: false
gem "rubocop-factory_bot", require: false
gem "rubocop-capybara", require: false
gem "rubocop-i18n", require: false
gem "rubocop-performance", "~> 1.23", require: false
gem "rubocop-pundit", github: "manyfold3d/rubocop-pundit", require: false
gem "rubyzip", "~> 2.4"
gem "i18n-tasks", "~> 1.0"
gem "simplecov", "~> 0.22.0", require: false
gem "with_model", "~> 2.2"

# system tests and custom screenshots
gem "capybara"
gem "capybara-screenshot", github: "el-cms/capybara-screenshot", branch: "custom-prefixes"
gem "image_processing"
gem "selenium-webdriver"
end

group :development do
Expand Down
43 changes: 43 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
GIT
remote: https://github.com/el-cms/capybara-screenshot.git
revision: 866841fa662cbe54043cc254be2d76e6511895da
branch: custom-prefixes
specs:
capybara-screenshot (1.0.26)
capybara (>= 1.0, < 4)
launchy

GIT
remote: https://github.com/manyfold3d/rubocop-pundit.git
revision: 10ac81bbec63a9abd3d58be84dc47d9c490b29c6
Expand Down Expand Up @@ -182,6 +191,15 @@ GEM
byebug (12.0.0)
caber (0.4.0)
rails (>= 7.1.4)
capybara (3.40.0)
addressable
matrix
mini_mime (>= 0.1.3)
nokogiri (~> 1.11)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
chunky_png (1.4.0)
climate_control (1.2.0)
cocooned (2.4.1)
Expand Down Expand Up @@ -348,6 +366,9 @@ GEM
terminal-table (>= 1.5.1)
i18n_data (1.1.0)
simple_po_parser (~> 1.1)
image_processing (1.13.0)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
inherited_resources (1.14.0)
actionpack (>= 6.0)
has_scope (>= 0.6)
Expand Down Expand Up @@ -438,8 +459,10 @@ GEM
net-pop
net-smtp
marcel (1.0.4)
matrix (0.4.2)
memoist (0.16.2)
method_source (1.1.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
mini_portile2 (2.8.8)
minitest (5.25.5)
Expand Down Expand Up @@ -691,6 +714,9 @@ GEM
rubocop-ast (1.44.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-capybara (2.22.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-factory_bot (2.27.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
Expand All @@ -715,11 +741,20 @@ GEM
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec (~> 3.5)
ruby-progressbar (1.13.0)
ruby-vips (2.2.2)
ffi (~> 1.12)
logger
ruby2_keywords (0.0.5)
rubyzip (2.4.1)
scout_apm (5.6.2)
parser
securerandom (0.4.1)
selenium-webdriver (4.28.0)
base64 (~> 0.2)
logger (~> 1.4)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
shellany (0.0.1)
shrine (3.6.0)
content_disposition (~> 1.0)
Expand Down Expand Up @@ -830,12 +865,15 @@ GEM
faraday (~> 2.0)
faraday-follow_redirects
webrick (1.9.1)
websocket (1.2.11)
websocket-driver (0.7.7)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
with_model (2.2.0)
activerecord (>= 7.0)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.7.2)
zxcvbn (0.1.10)

Expand All @@ -860,6 +898,8 @@ DEPENDENCIES
bullet (~> 8.0)
byebug
caber
capybara
capybara-screenshot!
climate_control (~> 1.2)
cocooned (~> 2.4)
cssbundling-rails (~> 1.4)
Expand All @@ -882,6 +922,7 @@ DEPENDENCIES
i18n-js (~> 4.2)
i18n-tasks (~> 1.0)
i18n_data (~> 1.1.0)
image_processing
jbuilder (~> 2.13)
job-iteration (~> 1.10)
jsbundling-rails
Expand Down Expand Up @@ -920,6 +961,7 @@ DEPENDENCIES
rolify (~> 6.0)
rspec-rails
rswag (~> 2.16)
rubocop-capybara
rubocop-factory_bot
rubocop-i18n
rubocop-performance (~> 1.23)
Expand All @@ -929,6 +971,7 @@ DEPENDENCIES
rubocop-rspec_rails
rubyzip (~> 2.4)
scout_apm
selenium-webdriver
shrine (~> 3.6)
shrine-tus (~> 2.1)
sidekiq (~> 7.3)
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ You can run the test suite as a one off with the command `bundle exec rake`, or

Tests are run automatically when pushed to our repository using GitHub Actions.

Generation of screenshots for the documentation is made with system specs and is not run by default.
To generate screenshots, set `DOC_SCREENSHOT=true`:

```sh
# All specs and documentation
DOC_SCREENSHOT=true bundle exec rspec
# Only documentation specs
DOC_SCREENSHOT=true bundle exec rspec -t @documentation
```


### Internationalisation & Translation

Manyfold uses [Rails' I18n framework](https://guides.rubyonrails.org/i18n.html) to handle all text content.
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def img_src
end

def configure_content_security_policy
return if Rails.env.test?

# Standard security policy
content_security_policy.default_src :self
content_security_policy.connect_src :self
Expand All @@ -94,7 +96,7 @@ def configure_content_security_policy
content_security_policy.style_src :self
content_security_policy.style_src_attr :unsafe_inline
content_security_policy.style_src_elem :self, "https://fonts.googleapis.com"
# Add libary origins
# Add library origins
origins = Library.all.filter_map(&:storage_origin) # rubocop:disable Pundit/UsePolicyScope
content_security_policy.img_src(*origins)
content_security_policy.connect_src(*origins)
Expand Down
6 changes: 6 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
require "rake"
Rails.application.load_tasks

Capybara::Screenshot.prune_strategy = :keep_last_run

Rails.root.glob("spec/support/**/*.rb").sort.each { |f| require f }

# Checks for pending migrations and applies them before tests are run.
Expand Down Expand Up @@ -62,6 +64,10 @@
config.filter_run_excluding case_sensitive: true
end
end

config.filter_run_excluding :documentation unless ENV.fetch("DOC_SCREENSHOT", false) === "true"

config.include ScreenshotHelpers, type: :system
end

# Copy parsers into integration tests - this doesn't happen automatically for some reason
Expand Down
Loading
Loading
0