X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f075cec933827186d93d5d16ab5ab6803b31d40d..9325dabcc2b6c32a589ba86cc052946b4875eb1d:/apps/workbench/test/integration/websockets_test.rb diff --git a/apps/workbench/test/integration/websockets_test.rb b/apps/workbench/test/integration/websockets_test.rb index 65784af523..341975fe2a 100644 --- a/apps/workbench/test/integration/websockets_test.rb +++ b/apps/workbench/test/integration/websockets_test.rb @@ -33,52 +33,60 @@ class WebsocketTest < ActionDispatch::IntegrationTest Thread.current[:arvados_api_token] = nil end - test "test live logging scrolling" do - visit(page_with_token("admin", "/pipeline_instances/zzzzz-d1hrv-9fm8l10i9z2kqc6")) - click_link("Log") - assert_no_text '123 hello' - api = ArvadosApiClient.new + [["pipeline_instances", api_fixture("pipeline_instances")['pipeline_with_newer_template']['uuid']], + ["jobs", api_fixture("jobs")['running']['uuid']]].each do |c| + test "test live logging scrolling #{c[0]}" do - text = "" - (1..1000).each do |i| - text << "#{i} hello\n" - end + controller = c[0] + uuid = c[1] - Thread.current[:arvados_api_token] = @@API_AUTHS["admin"]['api_token'] - api.api("logs", "", {log: { - object_uuid: "zzzzz-d1hrv-9fm8l10i9z2kqc6", - event_type: "stderr", - properties: {"text" => text}}}) - assert_text '1000 hello' + visit(page_with_token("admin", "/#{controller}/#{uuid}")) + click_link("Log") + assert_no_text '123 hello' - # First test that when we're already at the bottom of the page, it scrolls down - # when a new line is added. - old_top = page.evaluate_script("$('#pipeline_event_log_div').scrollTop()") + api = ArvadosApiClient.new - api.api("logs", "", {log: { - object_uuid: "zzzzz-d1hrv-9fm8l10i9z2kqc6", - event_type: "stderr", - properties: {"text" => "1001 hello\n"}}}) - assert_text '1001 hello' + text = "" + (1..1000).each do |i| + text << "#{i} hello\n" + end - # Check that new value of scrollTop is greater than the old one - assert page.evaluate_script("$('#pipeline_event_log_div').scrollTop()") > old_top + Thread.current[:arvados_api_token] = @@API_AUTHS["admin"]['api_token'] + api.api("logs", "", {log: { + object_uuid: uuid, + event_type: "stderr", + properties: {"text" => text}}}) + assert_text '1000 hello' - # Now scroll to 30 pixels from the top - page.execute_script "$('#pipeline_event_log_div').scrollTop(30)" - assert_equal 30, page.evaluate_script("$('#pipeline_event_log_div').scrollTop()") + # First test that when we're already at the bottom of the page, it scrolls down + # when a new line is added. + old_top = page.evaluate_script("$('#event_log_div').scrollTop()") - api.api("logs", "", {log: { - object_uuid: "zzzzz-d1hrv-9fm8l10i9z2kqc6", - event_type: "stderr", - properties: {"text" => "1002 hello\n"}}}) - assert_text '1002 hello' + api.api("logs", "", {log: { + object_uuid: uuid, + event_type: "stderr", + properties: {"text" => "1001 hello\n"}}}) + assert_text '1001 hello' - # Check that we haven't changed scroll position - assert_equal 30, page.evaluate_script("$('#pipeline_event_log_div').scrollTop()") + # Check that new value of scrollTop is greater than the old one + assert page.evaluate_script("$('#event_log_div').scrollTop()") > old_top - Thread.current[:arvados_api_token] = nil + # Now scroll to 30 pixels from the top + page.execute_script "$('#event_log_div').scrollTop(30)" + assert_equal 30, page.evaluate_script("$('#event_log_div').scrollTop()") + + api.api("logs", "", {log: { + object_uuid: uuid, + event_type: "stderr", + properties: {"text" => "1002 hello\n"}}}) + assert_text '1002 hello' + + # Check that we haven't changed scroll position + assert_equal 30, page.evaluate_script("$('#event_log_div').scrollTop()") + + Thread.current[:arvados_api_token] = nil + end end test "pipeline instance arv-refresh-on-log-event" do