14988: Fixes assert_equal param ordering for proper error messages.
[arvados.git] / apps / workbench / test / integration / websockets_test.rb
index 3cfd792e8da9bf38d746e346f7339e7f1cbda755..e377da3237ea69b820ece1125ee58d11cda4d4c4 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 require 'integration_helper'
 
 class WebsocketTest < ActionDispatch::IntegrationTest
@@ -6,7 +10,7 @@ class WebsocketTest < ActionDispatch::IntegrationTest
     @dispatch_client = ArvadosApiClient.new
   end
 
-  def dispatch_log body
+  def dispatch_log(body)
     use_token :dispatch1 do
       @dispatch_client.api('logs', '', log: body)
     end
@@ -201,7 +205,6 @@ class WebsocketTest < ActionDispatch::IntegrationTest
 
   test "test running job with just a few previous log records" do
     job = api_fixture("jobs")['running']
-    visit page_with_token("active", "/jobs/#{job['uuid']}")
 
     # Create just one old log record
     dispatch_log(owner_uuid: job['owner_uuid'],
@@ -209,7 +212,7 @@ class WebsocketTest < ActionDispatch::IntegrationTest
                  event_type: "stderr",
                  properties: {"text" => "Historic log message"})
 
-    click_link("Log")
+    visit page_with_token("active", "/jobs/#{job['uuid']}\#Log")
 
     # Expect "all" historic log records because we have less than
     # default Rails.configuration.running_job_log_records_to_fetch count
@@ -224,25 +227,23 @@ class WebsocketTest < ActionDispatch::IntegrationTest
   end
 
   test "test running job with too many previous log records" do
-    Rails.configuration.running_job_log_records_to_fetch = 5
-
+    max = 5
+    Rails.configuration.running_job_log_records_to_fetch = max
     job = api_fixture("jobs")['running']
-    visit page_with_token("active", "/jobs/#{job['uuid']}")
 
-    # Create Rails.configuration.running_job_log_records_to_fetch + 1 log records
-    (0..Rails.configuration.running_job_log_records_to_fetch).each do |count|
+    # Create max+1 log records
+    (0..max).each do |count|
       dispatch_log(owner_uuid: job['owner_uuid'],
                    object_uuid: job['uuid'],
                    event_type: "stderr",
                    properties: {"text" => "Old log message #{count}"})
     end
 
-    # Go to log tab, which results in subscribing to websockets
-    click_link("Log")
+    visit page_with_token("active", "/jobs/#{job['uuid']}\#Log")
 
     # Expect all but the first historic log records,
     # because that was one too many than fetch count.
-    (1..Rails.configuration.running_job_log_records_to_fetch).each do |count|
+    (1..max).each do |count|
       assert_text "Old log message #{count}"
     end
     assert_no_text 'Old log message 0'