+ assert_text 'test dashboard arv-refresh-on-log-event'
+ end
+
+ test 'job graph appears when first data point is already in logs table' do
+ job_graph_first_datapoint_test
+ end
+
+ test 'job graph appears when first data point arrives by websocket' do
+ use_token :admin do
+ Log.find(api_fixture('logs')['crunchstat_for_running_job']['uuid']).destroy
+ end
+ job_graph_first_datapoint_test expect_existing_datapoints: false
+ end
+
+ def job_graph_first_datapoint_test expect_existing_datapoints: true
+ uuid = api_fixture('jobs')['running']['uuid']
+
+ visit page_with_token "active", "/jobs/#{uuid}"
+ click_link "Log"
+
+ assert_selector '#event_log_div', visible: true
+
+ if expect_existing_datapoints
+ assert_selector '#log_graph_div', visible: true
+ # Magic numbers 12.99 etc come from the job log fixture:
+ assert_last_datapoint 'T1-cpu', (((12.99+0.99)/10.0002)/8)
+ else
+ # Until graphable data arrives, we should see the text log but not the graph.
+ assert_no_selector '#log_graph_div', visible: true
+ end
+
+ text = "2014-11-07_23:33:51 #{uuid} 31708 1 stderr crunchstat: cpu 1970.8200 user 60.2700 sys 8 cpus -- interval 10.0002 seconds 35.3900 user 0.8600 sys"