gitignore sdk/cli/vendor. refs #3551
[arvados.git] / apps / workbench / test / integration / smoke_test.rb
1 require 'integration_helper'
2 require 'uri'
3
4 class SmokeTest < ActionDispatch::IntegrationTest
5   setup do
6     Capybara.current_driver = Capybara.javascript_driver
7   end
8
9   def assert_visit_success(allowed=[200])
10     assert_includes(allowed, status_code,
11                     "#{current_url} returned #{status_code}, not one of " +
12                     allowed.inspect)
13   end
14
15   def all_links_in(find_spec, text_regexp=//)
16     all(find_spec + ' a').collect { |tag|
17       if tag[:href].nil? or tag[:href].empty? or (tag.text !~ text_regexp)
18         nil
19       elsif tag[:'data-remote']
20         # these don't necessarily work with format=html
21         nil
22       else
23         url = URI(tag[:href])
24         url.host.nil? ? url.path : nil
25       end
26     }.compact
27   end
28
29   test "all first-level links succeed" do
30     visit page_with_token('active_trustedclient', '/')
31     assert_visit_success
32     click_link 'notifications-menu'
33     urls = [all_links_in('nav'),
34             all_links_in('.navbar', /^Manage /)].flatten
35     seen_urls = ['/']
36     while not (url = urls.shift).nil?
37       next if seen_urls.include? url
38       visit url
39       seen_urls << url
40       assert_visit_success
41       # Uncommenting the line below lets you crawl the entire site for a
42       # more thorough test.
43       # urls += all_links_in('body')
44     end
45   end
46 end