1 require 'integration_helper'
3 class AjaxErrorsTest < ActionDispatch::IntegrationTest
6 need_selenium 'to assert_text in iframe'
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"
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.'
25 test 'load pane with expired token' do
26 skip 'unreliable test'
27 # Similar to 'deleted session'. Here, the session cookie is still
28 # alive, but it contains a token which has expired. This uses a
29 # different code path because Workbench cannot detect that
30 # anything is amiss until it actually uses the token in an API
32 visit page_with_token('active', '/projects/' + api_fixture('groups')['aproject']['uuid'])
33 use_token :active_trustedclient do
34 # Go behind Workbench's back to expire the "active" token.
35 token = api_fixture('api_client_authorizations')['active']['api_token']
36 auth = ApiClientAuthorization.find(token)
37 auth.update_attributes(expires_at: '1999-12-31T23:59:59Z')
39 click_link "Subprojects"
41 assert_no_double_layout
42 assert_selector 'a,button', text: 'Reload tab'
43 assert_selector '.pane-error-display'
44 page.driver.browser.switch_to.frame 0
45 assert_text 'You are not logged in.'
50 def assert_no_double_layout
51 # Check we're not rendering a full page layout within a tab
52 # pane. Bootstrap responsive layouts require exactly one
53 # div.container-fluid. Checking "body body" would be more generic,
54 # but doesn't work when the browser/driver automatically collapses
55 # syntatically invalid tags.
56 assert_no_selector '.container-fluid .container-fluid'