FIX: Customize form template view modal footer buttons (#25804)

This commit is contained in:
Keegan George 2024-02-21 22:20:56 -08:00 committed by GitHub
parent 867c2989d7
commit 3b87a174e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 3 deletions

View File

@ -18,17 +18,20 @@ export default class CustomizeFormTemplateViewModal extends Component {
@action
editTemplate() {
this.router.transitionTo("adminCustomizeFormTemplates.edit", this.model);
this.router.transitionTo(
"adminCustomizeFormTemplates.edit",
this.args.model
);
}
@action
deleteTemplate() {
return this.dialog.yesNoConfirm({
message: I18n.t("admin.form_templates.delete_confirm", {
template_name: this.model.name,
template_name: this.args.model.name,
}),
didConfirm: () => {
ajax(`/admin/customize/form-templates/${this.model.id}.json`, {
ajax(`/admin/customize/form-templates/${this.args.model.id}.json`, {
type: "DELETE",
})
.then(() => {

View File

@ -44,6 +44,25 @@ describe "Admin Customize Form Templates", type: :system do
form_template_page.click_toggle_preview
expect(form_template_page).to have_input_field("input")
end
context "when using the view template modal" do
it "should navigate to the edit page when clicking the edit button" do
form_template_page.visit
form_template_page.click_view_form_template
form_template_page.find(".d-modal__footer .btn-primary").click
expect(page).to have_current_path("/admin/customize/form-templates/#{form_template.id}")
end
it "should delete the form template when clicking the delete button" do
form_template_page.visit
original_template_name = form_template.name
form_template_page.click_view_form_template
form_template_page.find(".d-modal__footer .btn-danger").click
form_template_page.find(".dialog-footer .btn-primary").click
expect(form_template_page).to have_no_form_template(original_template_name)
end
end
end
describe "when visiting the page to edit a form template" do

View File

@ -31,6 +31,10 @@ module PageObjects
find(".form-templates__table tbody tr td", text: name).present?
end
def has_no_form_template?(name)
has_no_css?(".form-templates__table tbody tr td", text: name)
end
def has_category_in_template_row?(category_name)
find(
".form-templates__table .categories .badge-category__name",