+ test "test running job with just a few previous log records" do
+ job = api_fixture("jobs")['running']
+
+ # Create just one old log record
+ dispatch_log(owner_uuid: job['owner_uuid'],
+ object_uuid: job['uuid'],
+ event_type: "stderr",
+ properties: {"text" => "Historic log message"})
+
+ 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
+ assert_text 'Historic log message'
+
+ # Create new log record and expect it to show up in log tab
+ dispatch_log(owner_uuid: job['owner_uuid'],
+ object_uuid: job['uuid'],
+ event_type: "stderr",
+ properties: {"text" => "Log message after subscription"})
+ assert_text 'Log message after subscription'
+ end
+
+ test "test running job with too many previous log records" do
+ max = 5
+ Rails.configuration.running_job_log_records_to_fetch = max
+ job = api_fixture("jobs")['running']
+
+ # 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
+
+ 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..max).each do |count|
+ assert_text "Old log message #{count}"
+ end
+ assert_no_text 'Old log message 0'
+
+ # Create one more log record after subscription
+ dispatch_log(owner_uuid: job['owner_uuid'],
+ object_uuid: job['uuid'],
+ event_type: "stderr",
+ properties: {"text" => "Life goes on!"})
+
+ # Expect it to show up in log tab
+ assert_text 'Life goes on!'
+ end