1 require 'integration_helper'
3 class ErrorsTest < ActionDispatch::IntegrationTest
8 BAD_UUID = "ffffffffffffffffffffffffffffffff+0"
10 test "error page renders user navigation" do
11 visit(page_with_token("active", "/collections/#{BAD_UUID}"))
12 assert(page.has_text?(api_fixture("users")["active"]["email"]),
13 "User information missing from error page")
14 assert(page.has_no_text?(/log ?in/i),
15 "Logged in user prompted to log in on error page")
18 test "no user navigation with expired token" do
19 visit(page_with_token("expired", "/collections/#{BAD_UUID}"))
20 assert(page.has_no_text?(api_fixture("users")["active"]["email"]),
21 "Page visited with expired token included user information")
22 assert(page.has_selector?("a", text: /log ?in/i),
23 "Login prompt missing on expired token error page")
26 test "error page renders without login" do
27 visit "/collections/download/#{BAD_UUID}/#{@@API_AUTHS['active']['api_token']}"
28 assert(page.has_no_text?(/\b500\b/),
29 "Error page without login returned 500")
32 test "'object not found' page includes search link" do
33 visit(page_with_token("active", "/collections/#{BAD_UUID}"))
34 assert(all("a").any? { |a| a[:href] =~ %r{/collections/?(\?|$)} },
35 "no search link found on 404 page")
42 def page_has_error_token?(start_stamp)
43 matching_stamps = (start_stamp .. now_timestamp).to_a.join("|")
44 # Check the page HTML because we really don't care how it's presented.
45 # I think it would even be reasonable to put it in a comment.
46 page.html =~ /\b(#{matching_stamps})\+[0-9A-Fa-f]{8}\b/
49 # We use API tokens with limited scopes as the quickest way to get the API
50 # server to return an error. If Workbench gets smarter about coping when
51 # it has a too-limited token, these tests will need to be adjusted.
52 test "API error page includes error token" do
53 start_stamp = now_timestamp
54 visit(page_with_token("active_readonly", "/authorized_keys"))
55 click_on "Add a new authorized key"
56 assert(page.has_text?(/fiddlesticks/i),
57 "Not on an error page after making an SSH key out of scope")
58 assert(page_has_error_token?(start_stamp), "no error token on 404 page")
61 test "showing a bad UUID returns 404" do
62 visit(page_with_token("active", "/pipeline_templates/zzz"))
63 assert(page.has_no_text?(/fiddlesticks/i),
64 "trying to show a bad UUID rendered a fiddlesticks page, not 404")
67 test "404 page includes information about missing object" do
68 visit(page_with_token("active", "/groups/zazazaz"))
69 assert(page.has_text?(/group with UUID zazazaz/i),
70 "name of searched group missing from 404 page")
73 test "unrouted 404 page works" do
74 visit(page_with_token("active", "/__asdf/ghjk/zxcv"))
75 assert(page.has_text?(/not found/i),
76 "unrouted page missing 404 text")
77 assert(page.has_no_text?(/fiddlesticks/i),
78 "unrouted request returned a generic error page, not 404")
81 test "API error page has Report problem button" do
82 original_arvados_v1_base = Rails.configuration.arvados_v1_base
85 # point to a bad api server url to generate fiddlesticks error
86 Rails.configuration.arvados_v1_base = "https://[100::f]:1/"
88 visit page_with_token("active")
90 assert(page.has_text?(/fiddlesticks/i), 'Expected to be in error page')
92 # reset api server base config to let the popup rendering to work
93 Rails.configuration.arvados_v1_base = original_arvados_v1_base
95 # check the "Report problem" button
96 assert page.has_link? 'Report problem', 'Report problem link not found'
98 click_link 'Report problem'
99 within '.modal-content' do
100 assert page.has_text?('Report a problem'), 'Report a problem text not found'
101 assert page.has_no_text?('Version / debugging info'), 'Version / debugging info is not expected'
102 assert page.has_text?('Describe the problem'), 'Describe the problem text not found'
103 assert page.has_text?('Send problem report'), 'Send problem report button text is not found'
104 assert page.has_no_button?('Send problem report'), 'Send problem report button is not disabled before entering problem description'
105 assert page.has_button?('Cancel'), 'Cancel button not found'
107 # enter a report text and click on report
108 page.find_field('report_issue_text').set 'my test report text'
109 assert page.has_button?('Send problem report'), 'Send problem report button not enabled after entering text'
110 click_button 'Send problem report'
112 # ajax success updated button texts and added footer message
113 assert page.has_no_text?('Send problem report'), 'Found button - Send problem report'
114 assert page.has_no_button?('Cancel'), 'Found button - Cancel'
115 assert page.has_text?('Report sent'), 'No text - Report sent'
116 assert page.has_button?('Close'), 'No button - Close'
117 assert page.has_text?('Thanks for reporting this issue'), 'No text - Thanks for reporting this issue'
122 # out of the popup now and should be back in the error page
123 assert(page.has_text?(/fiddlesticks/i), 'Expected to be in error page after closing report issue popup')
125 Rails.configuration.arvados_v1_base = original_arvados_v1_base