4 require 'integration_helper'
6 class JobsTest < ActionDispatch::IntegrationTest
11 def fakepipe_with_log_data
13 "2014-01-01_12:00:01 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 1\n" +
14 "2014-01-01_12:00:02 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 2\n" +
15 "2014-01-01_12:00:03 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 3\n"
16 StringIO.new content, 'r'
19 test "add job description" do
20 job = api_fixture('jobs')['nearly_finished_job']
21 visit page_with_token("active", "/jobs/#{job['uuid']}")
23 # edit job description
24 within('.arv-description-as-subtitle') do
25 find('.fa-pencil').click
26 find('.editable-input textarea').set('*Textile description for job* - "Go to dashboard":/')
27 find('.editable-submit').click
30 # Verify edited description
31 assert_no_text '*Textile description for job*'
32 assert_text 'Textile description for job'
33 assert_selector 'a[href="/"]', text: 'Go to dashboard'
36 test "view job log" do
37 job = api_fixture('jobs')['job_with_real_log']
39 IO.expects(:popen).returns(fakepipe_with_log_data)
41 visit page_with_token("active", "/jobs/#{job['uuid']}")
42 assert page.has_text? job['script_version']
46 assert page.has_text? 'Started at'
47 assert page.has_text? 'Finished at'
48 assert page.has_text? 'log message 1'
49 assert page.has_text? 'log message 2'
50 assert page.has_text? 'log message 3'
51 assert page.has_no_text? 'Showing only 100 bytes of this log'
54 test 'view partial job log' do
55 # This config will be restored during teardown by ../test_helper.rb:
56 Rails.configuration.log_viewer_max_bytes = 100
58 IO.expects(:popen).returns(fakepipe_with_log_data)
59 job = api_fixture('jobs')['job_with_real_log']
61 visit page_with_token("active", "/jobs/#{job['uuid']}")
62 assert page.has_text? job['script_version']
66 assert page.has_text? 'Showing only 100 bytes of this log'
70 ['foobar', false, false],
71 ['job_with_latest_version', true, false],
72 ['job_with_latest_version', true, true],
73 ].each do |job_name, expect_options, use_latest|
74 test "Rerun #{job_name} job, expect options #{expect_options},
75 and use latest version option #{use_latest}" do
76 job = api_fixture('jobs')[job_name]
77 visit page_with_token 'active', '/jobs/'+job['uuid']
80 assert_text 'supplied_script_version: master'
82 assert_text 'supplied_script_version: (none)'
85 assert_triggers_dom_event 'shown.bs.modal' do
86 find('a,button', text: 'Re-run job...').click
88 within('.modal-dialog') do
89 assert_selector 'a,button', text: 'Cancel'
91 page.choose("job_script_version_#{job['supplied_script_version']}")
96 # Re-running jobs doesn't currently work because the test API
97 # server has no git repository to check against. For now, check
98 # that the correct script version is mentioned in the
99 # Fiddlesticks error message.
100 if expect_options && use_latest
101 assert_text "Script version #{job['supplied_script_version']} does not resolve to a commit"
103 assert_text "Script version #{job['script_version']} does not resolve to a commit"