class OpsManagerUiDrivers::Version14::ProductDashboard

Attributes

browser[R]

Public Class Methods

new(browser:) click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 9
def initialize(browser:)
  @browser = browser
  @allowed_ignorable_errors = []
end

Public Instance Methods

apply_updates(validate: true) click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 14
def apply_updates(validate: true)
  open_dashboard
  browser.click_on 'install-action'
  if validate
    fail 'Install failed verification' if nonignorable_verification_failed?
    allow_cpu_verification_errors
    allow_privilege_verification_errors
    allow_icmp_verification_errors #this is only for AWS; consider moving out

    ignore_allowable_errors
    assert_installation_started
  end
  ApplyUpdatesResult.new(browser: @browser)
end
delete_installation_available?() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 90
def delete_installation_available?
  open_dashboard
  browser.click_on 'toggle-installation-dropdown-action'
  browser.all('#show-delete-installation-modal-action').any?
end
delete_product(product_name) click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 43
def delete_product(product_name)
  open_dashboard
  disable_css_transitions!
  browser.click_on "open-delete-#{product_name.dasherize}-modal"
  browser.click_on "delete-#{product_name.dasherize}-action"
end
delete_whole_installation() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 74
def delete_whole_installation
  open_dashboard
  browser.click_on 'toggle-installation-dropdown-action'
  disable_css_transitions!
  browser.click_on 'show-delete-installation-modal-action'
  browser.click_on 'delete-installation-action'
  apply_updates
end
deletion_in_progress?() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 96
def deletion_in_progress?
  open_dashboard
  browser.all('#delete-in-progress-marker').any?
end
import_installation_file(file_path) click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 29
def import_installation_file(file_path)
  open_dashboard
  browser.click_on 'toggle-installation-dropdown-action'
  browser.click_on 'show-import-backup'
  browser.attach_file 'import[file]', file_path
  browser.click_on 'import-backup'
end
import_product_from(full_path) click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 50
def import_product_from(full_path)
  open_dashboard
  browser.attach_file('component_add[file]', full_path, {visible: false})

  browser.expect(browser.page).to browser.have_text('Successfully added product')
end
product_available?(product_name, product_version) click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 57
def product_available?(product_name, product_version)
  open_dashboard
  browser.all("li.#{product_name} input#component_version[value='#{product_version}']", {visible: false}).any?
end
product_configuration_percentage(product_name) click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 123
def product_configuration_percentage(product_name)
  open_dashboard
  browser.find("#show-#{product_name}-configure-action")['data-progress'].to_i
end
reset_state(ops_manager) click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 101
def reset_state(ops_manager)
  revert_pending_changes if revert_available?
  if delete_installation_available?
    delete_whole_installation
    browser.poll_up_to_mins(15) do
      browser.expect(ops_manager.state_change_progress).to browser.be_state_change_success
    end
  end
end
revert_available?() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 118
def revert_available?
  open_dashboard
  browser.all('#open-revert-installation-modal-action').any?
end
revert_pending_changes() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 111
def revert_pending_changes
  open_dashboard
  disable_css_transitions!
  browser.click_on 'open-revert-installation-modal-action'
  browser.click_on 'revert-installation-action'
end
upgrade_microbosh() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 37
def upgrade_microbosh
  open_dashboard
  browser.find('p', text: 'Ops Manager Director').trigger(:mouseover)
  browser.click_on 'upgrade-microbosh'
end
upgrade_product(product_name) click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 62
def upgrade_product(product_name)
  open_dashboard
  browser.find(".product.#{product_name} p").trigger(:mouseover)
  browser.click_on "upgrade-#{product_name}"
  expect_no_flash_errors
end
version_for_product(product_name) click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 69
def version_for_product(product_name)
  open_dashboard
  browser.find("#show-#{product_name}-configure-action .version").text
end
wait_for_installation_to_be_deleted() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 83
def wait_for_installation_to_be_deleted
  browser.poll_up_to_mins(10) do
    open_dashboard
    assert_install_action_disabled
  end
end

Private Instance Methods

allow_cpu_verification_errors() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 151
def allow_cpu_verification_errors
  return if @allowed_ignorable_errors.include?(/Installation requires \d+ CPU cores/)

  @allowed_ignorable_errors << /Installation requires \d+ CPU cores/
end
allow_icmp_verification_errors() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 163
def allow_icmp_verification_errors
  return if @allowed_ignorable_errors.include?(/ignorable if ICMP is disabled/i)

  @allowed_ignorable_errors << /ignorable if ICMP is disabled/i
end
allow_privilege_verification_errors() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 157
def allow_privilege_verification_errors
  return if @allowed_ignorable_errors.include?(/required privileges/i)

  @allowed_ignorable_errors << /required privileges/i
end
assert_install_action_disabled() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 132
def assert_install_action_disabled
  browser.expect(browser.page).to browser.have_css('#install-action.disabled')
end
assert_installation_started() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 136
def assert_installation_started
  browser.expect(browser.page).to browser.have_text(/applying changes/i)
end
expect_no_flash_errors() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 183
def expect_no_flash_errors
  if (flash_error = browser.all('.flash-message.error').first)
    fail flash_error.text
  end
end
ignore_allowable_errors() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 169
def ignore_allowable_errors
  flash_errors = browser.all('.flash-message.error')

  if flash_errors.any?
    unexpected_errors = flash_errors.reject do |error|
      @allowed_ignorable_errors.select do |expected_error|
        error.text =~ expected_error
      end.any?
    end

    browser.click_on 'ignore-install-action' if unexpected_errors.empty?
  end
end
nonignorable_verification_failed?() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 140
def nonignorable_verification_failed?
  result = browser.all('.flash-message.error').any? && browser.all('#ignore-install-action').empty?
  if result
    Logger.debug 'flash message errors; we expect these to be empty'
    Logger.debug browser.all('.flash-message.error').inspect
    Logger.debug 'ignore install action; we expect there to be one of these'
    Logger.debug browser.all('#ignore-install-action').inspect
  end
  result
end
open_dashboard() click to toggle source
# File lib/ops_manager_ui_drivers/version14/product_dashboard.rb, line 189
def open_dashboard
  browser.visit '/'
end