2761: load inputs dynamically
authorradhika <radhika@curoverse.com>
Wed, 10 Sep 2014 15:45:19 +0000 (11:45 -0400)
committerradhika <radhika@curoverse.com>
Wed, 10 Sep 2014 15:45:19 +0000 (11:45 -0400)
apps/workbench/test/diagnostics/pipeline_test.rb
apps/workbench/test/diagnostics_test_helper.rb [new file with mode: 0644]

index fdc9d20a4ca07ec1afe228ebe4eaff15960a9ae8..126b6a6d21517f95e9614c537fb0c7cffa9eaf8d 100644 (file)
@@ -23,12 +23,6 @@ class PipelineTest < DiagnosticsTest
         page.find('.glyphicon-search').click
       end
 
-#      within '.modal-content' do
-#        find('.selectable', text: pipeline_config['template_name']).click
-#        find(:xpath, "//div[./span[contains(.,'zzzzz-p5p6p-rxj8d71854j9idn')]]").click
-#        click_button 'Show'
-#      end
-
       # Run the pipeline
       find('a,button', text: 'Run').click
 
@@ -38,23 +32,34 @@ class PipelineTest < DiagnosticsTest
         find('button', text: 'Choose').click
       end
 
+      if pipeline_config['input_names'].andand.any?
         # This pipeline needs input. So, Run should be disabled
         page.assert_selector 'a.disabled,button.disabled', text: 'Run'
 
-        # Choose input for the pipeline
-        find('.btn', text: 'Choose').click
-        within('.modal-dialog') do
-          find('.selectable', text: pipeline_config['input_names'][0]).click
-          find('button', text: 'OK').click
-        end
-        wait_for_ajax
-
-        # Run this pipeline instance
-        find('a,button', text: 'Run').click
+        inputs = page.all('.btn', text: 'Choose')
+        inputs.each_with_index do |input, index|
+          # Choose input for the pipeline
+          input.click
+          within('.modal-dialog') do
+            input_found = page.has_text?(pipeline_config['input_names'][index])
+            if input_found
+              find('.selectable', text: pipeline_config['input_names'][index]).click
+            else
+              fill_in('Search', with: pipeline_config['input_names'][index], exact: true)
+              wait_for_ajax
+              find('.selectable', text: pipeline_config['input_names'][index]).click
+            end
+            find('button', text: 'OK').click
+            wait_for_ajax
+          end
 
-        # Pipeline is running. We have a "Stop" button instead now.
-        page.assert_selector 'a,button', text: 'Stop'
+          # Run this pipeline instance
+          find('a,button', text: 'Run').click
+          # Pipeline is running. We have a "Stop" button instead now.
+          page.assert_selector 'a,button', text: 'Stop'
+        end
       end
+    end
   end
 
 end
diff --git a/apps/workbench/test/diagnostics_test_helper.rb b/apps/workbench/test/diagnostics_test_helper.rb
new file mode 100644 (file)
index 0000000..2d378f3
--- /dev/null
@@ -0,0 +1,15 @@
+require 'integration_helper'
+require 'yaml'
+
+class DiagnosticsTest < ActionDispatch::IntegrationTest
+
+  def visit_page_with_token token_name, path='/'
+    tokens = Rails.configuration.diagnostics_testing_user_tokens
+    visit page_with_token(tokens[token_name], path)
+  end
+
+  def diagnostic_test_pipeline_config pipeline_to_run
+    Rails.configuration.diagnostics_testing_pipeline_fields[pipeline_to_run]
+  end
+
+end