Given(/^I am on the OA::ViewCustomerMasterPage for DMS (.*)$/) do |dms|
  visit(
    OA::ViewCustomerMaster,
    using_params: { queries: { "customer_master_master_id" => dms } }
  )
end

Given(/^DMS has no specs$/) do
  on(OA::ViewCustomerMaster) do |page|
    page.spec_panelcontent_element.when_present
    page.delete_all_specs
  end
end

When(/^I add a new image spec$/) do
  on(OA::ViewCustomerMaster) do |page|
    @spec_info_data = {
      product_type: "Music",
      encoding_order_type: "Tone",
      profile_type: "Image",
      format: "standard jpg",
      required: "Yes",
      filename: "Watir Test#{Time.stamp}",
      delivery_location: "Watir Location#{Time.stamp}"
    }
    page.populate_spec_fields(@spec_info_data)
  end
end

Then(/^I should see the newly added Spec on the view customer master page and on the edit popup$/) do
  on(OA::ViewCustomerMaster) do |page|
    page.check_populated_spec_data(@spec_info_data)
    page.verify_populated_spec_fields(@spec_info_data)
  end
end

When(/^I edit existing server and save$/) do
  @server_info_data = DataHelpers::DmsCustomerData.server_info_data
  on(OA::ViewCustomerMaster) do |page|
    page.populate_server_info_fields(@server_info_data)
    page.submit_server
  end
end

Then(/^I should see the updated server on the view customer master page and on the edit popup$/) do
  on(OA::ViewCustomerMaster) do |page|
    page.edit_server_elements[0].when_present
    page.verify_server_info_on_table(@server_info_data)
    page.verify_server_info_on_form(@server_info_data)
  end
end
