-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Take screenshots during system tests, upload to Google Cloud storage, and append to Dangerbot output #5320
Conversation
Screenshots 📸 (click to expand)5320-test_front_page_with_navbar_search_autocomplete.png5320-test_viewing_the_dashboard.pngGenerated by 🚫 Danger |
Great -- Now we just have to figure out how to use Danger to paste it into a comment, or display it inline. |
Lines 60 to 68 in 3d2b068
|
Huh, so i see:
However, later in the source code of this page, I see this dataurl which is correct! |
I messaged GitHub help desk to ask about limitations of dataurls. Unfortunately I can't think of another way around this except to abandon dataurls and store in Google cloud maybe. |
# project_id = "Your Google Cloud project ID"
# bucket_name = "Your Google Cloud Storage bucket name"
# local_file_path = "Path to local file to upload"
# storage_file_path = "Path to store the file in Google Cloud Storage"
require "google/cloud/storage"
storage = Google::Cloud::Storage.new project_id: project_id
bucket = storage.bucket bucket_name
file = bucket.create_file local_file_path, storage_file_path
puts "Uploaded #{file.name}" |
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABlBMVEX+AAD///+KQee0AAAAAWJLR0QB/wIt3gAAAAd0SU1FB+EGHRIVAvrm6EMAAAAMSURBVAjXY2AgDQAAADAAAceqhY4AAAAldEVYdGRhdGU6Y3JlYXRlADIwMTctMDYtMjlUMTg6MjE6MDIrMDI6MDDGD83DAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE3LTA2LTI5VDE4OjIxOjAyKzAyOjAwt1J1fwAAAABJRU5ErkJggg== dataurl |
test/system/screenshots_test.rb
Outdated
|
||
# apparently this will wait for ajax to complete? | ||
# also, not sure we can nest css like this: | ||
assert_select "ul.dropdown-menu li", count: 2 #, wait: 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use:
page.assert_selector('li', text: 'Horse', visible: true)
too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, seeing:
Probably need to escape keys |
Hmm, two issues -- how do we
And, we seem to be getting:
|
Although i tested these Google Cloud upload functions locally so I know they work! https://storage.googleapis.com/plots2-screenshots/test.png for example was uploaded from Ruby using the same |
I'm going to put an encoded JSON value into a dummy |
@icarito any idea how to properly require the Google cloud gem in Dangerfile? |
Tried a couple things! |
Hmm, still |
Aha, it's in: |
I dunno where that oddly encoded character is from! A typical Google Cloud Storage url might be something like: Or a public one: |
Ahhhh! I bet it's the emoji camera! !!!!! 📸 Too bad camera... not this time! |
Hmm. Well that's odd. It wasn't the emoji, i guess? |
They had the same issue here! stevekinney/pizza#103 |
require "google/cloud/storage" | ||
storage = Google::Cloud::Storage.new project_id: "public-lab" | ||
bucket = storage.bucket "plots2-screenshots" | ||
Encoding.default_external = 'UTF-8' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may need: # encoding: utf-8
as per https://stackoverflow.com/questions/20521371/set-utf-8-as-default-for-ruby-1-9-3#20523482
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encoding.default_internal = Encoding::UTF_8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ruby 2.0 and above: default string encoding is UTF-8.
Thus, if you use Ruby 2.0, you could skip the encoding comment and correctly assume UTF-8 encoding everywhere by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes maybe as a follow-up?
THIS WORKED!!!!!! I'm changing the filenames, but this should be good to merge!!!!!! |
Hmm, why isn't it finding output.xml... @alaxalves was this somehow related to the splitting of the system tests into a parallel process? Junit should generate in both, I'd think though... |
Maybe this needs a rebase? |
Made a clean squashed version of this at #5868 that is also rebased... let's see! |
This is complete!!!!! #5868 worked perfectly after some tweaks!!!! Check it out 📸 |
* add screenshots for grids Re publiclab#5320 publiclab#5868 publiclab#5316 * adjust screenshot path
* add screenshots for grids Re publiclab#5320 publiclab#5868 publiclab#5316 * adjust screenshot path
Re #5316 screenshots of tests
Also we might try:
bin/rails test:system test
to get the coverage to not run twice (we went down from 91-44% but that's because we're running tests twice and 44 is just for system tests i guess?)https://api.rubyonrails.org/classes/ActionDispatch/SystemTestCase.html
Attempting to generate inline screenshots with https://iterm2.com/documentation-images.html
But fallback could be to generate them as files, then use Dangerfile to leave them as comments, but collasped in a
<details>
el: