Given(/^a user named (\w+) with (?:a|an) (MyTeachable|old) account with (\d+|many) schools?$/) do |name, account_type, num_schools|
  @context.given_user(name, account_type, num_schools)
end

Given(/^checks the "(.*?)" box$/) do |box_text|
  check(box_text)
end

Given("Non login user visit {string}") do |page|
  if page.eql? "homepage"
    @context.visit_page("/")
  else
    @context.visit_page(page)
  end
end

When(/selects "([^"]+)" from the dropdown/) do |school_name|
  find('#modal_login_school_list').find(:option, school_name).select_option
end

When(/selects a school from the dropdown/) do
  find('#modal_login_school_list').click
end

When(/^he logs out of the app$/) do
  @context.log_out_of_fedora
end

When(/^closes the cookie banner/) do
  banner_x = find(".cookie-banner button img")
  banner_x.click if banner_x
end

When(/^closes the myTeachable account modal$/) do
  sleep 1
  if find_all(".modal-header").size > 0
    within(".modal-header") { find("span").click }
  end
end
