module BlacklistManager
  class BlacklistManagerPage < OA::BasePage
    page_url "/"

    div(:success_alert, class: "alert-success")

    text_field(:add_word_entry, name: "word")
    text_field(:notes, name: "notes")
    button(:add_word, text: "Submit")
    text_field(:search_word_entry, class: "BlacklistSearch-input-field")
    button(:search_word, text: "Search")
    spans(:reason, class: "BlacklistReasonDropdown-reasons")
    elements(:delete_word, class: "Icons-trash-can")
    spans(:table_span, class: "BlacklistTable-table-data-placeholder")
    span(:word_cell) { table_span_elements[0] }
    span(:notes_cell) { table_span_elements[1] }
    span(:reason_cell) { table_span_elements[2] }
    span(:date_added_cell) { table_span_elements[3] }
    div(:spinner, class: "BlacklistManager-loader-container")

    def empty_word_cell(number_of_chars)
      # clearing the field can be very finnicky over the grid - this nukes it from orbit, only way to be sure
      word_cell_element.parent.text_field.send_keys Array.new(number_of_chars, :backspace)
      word_cell_element.parent.text_field.send_keys Array.new(number_of_chars, :delete)
      word_cell_element.parent.text_field.send_keys Array.new(number_of_chars, :backspace)
    end
  end
end
