Class: OpsManagerUiDrivers::Version17::BoshProductSections::Networks

Inherits:
Object
  • Object
show all
Defined in:
lib/ops_manager_ui_drivers/version17/bosh_product_sections/networks.rb

Constant Summary collapse

FLASH_MESSAGE_CLASS =
'.flash-message'.freeze
FLASH_MESSAGE_ERRORS =
'.flash-message.error ul.message li'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(browser:) ⇒ Networks

Returns a new instance of Networks.



8
9
10
11
# File 'lib/ops_manager_ui_drivers/version17/bosh_product_sections/networks.rb', line 8

def initialize(browser:)
  @browser                   = browser
  @bosh_product_form_section = BoshProductFormSection.new(@browser, 'network_collection[networks_attributes][0]')
end

Instance Method Details

#add_network(name:, subnets:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ops_manager_ui_drivers/version17/bosh_product_sections/networks.rb', line 13

def add_network(name:, subnets:)
  @bosh_product_form_section.open_form('network')

  @browser.click_on 'Add Network'
  @bosh_product_form_section.set_fields('name' => name)

  subnets.each_with_index do |subnet, index|
    subnet_section = Subnet.new(browser: @browser, network_form: @bosh_product_form_section, subnet_index: index)
    subnet_section.add_subnet(**subnet.symbolize_keys)
  end


  @browser.click_on 'Save'
  @browser.expect(@browser.page).to @browser.have_css(FLASH_MESSAGE_CLASS)
  flash_errors = @browser.all(FLASH_MESSAGE_ERRORS).to_a
  flash_errors.reject! { |node| node.text =~ /cannot reach gateway/i }

  if (flash_errors.length > 0)
    fail flash_errors.collect(&:text).inspect
  end
end

#configure_icmp_checks(enabled) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ops_manager_ui_drivers/version17/bosh_product_sections/networks.rb', line 44

def configure_icmp_checks(enabled)
  @bosh_product_form_section.open_form('network')

  if enabled
    @browser.check 'Enable ICMP checks'
  else
    @browser.uncheck 'Enable ICMP checks'
  end

  @bosh_product_form_section.save_form
end

#delete_network(network_name) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/ops_manager_ui_drivers/version17/bosh_product_sections/networks.rb', line 35

def delete_network(network_name)
  @bosh_product_form_section.open_form('network')
  button = @browser.find('button', text: network_name)
  button.click
  button.find(:xpath, '..').first('.with-delete-record').trigger('click')

  @bosh_product_form_section.save_form
end