1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require 'integration_helper'
7 class ErrorsTest < ActionDispatch::IntegrationTest
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_link?("notifications-menu"),
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_link?("notifications-menu"),
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 test "showing a bad UUID returns 404" do
54 visit(page_with_token("active", "/pipeline_templates/zzz"))
55 assert(page.has_no_text?(/fiddlesticks/i),
56 "trying to show a bad UUID rendered a fiddlesticks page, not 404")
59 test "404 page includes information about missing object" do
60 visit(page_with_token("active", "/groups/zazazaz"))
61 assert(page.has_text?(/group with UUID zazazaz/i),
62 "name of searched group missing from 404 page")
65 test "unrouted 404 page works" do
66 visit(page_with_token("active", "/__asdf/ghjk/zxcv"))
67 assert(page.has_text?(/not found/i),
68 "unrouted page missing 404 text")
69 assert(page.has_no_text?(/fiddlesticks/i),
70 "unrouted request returned a generic error page, not 404")
73 test "API error page has Report problem button" do
74 # point to a bad api server url to generate fiddlesticks error
75 original_arvados_v1_base = Rails.configuration.arvados_v1_base
76 Rails.configuration.arvados_v1_base = "https://[::1]:1/"
78 visit page_with_token("active")
80 assert_text 'fiddlesticks'
82 # reset api server base config to let the popup rendering to work
83 Rails.configuration.arvados_v1_base = original_arvados_v1_base
85 click_link 'Report problem'
87 within '.modal-content' do
88 assert_text 'Report a problem'
89 assert_no_text 'Version / debugging info'
90 assert_text 'Describe the problem'
91 assert_text 'Send problem report'
92 # "Send" button should be disabled until text is entered
93 assert_no_selector 'a,button:not([disabled])', text: 'Send problem report'
94 assert_selector 'a,button', text: 'Cancel'
97 report.expects(:deliver).returns true
98 IssueReporter.expects(:send_report).returns report
100 # enter a report text and click on report
101 find_field('report_issue_text').set 'my test report text'
102 click_button 'Send problem report'
104 # ajax success updated button texts and added footer message
105 assert_no_selector 'a,button', text: 'Send problem report'
106 assert_no_selector 'a,button', text: 'Cancel'
107 assert_text 'Report sent'
108 assert_text 'Thanks for reporting this issue'
112 # out of the popup now and should be back in the error page
113 assert_text 'fiddlesticks'