module Project
  class BasePage < UniversalPage
    include PageHelpers::ReactHelpers

    react_select_or_create(:new_project_artist) { div_element(id: "project-artist-select-and-add-new") }
    # project pages scroll to the top when they are loaded. this is slightly
    # delayed, so we need to wait for it to finish before doing anything.
    # See PHYS-653
    def wait_for_page_to_scroll_to_top
      # TODO: Come up with a more deterministic way to do this
      sleep 2
    end

    def product_id_from_url
      url_match = current_url.match(%r{/project/.*/product/(\d+)/})
      fail "Couldn't find product_id from URL!" unless url_match
      url_match[1]
    end
  end
end
