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 original_arvados_v1_base = Rails.configuration.arvados_v1_base
89 # point to a bad api server url to generate fiddlesticks error
90 Rails.configuration.arvados_v1_base = "https://[100::f]:1/"
92 visit page_with_token("active")
94 assert(page.has_text?(/fiddlesticks/i), 'Expected to be in error page')
96 # reset api server base config to let the popup rendering to work
97 Rails.configuration.arvados_v1_base = original_arvados_v1_base
99 # check the "Report problem" button
100 assert page.has_link? 'Report problem', 'Report problem link not found'
102 click_link 'Report problem'
103 within '.modal-content' do
104 assert page.has_text?('Report a problem'), 'Report a problem text not found'
105 assert page.has_no_text?('Version / debugging info'), 'Version / debugging info is not expected'
106 assert page.has_text?('Describe the problem'), 'Describe the problem text not found'
107 assert page.has_button?('Send problem report'), 'Send problem report button not found'
108 assert page.has_button?('Cancel'), 'Cancel button not found'
110 # enter a report text and click on report
111 page.find_field('report_issue_text').set 'my test report text'
112 click_button 'Send problem report'
114 # ajax success updated button texts and added footer message
115 assert page.has_no_button?('Send problem report'), 'Found button - Send problem report'
116 assert page.has_no_button?('Cancel'), 'Found button - Cancel'
117 assert page.has_text?('Report sent'), 'No text - Report sent'
118 assert page.has_button?('Close'), 'No button - Close'
119 assert page.has_text?('Thanks for reporting this issue'), 'No text - Thanks for reporting this issue'
124 # out of the popup now and should be back in the error page
125 assert(page.has_text?('Dashboard'), 'Expected to see dashboard')
127 Rails.configuration.arvados_v1_base = original_arvados_v1_base