mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 08:33:37 +08:00
2b3a572987
Why this change? Some of the tests in `spec/system/table_builder_spec.rb` are flaky when we are asserting that clicking the cancel button will close the modal. This change attempts to fix it by using the `click_button` method instead of `find` then `click` which is more reliable.
45 lines
1.1 KiB
Ruby
45 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Modals
|
|
class InsertTable < PageObjects::Modals::Base
|
|
MODAL_SELECTOR = ".insert-table-modal"
|
|
SPREADSHEET_TABLE_SELECTOR = "#{MODAL_SELECTOR} .jexcel"
|
|
|
|
def click_insert_table
|
|
find("#{MODAL_SELECTOR} .btn-insert-table").click
|
|
end
|
|
|
|
def cancel
|
|
click_button(I18n.t("js.cancel"))
|
|
end
|
|
|
|
def click_edit_reason
|
|
find("#{MODAL_SELECTOR} .btn-edit-reason").click
|
|
end
|
|
|
|
def type_edit_reason(text)
|
|
find("#{MODAL_SELECTOR} .edit-reason input").send_keys(text)
|
|
end
|
|
|
|
def find_cell(row, col)
|
|
find("#{SPREADSHEET_TABLE_SELECTOR} tbody tr[data-y='#{row}'] td[data-x='#{col}']")
|
|
end
|
|
|
|
def select_cell(row, col)
|
|
find_cell(row, col).double_click
|
|
end
|
|
|
|
def type_in_cell(row, col, text)
|
|
select_cell(row, col)
|
|
cell = find_cell(row, col).find("textarea")
|
|
cell.send_keys(text, :return)
|
|
end
|
|
|
|
def has_content_in_cell?(row, col, content)
|
|
find_cell(row, col).text == content
|
|
end
|
|
end
|
|
end
|
|
end
|