Merge branch '2328-keep-permission-flags' (closes #2328)
[arvados.git] / apps / workbench / test / integration / smoke_test.rb
1 require 'integration_helper'
2 require 'uri'
3
4 class SmokeTest < ActionDispatch::IntegrationTest
5   def assert_visit_success(allowed=[200])
6     assert_includes(allowed, status_code,
7                     "#{current_url} returned #{status_code}, not one of " +
8                     allowed.inspect)
9   end
10
11   def all_links_in(find_spec, text_regexp=//)
12     find(find_spec).all('a').collect { |tag|
13       if tag[:href].nil? or tag[:href].empty? or (tag.text !~ text_regexp)
14         nil
15       else
16         url = URI(tag[:href])
17         url.host.nil? ? url.path : nil
18       end
19     }.compact
20   end
21
22   test "all first-level links succeed" do
23     visit page_with_token('active_trustedclient', '/')
24     assert_visit_success
25     click_link 'user-menu'
26     urls = [all_links_in('nav'),
27             all_links_in('.navbar', /^Manage /)].flatten
28     seen_urls = ['/']
29     while not (url = urls.shift).nil?
30       next if seen_urls.include? url
31       visit url
32       seen_urls << url
33       assert_visit_success
34       # Uncommenting the line below lets you crawl the entire site for a
35       # more thorough test.
36       # urls += all_links_in('body')
37     end
38   end
39 end