Sha256: 798706b74554bd36e06cb908f209b13378dd32cba6a3e3b87d14e9dc46b1ff46

Contents?: true

Size: 1.77 KB

Versions: 68

Compression:

Stored size: 1.77 KB

Contents

module OpsManagerUiDrivers
  module Version17
    class ProductErrands
      def initialize(browser:, product_name:)
        @browser = browser
        @product_name = product_name
      end

      def enable_errand(errand_name)
        open_form
        set_check_box("pre_delete_errands_enabled_names_#{errand_name}", true)
        set_check_box("post_deploy_errands_enabled_names_#{errand_name}", true)
        save_form
      end

      def disable_errand(errand_name)
        open_form
        set_check_box("pre_delete_errands_enabled_names_#{errand_name}", false)
        set_check_box("post_deploy_errands_enabled_names_#{errand_name}", false)
        save_form
      end

      def enabled_errands
        open_form

        result = []

        browser.all("input[type='checkbox'][name='post_deploy_errands[enabled_names][]'][checked='checked']").map do |checkbox|
          result << checkbox.value
        end

        browser.all("input[type='checkbox'][name='pre_delete_errands[enabled_names][]'][checked='checked']").map do |checkbox|
          result << checkbox.value
        end

        result
      end

      def save_form(validate: true)
        browser.click_on 'Save'

        fail('unexpected failure') unless browser.has_css?('.flash-message')

        if validate
          fail(browser.find('.flash-message.error').text) unless browser.has_css?('.flash-message.success')
        end
      end

      def open_form
        browser.visit '/'
        browser.click_on "show-#{product_name}-configure-action"
        browser.click_on "show-product-errands-action"
      end

      private

      attr_reader :browser, :product_name

      def set_check_box(name, value)
        check_box = browser.first(:css, "\##{name}")
        check_box.set(value) if check_box
      end
    end
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
ops_manager_ui_drivers-2.42.0 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.41.0 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.40.1 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.40.0 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.39.0 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.38.0 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.37.0 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.36.0 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.35.2 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.35.1 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.35.0 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.34.1 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.34.0 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.33.1 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.33.0 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.32.1 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.32.0 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.31.3 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.31.2 lib/ops_manager_ui_drivers/version17/product_errands.rb
ops_manager_ui_drivers-2.31.1 lib/ops_manager_ui_drivers/version17/product_errands.rb