discourse/spec/system/page_objects/pages/admin_email_templates.rb
Martin Brennan e149be736b
FIX: Force composer markdown mode in email template editing (#34668)
For now, we want to force the markdown mode for email template
editing for admins, as this is a niche area and doesn't much
benefit from RTE for now...we may want to revert this decision
in future and do a better solution here.

This commit also fixes an issue where, for templates like
system_messages.reviewables_reminder which have a `one` and
`other` key for their text body (and thus "multiple bodies"),
we were showing `object Object` in the editor. Instead, we
want to do the same thing we do for multiple subjects, which
is provide a link to site texts with the text:

> This email template has multiple bodies.

There is only one known case of this happening so far, but at least
this minimally handles the issue for now.
2025-09-24 14:28:28 +10:00

63 lines
1.6 KiB
Ruby
Vendored

# frozen_string_literal: true
module PageObjects
module Pages
class AdminEmailTemplates < PageObjects::Pages::AdminBase
def visit
page.visit("/admin/email/templates")
self
end
def visit_template(template_id)
page.visit("/admin/email/templates/#{template_id}")
self
end
def has_template?(template_name)
has_css?("td", text: template_name)
end
def click_template(template_name)
find("td", text: template_name).click
self
end
def edit_subject(text)
find("input.email-template__subject").fill_in(with: text)
self
end
def has_subject_value?(value)
try_until_success { expect(find("input.email-template__subject").value).to eq(value) }
end
def edit_body(text)
find(".d-editor-input").fill_in(with: text)
self
end
def has_preview_content?(text)
has_css?(".d-editor-preview", text: text)
end
def save_changes
find(".save-changes").click
self
end
def has_multiple_subjects_link?(href)
link = find(".email-template__has-multiple-subjects")
expect(link[:href]).to eq(href)
expect(link.text).to eq(
I18n.t("admin_js.admin.customize.email_templates.multiple_subjects"),
)
end
def has_multiple_bodies_link?(href)
link = find(".email-template__has-multiple-bodies")
expect(link[:href]).to eq(href)
expect(link.text).to eq(I18n.t("admin_js.admin.customize.email_templates.multiple_bodies"))
end
end
end
end