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
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
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
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'
77 ['foobar', false, false],
78 ['job_with_latest_version', true, false],
79 ['job_with_latest_version', true, true],
80 ].each do |job_name, expect_options, use_latest|
81 test "Rerun #{job_name} job, expect options #{expect_options},
82 and use latest version option #{use_latest}" do
85 job = api_fixture('jobs')[job_name]
86 visit page_with_token 'active', '/jobs/'+job['uuid']
89 assert_text 'supplied_script_version: master'
91 assert_text 'supplied_script_version: (none)'
94 assert_triggers_dom_event 'shown.bs.modal' do
95 find('a,button', text: 'Re-run job...').click
97 within('.modal-dialog') do
98 assert_selector 'a,button', text: 'Cancel'
100 page.choose("job_script_version_#{job['supplied_script_version']}")
105 # Re-running jobs doesn't currently work because the test API
106 # server has no git repository to check against. For now, check
107 # that the correct script version is mentioned in the
108 # Fiddlesticks error message.
109 if expect_options && use_latest
110 assert_text "Script version #{job['supplied_script_version']} does not resolve to a commit"
112 assert_text "Script version #{job['script_version']} does not resolve to a commit"