2023-02-09 03:21:39 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PageObjects
|
|
|
|
module Pages
|
|
|
|
class FormTemplate < PageObjects::Pages::Base
|
|
|
|
# Form Template Index
|
|
|
|
def has_form_template_table?
|
2023-03-02 03:07:13 +08:00
|
|
|
page.has_selector?("table.form-templates__table")
|
2023-02-09 03:21:39 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def click_view_form_template
|
2023-03-02 03:07:13 +08:00
|
|
|
find(".form-templates__table tr:first-child .btn-view-template").click
|
|
|
|
end
|
|
|
|
|
|
|
|
def click_toggle_preview
|
|
|
|
find(".d-toggle-switch .d-toggle-switch__checkbox-slider", visible: false).click
|
|
|
|
self
|
2023-02-09 03:21:39 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_form_template?(name)
|
2023-03-02 03:07:13 +08:00
|
|
|
find(".form-templates__table tbody tr td", text: name).present?
|
2023-02-09 03:21:39 +08:00
|
|
|
end
|
|
|
|
|
2023-03-02 04:37:14 +08:00
|
|
|
def has_category_in_template_row?(category_name)
|
|
|
|
find(".form-templates__table .categories .category-name", text: category_name).present?
|
|
|
|
end
|
|
|
|
|
2023-02-09 03:21:39 +08:00
|
|
|
def has_template_structure?(structure)
|
|
|
|
find("code", text: structure).present?
|
|
|
|
end
|
|
|
|
|
|
|
|
# Form Template new/edit form related
|
|
|
|
def type_in_template_name(input)
|
2023-05-31 02:37:32 +08:00
|
|
|
find(".form-templates__form-name-input").fill_in(with: input)
|
2023-02-09 03:21:39 +08:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def click_save_button
|
2023-05-28 20:14:25 +08:00
|
|
|
find(".form-templates__form .footer-buttons .btn-primary:enabled", visible: :all).click
|
2023-02-09 03:21:39 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def click_quick_insert(field_type)
|
2023-03-02 03:07:13 +08:00
|
|
|
find(".form-templates__form .quick-insert-#{field_type}").click
|
|
|
|
end
|
|
|
|
|
|
|
|
def click_validations_button
|
|
|
|
find(".form-templates__validations-modal-button").click
|
|
|
|
end
|
|
|
|
|
|
|
|
def click_preview_button
|
2023-05-28 20:15:02 +08:00
|
|
|
find(".form-templates__preview-button:enabled").click
|
2023-03-02 03:07:13 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_input_field?(type)
|
|
|
|
find(".form-template-field__#{type}").present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_preview_modal?
|
|
|
|
find(".form-template-form-preview-modal").present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_validations_modal?
|
|
|
|
find(".admin-form-template-validation-options-modal").present?
|
2023-02-09 03:21:39 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_name_value?(name)
|
2023-03-02 03:07:13 +08:00
|
|
|
find(".form-templates__form-name-input").value == name
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_save_button_with_state?(state)
|
|
|
|
find_button("Save", disabled: state)
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_preview_button_with_state?(state)
|
|
|
|
find_button("Preview", disabled: state)
|
2023-02-09 03:21:39 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|