1 require 'integration_helper'
2 require 'selenium-webdriver'
5 class ErrorsTest < ActionDispatch::IntegrationTest
7 headless = Headless.new
9 Capybara.current_driver = :selenium
12 BAD_UUID = "ffffffffffffffffffffffffffffffff+0"
14 test "error page renders user navigation" do
15 visit(page_with_token("active", "/collections/#{BAD_UUID}"))
16 assert(page.has_text?(api_fixture("users")["active"]["email"]),
17 "User information missing from error page")
18 assert(page.has_no_text?(/log ?in/i),
19 "Logged in user prompted to log in on error page")
22 test "no user navigation with expired token" do
23 visit(page_with_token("expired", "/collections/#{BAD_UUID}"))
24 assert(page.has_no_text?(api_fixture("users")["active"]["email"]),
25 "Page visited with expired token included user information")
26 assert(page.has_selector?("a", text: /log ?in/i),
27 "Login prompt missing on expired token error page")
30 test "error page renders without login" do
31 visit "/collections/download/#{BAD_UUID}/#{@@API_AUTHS['active']['api_token']}"
32 assert(page.has_no_text?(/\b500\b/),
33 "Error page without login returned 500")
36 test "'object not found' page includes search link" do
37 visit(page_with_token("active", "/collections/#{BAD_UUID}"))
38 assert(all("a").any? { |a| a[:href] =~ %r{/collections/?(\?|$)} },
39 "no search link found on 404 page")
46 def page_has_error_token?(start_stamp)
47 matching_stamps = (start_stamp .. now_timestamp).to_a.join("|")
48 # Check the page HTML because we really don't care how it's presented.
49 # I think it would even be reasonable to put it in a comment.
50 page.html =~ /\b(#{matching_stamps})\+[0-9A-Fa-f]{8}\b/
53 # We use API tokens with limited scopes as the quickest way to get the API
54 # server to return an error. If Workbench gets smarter about coping when
55 # it has a too-limited token, these tests will need to be adjusted.
56 test "API error page includes error token" do
57 start_stamp = now_timestamp
58 visit(page_with_token("active_readonly", "/authorized_keys"))
59 click_on "Add a new authorized key"
60 assert(page.has_text?(/fiddlesticks/i),
61 "Not on an error page after making an SSH key out of scope")
62 assert(page_has_error_token?(start_stamp), "no error token on 404 page")
65 test "showing a bad UUID returns 404" do
66 visit(page_with_token("active", "/pipeline_templates/zzz"))
67 assert(page.has_no_text?(/fiddlesticks/i),
68 "trying to show a bad UUID rendered a fiddlesticks page, not 404")
71 test "404 page includes information about missing object" do
72 visit(page_with_token("active", "/groups/zazazaz"))
73 assert(page.has_text?(/group with UUID zazazaz/i),
74 "name of searched group missing from 404 page")
77 test "unrouted 404 page works" do
78 visit(page_with_token("active", "/__asdf/ghjk/zxcv"))
79 assert(page.has_text?(/not found/i),
80 "unrouted page missing 404 text")
81 assert(page.has_no_text?(/fiddlesticks/i),
82 "unrouted request returned a generic error page, not 404")
85 test "API error page has Report problem button" do
86 visit page_with_token("active")
88 original_arvados_v1_base = Rails.configuration.arvados_v1_base
91 # point to a bad api server url to generate fiddlesticks error
92 Rails.configuration.arvados_v1_base = "https://[100::f]:1/"
94 visit page_with_token("active")
96 assert(page.has_text?(/fiddlesticks/i), 'Expected to be in error page')
98 # reset api server base config to let the popup rendering to work
99 Rails.configuration.arvados_v1_base = original_arvados_v1_base
101 # check the "Report problem" button
102 assert page.has_link? 'Report problem', 'Report problem link not found'
104 click_link 'Report problem'
105 within '.modal-content' do
106 assert page.has_text?('Report a problem'), 'Report a problem text not found'
107 assert page.has_no_text?('Version / debugging info'), 'Version / debugging info is not expected'
108 assert page.has_text?('API version'), 'API version text not found'
109 assert page.has_text?('API startup time'), 'API startup time text not found'
110 assert page.has_text?('Found a problem?'), 'Found a problem text not found'
111 assert page.has_button?('Send problem report'), 'Send problem report button not found'
112 assert page.has_button?('Cancel'), 'Cancel button not found'
114 # enter a report text and click on report
115 page.find_field('report_issue_text').set 'my test report text'
116 click_button 'Send problem report'
118 # ajax success updated button texts and added footer message
119 assert page.has_no_button?('Send problem report'), 'Found button - Send problem report'
120 assert page.has_no_button?('Cancel'), 'Found button - Cancel'
121 assert page.has_text?('Report sent'), 'No text - Report sent'
122 assert page.has_button?('Close'), 'No button - Close'
123 assert page.has_text?('Thanks for reporting this issue'), 'No text - Thanks for reporting this issue'
128 # out of the popup now and should be back in the error page
129 assert(page.has_text?('Dashboard'), 'Expected to see dashboard')
131 Rails.configuration.arvados_v1_base = original_arvados_v1_base