7942: Skip unreliable test. refs #7942
[arvados.git] / apps / workbench / test / integration / ajax_errors_test.rb
1 require 'integration_helper'
2
3 class AjaxErrorsTest < ActionDispatch::IntegrationTest
4   setup do
5     # Regrettably...
6     need_selenium 'to assert_text in iframe'
7   end
8
9   test 'load pane with deleted session' do
10     skip 'unreliable test'
11     # Simulate loading a page in browser-tab A, hitting "Log out" in
12     # browser-tab B, then returning to browser-tab A and choosing a
13     # different tab. (Automatic tab refreshes will behave similarly.)
14     visit page_with_token('active', '/projects/' + api_fixture('groups')['aproject']['uuid'])
15     ActionDispatch::Request::Session.any_instance.stubs(:[]).returns(nil)
16     click_link "Subprojects"
17     wait_for_ajax
18     assert_no_double_layout
19     assert_selector 'a,button', text: 'Reload tab'
20     assert_selector '.pane-error-display'
21     page.driver.browser.switch_to.frame 0
22     assert_text 'You are not logged in.'
23   end
24
25   test 'load pane with expired token' do
26     # Similar to 'deleted session'. Here, the session cookie is still
27     # alive, but it contains a token which has expired. This uses a
28     # different code path because Workbench cannot detect that
29     # anything is amiss until it actually uses the token in an API
30     # request.
31     visit page_with_token('active', '/projects/' + api_fixture('groups')['aproject']['uuid'])
32     use_token :active_trustedclient do
33       # Go behind Workbench's back to expire the "active" token.
34       token = api_fixture('api_client_authorizations')['active']['api_token']
35       auth = ApiClientAuthorization.find(token)
36       auth.update_attributes(expires_at: '1999-12-31T23:59:59Z')
37     end
38     click_link "Subprojects"
39     wait_for_ajax
40     assert_no_double_layout
41     assert_selector 'a,button', text: 'Reload tab'
42     assert_selector '.pane-error-display'
43     page.driver.browser.switch_to.frame 0
44     assert_text 'You are not logged in.'
45   end
46
47   protected
48
49   def assert_no_double_layout
50     # Check we're not rendering a full page layout within a tab
51     # pane. Bootstrap responsive layouts require exactly one
52     # div.container-fluid. Checking "body body" would be more generic,
53     # but doesn't work when the browser/driver automatically collapses
54     # syntatically invalid tags.
55     assert_no_selector '.container-fluid .container-fluid'
56   end
57 end