Merge branch '8784-dir-listings'
[arvados.git] / apps / workbench / test / integration / logins_test.rb
index 6e5389e7cc11d0a4d6c7c4808023476346e9c978..7f2774ce2f33beb7d596a32dc89569c984ff17f2 100644 (file)
@@ -1,22 +1,26 @@
-require 'test_helper'
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+require 'integration_helper'
 
 class LoginsTest < ActionDispatch::IntegrationTest
+  setup do
+    need_javascript
+  end
+
   test "login with api_token works after redirect" do
     visit page_with_token('active_trustedclient')
-    assert page.has_text?('Recent jobs'), "Missing 'Recent jobs' from page"
+    assert page.has_text?('Recent pipelines and processes'), "Missing 'Recent pipelines and processes' from page"
     assert_no_match(/\bapi_token=/, current_path)
   end
 
-  test "can't use expired token" do
-    visit page_with_token('expired_trustedclient')
-    assert page.has_text? 'Log in'
-  end
-
-  test "expired token yields login page, not error page" do
-    skip
+  test "trying to use expired token redirects to login page" do
     visit page_with_token('expired_trustedclient')
-    # Even the error page has a "Log in" link. We should look for
-    # something that only appears the real login page.
-    assert page.has_text? 'Please log in'
+    buttons = all("a.btn", text: /Log in/)
+    assert_equal(1, buttons.size, "Failed to find one login button")
+    login_link = buttons.first[:href]
+    assert_match(%r{//[^/]+/login}, login_link)
+    assert_no_match(/\bapi_token=/, login_link)
   end
 end