Skip to content

Commit

Permalink
screenshots in system tests (#5868)
Browse files Browse the repository at this point in the history
* screenshots in system tests

* more screenshots

* Google::Cloud::Storage.anonymous

* Update Dangerfile

* Update docker-compose-testing.yml

* HAS_JOSH_K_SEAL_OF_APPROVAL

* change fail to warn in danger junit parsing

so if all tests pass, we don't worry
  • Loading branch information
jywarren authored and sagarpreet-chadha committed Jun 29, 2019
1 parent 84a306c commit afc29e8
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 7 deletions.
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ install:
- docker-compose exec web bash -c "rake db:setup"
- docker-compose exec web bash -c "rake db:migrate"
- docker-compose exec web bash -c "rake assets:precompile"
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then gem install danger danger-junit; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash -c "docker-compose exec web gem install danger danger-junit google-cloud-storage"; fi'

script:
- docker-compose exec web bash -c 'echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" > /tmp/credentials.json' # needs to be a path to a json file, so we shuffle...
- docker-compose exec web bash -c "CI=TRUE GENERATE_REPORT=true $TASK"
- |
if [ $TASK != "rake test:all" ]; then
- if [ $TASK != "rake test:all" ]; then
echo -e '<?xml version="1.0" encoding="UTF-8"?>' > output.xml;
tail -n +2 -q ./test/reports/TEST*.xml >> output.xml;
fi
- |
if [ $TRAVIS_PULL_REQUEST != "false"; then
danger --verbose;
- if [ $TRAVIS_PULL_REQUEST != "false" ]; then
docker-compose exec web danger --verbose;
fi
17 changes: 16 additions & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ begin
end

rescue => ex
fail "There was an error with Danger bot's Junit parsing: #{ex.message}"
warn "There was an error with Danger bot's Junit parsing: #{ex.message}"
message ex.inspect # view the entire error output in the log
end

# Store screenshots in Google Cloud
require "google/cloud/storage"
storage = Google::Cloud::Storage.anonymous # don't rely on a key credential
bucket = storage.bucket "plots2-screenshots"
Encoding.default_external = 'UTF-8'

images = []
Dir.glob('tmp/screenshots/*') do |item|
file = bucket.create_file item, github.pr_json["number"].to_s + "-" + item.split('/').last
images << "<h3>#{file.name}</h3><p><img src='#{file.public_url}' /></p>"
end

screenshots = "<details><summary>Screenshots :camera_flash: (click to expand)</summary>" + images.join + "</details>"
markdown(screenshots)
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gem 'gemoji'
gem 'geocoder'
gem 'geokit-rails'
gem 'georuby', '2.0'
gem "google-cloud-storage"
gem 'grape'
gem 'grape-entity'
gem 'grape-swagger', '~> 0.32.1'
Expand Down
14 changes: 14 additions & 0 deletions containers/docker-compose-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ services:
- RAILS_ENV=${RAILS_ENV}
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
- REDIS_URL=redis://redis:6379/0
- DANGER_GITHUB_API_TOKEN=${DANGER_GITHUB_API_TOKEN}
- TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST}
- TRAVIS_REPO_SLUG=${TRAVIS_REPO_SLUG}
- CI=${CI}
- TRAVIS=${TRAVIS}
- CONTINUOUS_INTEGRATION=${CONTINUOUS_INTEGRATION}
# used to tell if we are in a Travis environment:
- HAS_JOSH_K_SEAL_OF_APPROVAL=${HAS_JOSH_K_SEAL_OF_APPROVAL}
- GITHUB_ACTION=${GITHUB_ACTION}
- GITHUB_TOKEN=${GITHUB_TOKEN}
- GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
- GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH}
- GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME}
- QT_QPA_PLATFORM=${QT_QPA_PLATFORM}
links:
- redis
volumes:
Expand Down
32 changes: 32 additions & 0 deletions test/system/screenshots_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "application_system_test_case"

class ScreenshotsTest < ApplicationSystemTestCase
Capybara.default_max_wait_time = 60

test 'front page with navbar search autocomplete' do
visit '/'
fill_in("searchform_input", with: "Canon")
assert_selector ".typeahead li", text: "Canon A1200 IR conversion at PLOTS Barnraising at LUMCON"
take_screenshot
end

test 'wiki' do
visit '/wiki'
take_screenshot
end

test 'tags' do
visit '/tags'
take_screenshot
end

test 'blog' do
visit '/blog'
take_screenshot
end

test 'people' do
visit '/people'
take_screenshot
end
end

0 comments on commit afc29e8

Please sign in to comment.