A platform for community discussion. Free, open, simple.
FEATURE: Implement tag group selection in dropdown and multi-select for topic creation and preview when using Form Templates (#32108)
Juan David Martínez Cubillos72f9714ddc62
diff --git a/app/assets/javascripts/admin/addon/components/form-template/form.gjs b/app/assets/javascripts/admin/addon/components/form-template/form.gjsindex 149120c112b..e616c3846bb 100644--- a/app/assets/javascripts/admin/addon/components/form-template/form.gjs+++ b/app/assets/javascripts/admin/addon/components/form-template/form.gjs@@ -49,6 +49,10 @@ export default class FormTemplateForm extends Component {type: "multiselect",icon: "bullseye",},+ {+ type: "tagchooser",+ icon: "bullseye",+ },];get disablePreviewButton() {diff --git a/app/assets/javascripts/admin/addon/lib/template-form-fields.js b/app/assets/javascripts/admin/addon/lib/template-form-fields.jsindex 4762f7ea8e9..56a50e9ccee 100644--- a/app/assets/javascripts/admin/addon/lib/template-form-fields.js+++ b/app/assets/javascripts/admin/addon/lib/template-form-fields.js@@ -73,4 +73,16 @@ export const templateFormFields = [validations:# ${i18n("admin.form_templates.field_placeholders.validations")}`,},+ {+ type: "tagchooser",+ structure: `- type: tag-chooser+ id: ${i18n("admin.form_templates.field_placeholders.id")}+ tag_group: ""+ attributes:+ none_label: "${i18n("admin.form_templates.field_placeholders.none_label")}"+ label: "${i18n("admin.form_templates.field_placeholders.label")}"+ multiple: true+ validations:+ # ${i18n("admin.form_templates.field_placeholders.validations")}`,+ },];diff --git a/app/assets/javascripts/discourse/app/components/composer-editor.gjs b/app/assets/javascripts/discourse/app/components/composer-editor.gjsindex ebe5dea7d22..aed0d4b2c48 100644--- a/app/assets/javascripts/discourse/app/components/composer-editor.gjs+++ b/app/assets/javascripts/discourse/app/components/composer-editor.gjs@@ -948,18 +948,17 @@ export default class ComposerEditor extends Component {}@action- async updatePreviewFromForm() {+ async updateFormPreview() {const formTemplateData = prepareFormTemplateData(document.querySelector("#form-template-form"),- this.composer.selectedFormTemplate+ this.composer.selectedFormTemplate,+ false);- if (formTemplateData) {- this.preview = await this.cachedCookAsync(- formTemplateData,- this.markdownOptions- );- }+ this.preview = await this.cachedCookAsync(+ formTemplateData,+ this.markdownOptions+ );}async cachedCookAsync(text, options) {@@ -1006,7 +1005,7 @@ export default class ComposerEditor extends Component {@id={{this.selectedFormTemplateId}}@initialValues={{this.composer.formTemplateInitialValues}}@onSelectFormTemplate={{this.composer.onSelectFormTemplate}}- @onChange={{this.updatePreviewFromForm}}+ @onChange={{this.updateFormPreview}}/></form></div>diff --git a/app/assets/javascripts/discourse/app/components/d-editor.gjs b/app/assets/javascripts/discourse/app/components/d-editor.gjsindex 805ad912769..f3530ffd2f9 100644--- a/app/assets/javascripts/discourse/app/components/d-editor.gjs+++ b/app/assets/javascripts/discourse/app/components/d-editor.gjs@@ -30,7 +30,6 @@ import deprecated from "discourse/lib/deprecated";import { isTesting } from "discourse/lib/environment";import { getRegister } from "discourse/lib/get-owner";import { hashtagAutocompleteOptions } from "discourse/lib/hashtag-autocomplete";-import { wantsNewWindow } from "discourse/lib/intercept-click";import { PLATFORM_KEY_MODIFIER } from "discourse/lib/keyboard-shortcuts";import loadEmojiSearchAliases from "discourse/lib/load-emoji-search-aliases";import loadRichEditor from "discourse/lib/load-rich-editor";@@ -162,38 +161,6 @@ export default class DEditor extends Component {return keymap;}- @action- handlePreviewClick(event) {- if (!event.target.closest(".d-editor-preview")) {- return;- }-- if (wantsNewWindow(event)) {- return;- }-- if (event.target.tagName === "A") {- if (event.target.classList.contains("mention")) {- this.appEvents.trigger(- "d-editor:preview-click-user-card",- event.target,- event- );- }-- if (event.target.classList.contains("mention-group")) {- this.appEvents.trigger(- "d-editor:preview-click-group-card",- event.target,- event- );- }-- event.preventDefault();- return false;- }- }-@onEvent("willDestroyElement")_shutDown() {this._previewMutationObserver?.disconnect();@@ -812,7 +779,6 @@ export default class DEditor extends Component {/></div></div>-<DEditorPreview@preview={{this.preview}}@forcePreview={{this.forcePreview}}diff --git a/app/assets/javascripts/discourse/app/components/form-template-field/tag-chooser.gjs b/app/assets/javascripts/discourse/app/components/form-template-field/tag-chooser.gjsnew file mode 100644index 00000000000..f372260f33b--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/form-template-field/tag-chooser.gjs@@ -0,0 +1,174 @@+import Component from "@glimmer/component";+import { on } from "@ember/modifier";+import { action, set } from "@ember/object";+import didInsert from "@ember/render-modifiers/modifiers/did-insert";+import didUpdate from "@ember/render-modifiers/modifiers/did-update";+import { next } from "@ember/runloop";+import { service } from "@ember/service";+import { htmlSafe } from "@ember/template";+import { not } from "truth-helpers";+import icon from "discourse/helpers/d-icon";+import { i18n } from "discourse-i18n";++export default class TagChooserField extends Component {+ @service composer;+ @service dialog;++ get formattedChoices() {+ return this.args.choices.map((choice) => ({+ name: choice,+ display: this.args.attributes.tag_choices[choice]+ ? this.args.attributes.tag_choices[choice]+ : choice.replace(/-/g, " ").toUpperCase(),+ }));+ }++ get filteredSelectedValues() {+ return this.tags.filter((tag) =>+ this.formattedChoices.some((choice) => choice.name === tag)+ );+ }++ get selectedTags() {+ return this.tags.filter((tag) => this.args.choices.includes(tag));+ }++ @action+ dropdownSyncWithComposerTags() {+ if (!this.args.onChange) {+ return;+ }++ if (this.selectedTags.length > 1) {+ // the composer mini tag chooser can allow multiple tags+ // so if the user chooses multiple tags directly in this component+ // we will display an error to prevent it+ this.dialog.alert(+ i18n("admin.form_templates.errors.multiple_tags_not_allowed", {+ tag_name: this.args.attributes.tag_group,+ })+ );++ const selectedTags = [+ ...this.tags.filter((tag) => !this.selectedTags.includes(tag)),+ ];++ // the next is needed because we already updated the tags in the same runloop+ // when the user selected a tag in the composer directly+ next(() => {+ set(this.composer.model, "tags", selectedTags);+ this.args.onChange([]);+ });+ } else {+ this.args.onChange(this.tags);+ }+ }++ get tags() {+ return this.composer.get("model.tags") || [];+ }++ @action+ syncWithComposerTags() {+ if (this.args.attributes.multiple) {+ this.args.onChange?.(this.tags);+ } else {+ this.dropdownSyncWithComposerTags();+ }+ }++ @action+ handleSelectedValues(event) {+ const getFallbackValue = (optionValue) =>+ optionValue.toLowerCase().replace(/\s+/g, "-");+ let choiceMap = null;+ const tagChoices = this.args.attributes.tag_choices;++ if (tagChoices) {+ choiceMap = new Map(+ Object.entries(tagChoices).map(([key, value]) => [value, key])+ );+ }++ const selectedValues = Array.from(event.target.selectedOptions).map(+ (option) => {+ const mappedValue = choiceMap?.get(option.textContent.trim());+ return mappedValue ?? getFallbackValue(option.value);+ }+ );++ return selectedValues;+ }++ @action+ handleInput(event) {+ const selectedValues = this.handleSelectedValues(event);+ const validChoices = this.formattedChoices.map((choice) => choice.name);+ const selectedTags = selectedValues.filter((tag) =>+ validChoices.includes(tag)+ );++ set(+ this.composer.model,+ "tags",+ [+ ...this.tags.filter((tag) => !this.selectedTags.includes(tag)),+ ...selectedTags,+ ].uniq()+ );+ }++ @action+ isSelected(option) {+ option = option.toLowerCase().replace(/\s+/g, "-");+ return this.filteredSelectedValues.includes(option);+ }++ <template>+ <div+ data-field-type="multi-select"+ class="control-group form-template-field"+ {{didInsert this.syncWithComposerTags}}+ {{! not ideal but we would need a lot of re-architecturing to make the form dynamic }}+ {{didUpdate this.syncWithComposerTags this.composer.model.tags}}+ >+ {{#if @attributes.label}}+ <label class="form-template-field__label">+ {{@attributes.label}}+ {{#if @validations.required}}+ {{icon "asterisk" class="form-template-field__required-indicator"}}+ {{/if}}+ </label>+ {{/if}}++ {{#if @attributes.description}}+ <span class="form-template-field__description">+ {{htmlSafe @attributes.description}}+ </span>+ {{/if}}++ <select+ name={{@id}}+ required={{if @validations.required "required" ""}}+ multiple={{@attributes.multiple}}+ class="form-template-field__multi-select"+ {{on "input" this.handleInput}}+ >+ {{#if @attributes.none_label}}+ <option+ class="form-template-field__multi-select-placeholder"+ value=""+ disabled={{not this.selectedTags.length}}+ selected={{if this.selectedTags.length "" "selected"}}+ >{{@attributes.none_label}}</option>+ {{/if}}+ {{#each this.formattedChoices as |choice|}}+ <option+ value={{choice.display}}+ selected={{this.isSelected choice.name}}+ >{{choice.display}}</option>+ {{/each}}+ </select>+ </div>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/form-template-field/upload.gjs b/app/assets/javascripts/discourse/app/components/form-template-field/upload.gjsindex bc5db04905d..26a16ab25d8 100644--- a/app/assets/javascripts/discourse/app/components/form-template-field/upload.gjs+++ b/app/assets/javascripts/discourse/app/components/form-template-field/upload.gjs@@ -13,9 +13,9 @@ import UppyUpload from "discourse/lib/uppy/uppy-upload";export default class FormTemplateFieldUpload extends Component {@tracked uploadValue;@tracked uploadedFiles = [];+ @tracked fileInputSelector = `#${this.fileUploadElementId}`;@trackedfileUploadElementId = `${dasherize(this.args.id.toString())}-uploader`;- @tracked fileInputSelector = `#${this.fileUploadElementId}`;uppyUpload = new UppyUpload(getOwner(this), {id: this.args.id,diff --git a/app/assets/javascripts/discourse/app/components/form-template-field/wrapper.gjs b/app/assets/javascripts/discourse/app/components/form-template-field/wrapper.gjsindex 127ad39ee36..8b0283a43ed 100644--- a/app/assets/javascripts/discourse/app/components/form-template-field/wrapper.gjs+++ b/app/assets/javascripts/discourse/app/components/form-template-field/wrapper.gjs@@ -10,6 +10,7 @@ import CheckboxField from "./checkbox";import DropdownField from "./dropdown";import InputField from "./input";import MultiSelectField from "./multi-select";+import TagChooserField from "./tag-chooser";import TextareaField from "./textarea";import UploadField from "./upload";@@ -39,6 +40,7 @@ export default class FormTemplateFieldWrapper extends Component {dropdown: DropdownField,"multi-select": MultiSelectField,textarea: TextareaField,+ "tag-chooser": TagChooserField,upload: UploadField,};diff --git a/app/assets/javascripts/discourse/app/lib/form-template-validation.js b/app/assets/javascripts/discourse/app/lib/form-template-validation.jsindex 2270d301b5c..4c48ec53129 100644--- a/app/assets/javascripts/discourse/app/lib/form-template-validation.js+++ b/app/assets/javascripts/discourse/app/lib/form-template-validation.js@@ -11,7 +11,11 @@ export function getFormTemplateObject(form) {return formObject;}-export default function prepareFormTemplateData(form, formTemplate) {+export default function prepareFormTemplateData(+ form,+ formTemplate,+ checkFormValidity = true+) {const labelMap = formTemplate.reduce((acc, field) => {acc[field.id] = field.attributes.label;return acc;@@ -20,9 +24,11 @@ export default function prepareFormTemplateData(form, formTemplate) {const formData = new FormData(form);// Validate the form template- _validateFormTemplateData(form);- if (!form.checkValidity()) {- return false;+ if (checkFormValidity) {+ _validateFormTemplateData(form);+ if (!form.checkValidity()) {+ return false;+ }}// Gather form template datadiff --git a/app/controllers/form_templates_controller.rb b/app/controllers/form_templates_controller.rbindex 8a8d3865c7a..de3fc0912e2 100644--- a/app/controllers/form_templates_controller.rb+++ b/app/controllers/form_templates_controller.rb@@ -13,8 +13,11 @@ class FormTemplatesController < ApplicationControllerparams.require(:id)template = FormTemplate.find_by(id: params[:id])+raise Discourse::NotFound if template.nil?+ template.template = process_template(template.template)+render_serialized(template, FormTemplateSerializer, root: "form_template")end@@ -23,4 +26,40 @@ class FormTemplatesController < ApplicationControllerdef ensure_form_templates_enabledraise Discourse::InvalidAccess.new unless SiteSetting.experimental_form_templatesend++ def process_template(template_content)+ parsed_template = YAML.safe_load(template_content)++ tag_group_names = parsed_template.map { |f| f["tag_group"] }.compact.map(&:downcase).uniq++ tag_groups =+ TagGroup+ .includes(:tags)+ .visible(guardian)+ .where("lower(name) IN (?)", tag_group_names)+ .index_by { |tg| tg.name }++ parsed_template.map! do |form_field|+ next form_field unless form_field["tag_group"]++ tag_group_name = form_field["tag_group"]+ tags = tag_groups[tag_group_name].tags+ ordered_field = {}++ form_field.each do |key, value|+ ordered_field[key] = value++ ordered_field["choices"] = tags.map(&:name) if key == "id"+ if key == "attributes"+ ordered_field["attributes"]["tag_group"] = tag_group_name+ translated_tags = tags.select { |t| t.description }.to_h { |t| [t.name, t.description] }+ ordered_field["attributes"]["tag_choices"] = translated_tags+ end+ end++ ordered_field+ end++ YAML.dump(parsed_template)+ endenddiff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 836b8635a5f..3a3a5d4b984 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -7112,6 +7112,7 @@ en:dropdown: "Dropdown"upload: "Upload a file"multiselect: "Multiple choice"+ tagchooser: "Tag Group selector"validations_modal:button_title: "Validations"modal_title: "Validation Options"@@ -7157,6 +7158,8 @@ en:toggle_form_template: "form template enabled"select_template: "Select form templates"select_template_help: "Add/Edit Form Templates"+ errors:+ multiple_tags_not_allowed: 'You can''t select more tags from the "%{tag_name}". To avoid issues, use Form Template'impersonate:title: "Impersonate"diff --git a/lib/validators/form_template_yaml_validator.rb b/lib/validators/form_template_yaml_validator.rbindex 15a1c127624..ae230451eaa 100644--- a/lib/validators/form_template_yaml_validator.rb+++ b/lib/validators/form_template_yaml_validator.rb@@ -2,7 +2,7 @@class FormTemplateYamlValidator < ActiveModel::ValidatorRESERVED_KEYWORDS = %w[title body category category_id tags]- ALLOWED_TYPES = %w[checkbox dropdown input multi-select textarea upload]+ ALLOWED_TYPES = %w[checkbox dropdown input multi-select textarea upload tag-chooser]HTML_SANITIZATION_OPTIONS = {elements: ["a"],attributes: {diff --git a/spec/fabricators/form_template_fabricator.rb b/spec/fabricators/form_template_fabricator.rbindex adeceeb3d8c..8dbd5ba8761 100644--- a/spec/fabricators/form_template_fabricator.rb+++ b/spec/fabricators/form_template_fabricator.rb@@ -2,6 +2,6 @@Fabricator(:form_template) doname { sequence(:name) { |i| "template_#{i}" } }- template "- type: input- id: name"+ template "---\n- type: input+ id: name\n"enddiff --git a/spec/fabricators/tag_fabricator.rb b/spec/fabricators/tag_fabricator.rbindex 6d68de48f4d..98d20075fb9 100644--- a/spec/fabricators/tag_fabricator.rb+++ b/spec/fabricators/tag_fabricator.rb@@ -1,3 +1,6 @@# frozen_string_literal: true-Fabricator(:tag) { name { sequence(:name) { |i| "tag#{i + 1}" } } }+Fabricator(:tag) do+ name { sequence(:name) { |i| "tag#{i + 1}" } }+ description nil+enddiff --git a/spec/requests/form_templates_controller_spec.rb b/spec/requests/form_templates_controller_spec.rbindex 85920fd568f..957d7d23f56 100644--- a/spec/requests/form_templates_controller_spec.rb+++ b/spec/requests/form_templates_controller_spec.rb@@ -62,6 +62,69 @@ RSpec.describe FormTemplatesController doexpect(current_template["name"]).to eq(form_template.name)expect(current_template["template"]).to eq(form_template.template)end++ context "when using tag groups in a form template" do+ fab!(:tag1) { Fabricate(:tag, description: "Tag 1 custom Translation") }+ fab!(:tag2) { Fabricate(:tag, description: "Tag 2 custom Translation") }+ fab!(:tag3) { Fabricate(:tag) }+ fab!(:tag4) { Fabricate(:tag) }++ fab!(:tag_group1) { Fabricate(:tag_group, name: "tag_group1", tags: [tag1, tag3]) }+ fab!(:tag_group2) { Fabricate(:tag_group, name: "tag_group2", tags: [tag2, tag4]) }++ fab!(:tag_groups_form_template) do+ Fabricate(+ :form_template,+ name: "TagGroups",+ template:+ %Q(+ - type: tag-chooser+ id: 1+ attributes:+ label: "Full name"+ description: "What is your full name?"+ multiple: true+ tag_group: "tag_group1" # Replace with actual value if needed+ validations:+ required: false++ - type: tag-chooser+ id: 2+ attributes:+ label: "Prescription"+ description: "Upload your prescription"+ multiple: false+ tag_group: "tag_group2"+ validations:+ required: true),+ )+ end++ it "should return a single template with the correct data" do+ get "/form-templates/#{tag_groups_form_template.id}.json"+ expect(response.status).to eq(200)+ json = response.parsed_body++ current_template = json["form_template"]+ parsed_template = YAML.safe_load(current_template["template"])++ expect(current_template["id"]).to eq(tag_groups_form_template.id)+ expect(current_template["name"]).to eq(tag_groups_form_template.name)+ expect(current_template["template"]).to eq(YAML.dump(parsed_template))++ expect(parsed_template[0]["attributes"]["tag_group"]).to eq(tag_group1.name)+ expect(parsed_template[1]["attributes"]["tag_group"]).to eq(tag_group2.name)++ expect(parsed_template[0]["attributes"]["tag_choices"]).to eq(+ { "tag1" => "Tag 1 custom Translation" },+ )+ expect(parsed_template[1]["attributes"]["tag_choices"]).to eq(+ { "tag2" => "Tag 2 custom Translation" },+ )+ expect(parsed_template[0]["choices"]).to eq(%w[tag1 tag3])+ expect(parsed_template[1]["choices"]).to eq(%w[tag2 tag4])+ end+ endendcontext "when you are not logged in" dodiff --git a/spec/system/composer/category_templates_spec.rb b/spec/system/composer/category_templates_spec.rbindex cbed100864f..0158521a18f 100644--- a/spec/system/composer/category_templates_spec.rb+++ b/spec/system/composer/category_templates_spec.rb@@ -536,4 +536,105 @@ describe "Composer Form Templates", type: :system doattach_file "5-uploader", "#{Rails.root}/spec/fixtures/images/logo.png", make_visible: trueexpect(preview).to have_css("img")end++ context "when using tagchooser" do+ fab!(:tag1) { Fabricate(:tag, description: "Tag 1 custom Translation") }+ fab!(:tag2) { Fabricate(:tag, description: "Tag 2 custom Translation") }+ fab!(:tag3) { Fabricate(:tag) }+ fab!(:tag4) { Fabricate(:tag) }++ fab!(:tag_group1) { Fabricate(:tag_group, name: "tag_group1", tags: [tag1, tag3]) }+ fab!(:tag_group2) { Fabricate(:tag_group, name: "tag_group2", tags: [tag2, tag4]) }++ fab!(:tag_groups_form_template) do+ Fabricate(+ :form_template,+ name: "TagGroups",+ template:+ %Q(+ - type: tag-chooser+ id: 1+ attributes:+ label: "Full name"+ description: "What is your full name?"+ multiple: true+ tag_group: "tag_group1" # Replace with actual value if needed+ validations:+ required: false++ - type: tag-chooser+ id: 2+ attributes:+ label: "Prescription"+ description: "Upload your prescription"+ multiple: false+ tag_group: "tag_group2"+ validations:+ required: true),+ )+ end++ fab!(:category_with_tagchooser_template) do+ Fabricate(+ :category,+ name: "tagtest",+ slug: "tagtest",+ topic_count: 2,+ form_template_ids: [tag_groups_form_template.id],+ )+ end++ it "shows the correct tag group descriptions" do+ category_page.visit(category_with_tagchooser_template)+ category_page.new_topic_button.click++ tag_chooser1 = find("[name='1']")+ tag_chooser2 = find("[name='2']")++ expect(tag_chooser1).to have_content("#{tag3.name.upcase}")+ expect(tag_chooser2).to have_content("#{tag4.name.upcase}")++ tag_chooser1.find("option", text: tag1.description).click(:control)++ expect(tag_chooser1.value).to eq(["#{tag1.description}"])++ # event won't be triggered if not done this way+ tag_chooser2.click+ tag_chooser2.send_keys(:arrow_down)+ tag_chooser2.send_keys(:enter)++ tag_chooser2.click+ tag_chooser2.send_keys(:arrow_up)+ tag_chooser2.send_keys(:enter)++ # working description translations+ expect(tag_chooser1).to have_content("#{tag1.description}")+ expect(tag_chooser2).to have_content("#{tag2.description}")++ mini_tag_chooser = PageObjects::Components::SelectKit.new(".mini-tag-chooser")+ expect(mini_tag_chooser).to have_selected_name("#{tag1.name},#{tag2.name}")+ end++ it "updates form when selecting tags in the composer" do+ category_page.visit(category_with_tagchooser_template)+ category_page.new_topic_button.click++ mini_tag_chooser = find(".mini-tag-chooser")+ mini_tag_chooser.click++ input = mini_tag_chooser.find("[name='filter-input-search']")+ input.set(tag1.name)++ input.send_keys(:arrow_down)+ input.send_keys(:enter)++ expect(mini_tag_chooser).to have_content(tag1.name)++ tag_chooser1 = find("[name='1']")+ expect(tag_chooser1.value).to eq([tag1.description])++ mini_tag_chooser.find("button").click+ expect(tag_chooser1.value).to eq([])+ end+ endenddiff --git a/spec/system/composer/template_validation_spec.rb b/spec/system/composer/template_validation_spec.rbindex 366a3a3b990..66b30f77769 100644--- a/spec/system/composer/template_validation_spec.rb+++ b/spec/system/composer/template_validation_spec.rb@@ -7,15 +7,24 @@ describe "Composer Form Template Validations", type: :system do:form_template,name: "Bug Reports",template:- "- type: input- id: full-name- attributes:- label: What is your full name?- placeholder: John Doe- validations:- required: true- type: email- minimum: 10",+ %Q(+ - type: input+ id: full-name+ attributes:+ label: "What is your full name?"+ placeholder: "John Doe"+ validations:+ required: true+ type: email+ minimum: 10++ - type: textarea+ id: full-text+ attributes:+ label: "Text"+ placeholder: "Full text"+ validations:+ required: false),)end@@ -60,6 +69,28 @@ describe "Composer Form Template Validations", type: :system dosign_in userend+ context "when user is using preview" do+ context "when user is typing" do+ it "shows the cooked form if the user doesn't fill the required field first" do+ category_page.visit(category_with_template)+ category_page.new_topic_button.click++ composer.fill_title(topic_title)+ textarea = find("textarea")+ message = "This is a test message!"++ textarea.fill_in(with: message)++ expect(composer).to have_no_form_template_field_error(+ I18n.t("js.form_templates.errors.value_missing.default"),+ )++ preview = find(".d-editor-preview")+ expect(preview).to have_content(message)+ end+ end+ end+it "shows an asterisk on the label of the required fields" docategory_page.visit(category_with_template)category_page.new_topic_button.clickdiff --git a/spec/system/page_objects/components/composer.rb b/spec/system/page_objects/components/composer.rbindex 00e5934a699..0025a1ba130 100644--- a/spec/system/page_objects/components/composer.rb+++ b/spec/system/page_objects/components/composer.rb@@ -229,6 +229,10 @@ module PageObjectspage.has_css?(".form-template-field__error", text: error, visible: :all)end+ def has_no_form_template_field_error?(error)+ page.has_no_css?(".form-template-field__error", text: error, visible: :all)+ end+def has_form_template_field_label?(label)page.has_css?(".form-template-field__label", text: label)end