4 require 'integration_helper'
6 class JobsTest < ActionDispatch::IntegrationTest
8 def fakepipe_with_log_data
10 "2014-01-01_12:00:01 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 1\n" +
11 "2014-01-01_12:00:02 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 2\n" +
12 "2014-01-01_12:00:03 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 3\n"
13 StringIO.new content, 'r'
16 test "add job description" do
17 Capybara.current_driver = Capybara.javascript_driver
18 visit page_with_token("active", "/jobs")
20 # go to job running the script "doesnotexist"
21 within first('tr', text: 'doesnotexist') do
25 # edit job description
26 within('.arv-description-as-subtitle') do
27 find('.fa-pencil').click
28 find('.editable-input textarea').set('*Textile description for job* - "Go to dashboard":/')
29 find('.editable-submit').click
33 # Verify edited description
34 assert page.has_no_text? '*Textile description for job*'
35 assert page.has_text? 'Textile description for job'
36 assert page.has_link? 'Go to dashboard'
37 click_link 'Go to dashboard'
38 assert page.has_text? 'Active pipelines'
41 test "view job log" do
42 Capybara.current_driver = Capybara.javascript_driver
43 job = api_fixture('jobs')['job_with_real_log']
45 IO.expects(:popen).returns(fakepipe_with_log_data)
47 visit page_with_token("active", "/jobs/#{job['uuid']}")
48 assert page.has_text? job['script_version']
52 assert page.has_text? 'Started at'
53 assert page.has_text? 'Finished at'
54 assert page.has_text? 'log message 1'
55 assert page.has_text? 'log message 2'
56 assert page.has_text? 'log message 3'
57 assert page.has_no_text? 'Showing only 100 bytes of this log'
60 test 'view partial job log' do
61 Capybara.current_driver = Capybara.javascript_driver
62 # This config will be restored during teardown by ../test_helper.rb:
63 Rails.configuration.log_viewer_max_bytes = 100
65 IO.expects(:popen).returns(fakepipe_with_log_data)
66 job = api_fixture('jobs')['job_with_real_log']
68 visit page_with_token("active", "/jobs/#{job['uuid']}")
69 assert page.has_text? job['script_version']
73 assert page.has_text? 'Showing only 100 bytes of this log'