+ [["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
+
+ controller = c[0]
+ uuid = c[1]
+
+ visit(page_with_token("admin", "/#{controller}/#{uuid}"))
+ click_link("Log")
+ assert_no_text '123 hello'
+
+ api = ArvadosApiClient.new
+
+ text = ""
+ (1..1000).each do |i|
+ text << "#{i} hello\n"
+ end
+
+ 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'
+
+ # 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: uuid,
+ event_type: "stderr",
+ properties: {"text" => "1001 hello\n"}}})
+ assert_text '1001 hello'
+
+ # Check that new value of scrollTop is greater than the old one
+ new_top = page.evaluate_script("$('#event_log_div').scrollTop()")
+ assert_operator new_top, :>, old_top
+
+ # 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'