4878: add integration test for Re-run job with options.
authorRadhika Chippada <radhika@curoverse.com>
Fri, 23 Jan 2015 16:25:55 +0000 (11:25 -0500)
committerRadhika Chippada <radhika@curoverse.com>
Fri, 23 Jan 2015 16:25:55 +0000 (11:25 -0500)
apps/workbench/test/integration/jobs_test.rb
services/api/test/fixtures/jobs.yml

index 716e7319874d56189b145acae6fd4c137a590f23..ae6001accc4cbcd59a0dc413e22ddb5d5def8c79 100644 (file)
@@ -72,4 +72,48 @@ class JobsTest < ActionDispatch::IntegrationTest
     wait_for_ajax
     assert page.has_text? 'Showing only 100 bytes of this log'
   end
+
+  [
+    ['foobar', false, false, false],
+    ['job_with_latest_version', true, false, false],
+    ['job_with_latest_version', true, true, false],
+    ['job_with_latest_version', true, true, true],
+  ].each do |job_name, expect_options, use_options, click_option|
+    test "Rerun #{job_name} job, expect options #{expect_options},
+          use options #{use_options} and click option #{click_option}" do
+      job = api_fixture('jobs')[job_name]
+      visit page_with_token 'active', '/jobs/'+job['uuid']
+
+      assert_selector 'a,button', text: 'Re-run same version'
+      if expect_options
+        assert_text 'supplied_script_version: master'
+        assert_selector 'a,button', text: 'Re-run with options'
+      else
+        assert_text 'supplied_script_version: (none)'
+        assert_no_selector 'a,button', text: 'Re-run with options'
+      end
+
+      # Now re-run the job
+      if use_options
+        assert_triggers_dom_event 'shown.bs.modal' do
+          find('a,button', text: 'Re-run with options...').click
+        end
+        within('.modal-dialog') do
+          assert_selector 'a,button', text: 'Run now'
+          assert_selector 'a,button', text: 'Cancel'
+          page.choose('use_script_same') if click_option
+          find('button', text: 'Run now').click
+        end
+      else
+        find('a,button', text: 'Re-run same version').click
+      end
+
+      # We see Fiddlesticks, but let's make sure the correct script version is sought.
+      if use_options && !click_option
+        assert_text "Script version #{job['supplied_script_version']} does not resolve to a commit"
+      else
+        assert_text "Script version #{job['script_version']} does not resolve to a commit"
+      end
+    end
+  end
 end
index 888cb2af7f578e1dccd59251f8f8864b29995d24..2243339b75eb92e9649eff0b48d7c10439de1a40 100644 (file)
@@ -371,6 +371,34 @@ graph_stage3:
     input2: "stuff2"
   output: ea10d51bcf88862dbcc36eb292017dfd+45
 
+job_with_latest_version:
+  uuid: zzzzz-8i9sb-nj8ioxnrvjtyk2b
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  cancelled_at: ~
+  cancelled_by_user_uuid: ~
+  cancelled_by_client_uuid: ~
+  script: hash
+  repository: foo
+  script_version: 7def43a4d3f20789dda4700f703b5514cc3ed250
+  supplied_script_version: master
+  script_parameters:
+    input: 1f4b0bc7583c2a7f9102c395f4ffc5e3+45
+  created_at: <%= 4.minute.ago.to_s(:db) %>
+  started_at: <%= 3.minute.ago.to_s(:db) %>
+  finished_at: <%= 2.minute.ago.to_s(:db) %>
+  running: false
+  success: true
+  output: fa7aeb5140e2848d39b416daeef4ffc5+45
+  priority: 0
+  log: ea10d51bcf88862dbcc36eb292017dfd+45
+  is_locked_by_uuid: ~
+  tasks_summary:
+    failed: 0
+    todo: 0
+    running: 0
+    done: 1
+  runtime_constraints: {}
+  state: Complete
 
 # Test Helper trims the rest of the file