Merge branch 'master' into 3889-functional-testing
[arvados.git] / apps / workbench / test / functional / pipeline_instances_controller_test.rb
index 77da2ad333adc6fa37811f78782b1771a3e96d4c..20886b5ab6d834fd01e03226ef69e751374b506f 100644 (file)
@@ -1,23 +1,25 @@
 require 'test_helper'
 
 class PipelineInstancesControllerTest < ActionController::TestCase
-  def create_instance_long_enough_to
+  def create_instance_long_enough_to(instance_attrs={})
+    # create 'two_part' pipeline with the given instance attributes
     pt_fixture = api_fixture('pipeline_templates')['two_part']
     post :create, {
-      pipeline_instance: {
+      pipeline_instance: instance_attrs.merge({
         pipeline_template_uuid: pt_fixture['uuid']
-      },
+      }),
       format: :json
     }, session_for(:active)
     assert_response :success
     pi_uuid = assigns(:object).uuid
     assert_not_nil assigns(:object)
+
+    # yield
     yield pi_uuid, pt_fixture
-    post :destroy, {
-      id: pi_uuid,
-      format: :json
-    }
-    assert_response :success
+
+    # delete the pipeline instance
+    use_token :active
+    PipelineInstance.where(uuid: pi_uuid).first.destroy
   end
 
   test "pipeline instance components populated after create" do
@@ -27,10 +29,18 @@ class PipelineInstancesControllerTest < ActionController::TestCase
     end
   end
 
+  test "can render pipeline instance with tagged collections" do
+    # Make sure to pass in a tagged collection to test that part of the rendering behavior.
+    get(:show,
+        {id: api_fixture("pipeline_instances")["pipeline_with_tagged_collection_input"]["uuid"]},
+        session_for(:active))
+    assert_response :success
+  end
+
   test "update script_parameters one at a time using merge param" do
-    create_instance_long_enough_to do |new_instance_uuid, template_fixture|
+      template_fixture = api_fixture('pipeline_templates')['two_part']
       post :update, {
-        id: new_instance_uuid,
+        id: api_fixture("pipeline_instances")["pipeline_to_merge_params"]["uuid"],
         pipeline_instance: {
           components: {
             "part-two" => {
@@ -57,6 +67,23 @@ class PipelineInstancesControllerTest < ActionController::TestCase
           assert_equal orig_params[k].to_json, new_params[k.to_sym].to_json
         end
       end
-    end
+  end
+
+  test "component rendering copes with unexpeceted components format" do
+    get(:show,
+        {id: api_fixture("pipeline_instances")["components_is_jobspec"]["uuid"]},
+        session_for(:active))
+    assert_response :success
+  end
+
+  test "dates in JSON components are parsed" do
+    get(:show,
+        {id: api_fixture('pipeline_instances')['has_component_with_completed_jobs']['uuid']},
+        session_for(:active))
+    assert_response :success
+    assert_not_nil assigns(:object)
+    assert_not_nil assigns(:object).components[:foo][:job]
+    assert assigns(:object).components[:foo][:job][:started_at].is_a? Time
+    assert assigns(:object).components[:foo][:job][:finished_at].is_a? Time
   end
 end