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_link?("notifications-menu"),
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_link?("notifications-menu"),
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 test "showing a bad UUID returns 404" do
50 visit(page_with_token("active", "/pipeline_templates/zzz"))
51 assert(page.has_no_text?(/fiddlesticks/i),
52 "trying to show a bad UUID rendered a fiddlesticks page, not 404")
55 test "404 page includes information about missing object" do
56 visit(page_with_token("active", "/groups/zazazaz"))
57 assert(page.has_text?(/group with UUID zazazaz/i),
58 "name of searched group missing from 404 page")
61 test "unrouted 404 page works" do
62 visit(page_with_token("active", "/__asdf/ghjk/zxcv"))
63 assert(page.has_text?(/not found/i),
64 "unrouted page missing 404 text")
65 assert(page.has_no_text?(/fiddlesticks/i),
66 "unrouted request returned a generic error page, not 404")
69 test "API error page has Report problem button" do
70 # point to a bad api server url to generate fiddlesticks error
71 original_arvados_v1_base = Rails.configuration.arvados_v1_base
72 Rails.configuration.arvados_v1_base = "https://[::1]:1/"
74 visit page_with_token("active")
76 assert_text 'fiddlesticks'
78 # reset api server base config to let the popup rendering to work
79 Rails.configuration.arvados_v1_base = original_arvados_v1_base
81 click_link 'Report problem'
83 within '.modal-content' do
84 assert_text 'Report a problem'
85 assert_no_text 'Version / debugging info'
86 assert_text 'Describe the problem'
87 assert_text 'Send problem report'
88 # "Send" button should be disabled until text is entered
89 assert_no_selector 'a,button:not([disabled])', text: 'Send problem report'
90 assert_selector 'a,button', text: 'Cancel'
93 report.expects(:deliver).returns true
94 IssueReporter.expects(:send_report).returns report
96 # enter a report text and click on report
97 find_field('report_issue_text').set 'my test report text'
98 click_button 'Send problem report'
100 # ajax success updated button texts and added footer message
101 assert_no_selector 'a,button', text: 'Send problem report'
102 assert_no_selector 'a,button', text: 'Cancel'
103 assert_text 'Report sent'
104 assert_text 'Thanks for reporting this issue'
108 # out of the popup now and should be back in the error page
109 assert_text 'fiddlesticks'