Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / apps / workbench / test / integration / smoke_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'integration_helper'
6 require 'uri'
7
8 class SmokeTest < ActionDispatch::IntegrationTest
9   setup do
10     need_javascript
11   end
12
13   def assert_visit_success(allowed=[200])
14     assert_includes(allowed, status_code,
15                     "#{current_url} returned #{status_code}, not one of " +
16                     allowed.inspect)
17   end
18
19   def all_links_in(find_spec, text_regexp=//)
20     all(find_spec + ' a').collect { |tag|
21       if tag[:href].nil? or tag[:href].empty? or (tag.text !~ text_regexp)
22         nil
23       elsif tag[:'data-remote']
24         # these don't necessarily work with format=html
25         nil
26       else
27         url = URI(tag[:href])
28         url.host.nil? ? url.path : nil
29       end
30     }.compact
31   end
32
33   test "all first-level links succeed" do
34     visit page_with_token('active_trustedclient', '/')
35     assert_visit_success
36     click_link 'notifications-menu'
37     urls = [all_links_in('nav'),
38             all_links_in('.navbar', /^Manage /)].flatten
39     seen_urls = ['/']
40     while not (url = urls.shift).nil?
41       next if seen_urls.include? url
42       visit url
43       seen_urls << url
44       assert_visit_success
45       # Uncommenting the line below lets you crawl the entire site for a
46       # more thorough test.
47       # urls += all_links_in('body')
48     end
49   end
50
51   test "mithril test page" do
52     visit page_with_token('active_trustedclient', '/tests/mithril')
53     assert_visit_success
54     assert_selector 'p', text: 'mithril is working'
55   end
56 end