4 require 'integration_helper'
6 class JobsTest < ActionDispatch::IntegrationTest
9 # Set up KEEP_LOCAL_STORE with a file that satisfies
10 # the log collection for job 'job_with_real_log'
11 # TODO: figure out a better way to store this test data
12 # (e.g. in a dummy test fixture)
14 ENV['KEEP_LOCAL_STORE'] ||= Dir.mktmpdir
15 keepdir = ENV['KEEP_LOCAL_STORE']
16 open(File.join(keepdir, 'cdd549ae79fe6640fa3d5c6261d8303c'), 'w') do |f|
17 f.write("2014-01-01_12:00:01 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 1\n")
18 f.write("2014-01-01_12:00:02 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 2\n")
19 f.write("2014-01-01_12:00:03 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 3\n")
22 @log_viewer_max_bytes = Rails.configuration.log_viewer_max_bytes
26 keepdir = ENV.delete 'KEEP_LOCAL_STORE'
27 FileUtils.rm_rf(keepdir) if keepdir
28 Rails.configuration.log_viewer_max_bytes = @log_viewer_max_bytes
31 test "add job description" do
32 Capybara.current_driver = Capybara.javascript_driver
33 visit page_with_token("active", "/jobs")
35 # go to job running the script "doesnotexist"
36 within first('tr', text: 'doesnotexist') do
40 # edit job description
41 within('.arv-description-as-subtitle') do
42 find('.fa-pencil').click
43 find('.editable-input textarea').set('*Textile description for job* - "Go to dashboard":/')
44 find('.editable-submit').click
48 # Verify edited description
49 assert page.has_no_text? '*Textile description for job*'
50 assert page.has_text? 'Textile description for job'
51 assert page.has_link? 'Go to dashboard'
52 click_link 'Go to dashboard'
53 assert page.has_text? 'Active pipelines'
56 test "view job log" do
57 Capybara.current_driver = Capybara.javascript_driver
58 job = api_fixture('jobs')['job_with_real_log']
60 visit page_with_token("active", "/jobs/#{job['uuid']}")
61 assert page.has_text? job['script_version']
65 assert page.has_text? 'Started at'
66 assert page.has_text? 'Finished at'
67 assert page.has_text? 'log message 1'
68 assert page.has_text? 'log message 2'
69 assert page.has_text? 'log message 3'
72 test 'view partial job log' do
73 Capybara.current_driver = Capybara.javascript_driver
74 Rails.configuration.log_viewer_max_bytes = 100
75 job = api_fixture('jobs')['job_with_real_log']
77 visit page_with_token("active", "/jobs/#{job['uuid']}")
78 assert page.has_text? job['script_version']
82 assert page.has_text? 'Showing only 100 bytes of this log'