2891: Add Workbench test for expired API token.
[arvados.git] / apps / workbench / test / integration / errors_test.rb
1 require 'integration_helper'
2
3 class ErrorsTest < ActionDispatch::IntegrationTest
4   BAD_UUID = "ffffffffffffffffffffffffffffffff+0"
5
6   test "error page renders user navigation" do
7     visit(page_with_token("active", "/collections/#{BAD_UUID}"))
8     assert(page.has_text?(api_fixture("users")["active"]["email"]),
9            "User information missing from error page")
10     assert(page.has_no_text?(/log ?in/i),
11            "Logged in user prompted to log in on error page")
12   end
13
14   test "no user navigation with expired token" do
15     visit(page_with_token("expired", "/collections/#{BAD_UUID}"))
16     assert(page.has_no_text?(api_fixture("users")["active"]["email"]),
17            "Page visited with expired token included user information")
18     assert(page.has_selector?("a", text: /log ?in/i),
19            "Login prompt missing on expired token error page")
20   end
21
22   test "error page renders without login" do
23     visit "/collections/download/#{BAD_UUID}/#{@@API_AUTHS['active']['api_token']}"
24     assert(page.has_no_text?(/\b500\b/),
25            "Error page without login returned 500")
26   end
27
28   test "'object not found' page includes search link" do
29     visit(page_with_token("active", "/collections/#{BAD_UUID}"))
30     assert(all("a").any? { |a| a[:href] =~ %r{/collections/?(\?|$)} },
31            "no search link found on 404 page")
32   end
33 end