FEATURE: add new tags from edit tag synonyms page (#20553)

Feature to allow adding new tags from the edit tag synonyms tag search field.
Previously new tags had to be created from the topic composer, and then added via the edit tag synonyms page.

/t/92741
This commit is contained in:
David Battersby 2023-03-08 14:26:20 +08:00 committed by GitHub
parent 6feb436303
commit 8eb2fa5fa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 107 additions and 1 deletions

View File

@ -120,6 +120,7 @@
@excludeSynonyms={{true}}
@excludeHasSynonyms={{true}}
@unlimitedTagCount={{true}}
@allowCreate={{true}}
/>
<DButton
@class="ok"

View File

@ -15,7 +15,11 @@ export default MultiSelectComponent.extend(TagsMixin, {
maximum: "maximumTagCount",
},
modifyComponentForRow() {
modifyComponentForRow(collection, item) {
if (this.getValue(item) === this.selectKit.filter && !item.count) {
return "select-kit/select-kit-row";
}
return "tag-chooser-row";
},

View File

@ -0,0 +1,48 @@
# frozen_string_literal: true
module PageObjects
module Pages
class Tag < PageObjects::Pages::Base
def visit_tag(tag)
page.visit "/tag/#{tag.name}"
self
end
def tag_info_btn
find("#show-tag-info")
end
def edit_synonyms_btn
find("#edit-synonyms")
end
def add_synonym_btn
find(".add-synonyms .ok")
end
def confirm_synonym_btn
find(".dialog-footer .btn-primary")
end
def add_synonyms_select_field
find("#add-synonyms")
end
def search_tags(search)
find("#add-synonyms-filter input").fill_in(with: search)
end
def has_search_result?(tag)
page.has_selector?(".select-kit-row[data-name='#{tag}']")
end
def search_result(index)
find(".select-kit-collection li:nth-child(#{index})")
end
def tag_box(tag)
find(".tag-box div[data-tag-name='#{tag}']")
end
end
end
end

View File

@ -0,0 +1,53 @@
# frozen_string_literal: true
describe "Tag synonyms", type: :system, js: true do
let(:tags_page) { PageObjects::Pages::Tag.new }
fab!(:tag_1) { Fabricate(:tag, name: "design") }
fab!(:tag_2) { Fabricate(:tag, name: "art") }
fab!(:current_user) { Fabricate(:admin) }
before { sign_in(current_user) }
describe "when visiting edit tag page" do
it "allows an admin to add existing tag as a synonym" do
tags_page.visit_tag(tag_1)
expect(tags_page.tag_info_btn).to be_visible
tags_page.tag_info_btn.click
expect(tags_page.edit_synonyms_btn).to be_visible
tags_page.edit_synonyms_btn.click
expect(tags_page.add_synonyms_select_field).to be_visible
tags_page.add_synonyms_select_field.click
expect(tags_page.has_search_result?(tag_2.name)).to be_truthy
tags_page.search_result(1).click
expect(tags_page.add_synonym_btn).to be_visible
tags_page.add_synonym_btn.click
expect(tags_page.confirm_synonym_btn).to be_visible
tags_page.confirm_synonym_btn.click
expect(tags_page.tag_box(tag_2.name)).to be_visible
end
it "allows an admin to create a new tag as synonym when tag does not exist" do
tags_page.visit_tag(tag_1)
tags_page.tag_info_btn.click
tags_page.edit_synonyms_btn.click
tags_page.add_synonyms_select_field.click
# searched tag doesnt exist but will show option to create tag
tags_page.search_tags("graphics")
expect(tags_page.has_search_result?("graphics")).to be_truthy
tags_page.search_result(1).click
tags_page.add_synonym_btn.click
tags_page.confirm_synonym_btn.click
expect(tags_page.tag_box("graphics")).to be_visible
end
end
end