FEATURE: Add input filter for editing tags in navigation menu modal (#22216)

What does this change do?

This commit adds an input filter to filter through the tag checkboxes in the
modal to edit tags that are shown in the user's navigation menu. The
filtering is a simple matching of the given filter term against the
names of the tags.
This commit is contained in:
Alan Guo Xiang Tan
2023-06-21 10:59:56 +08:00
committed by GitHub
parent 08d8bd9f43
commit 609562be3e
7 changed files with 137 additions and 23 deletions

View File

@@ -49,4 +49,24 @@ RSpec.describe "Editing sidebar tags navigation", type: :system do
expect(sidebar).to have_no_section_link(tag2.name)
expect(sidebar).to have_no_section_link(tag3.name)
end
it "allows a user to filter the tags in the modal by the tag's name" do
visit "/latest"
expect(sidebar).to have_tags_section
modal = sidebar.click_edit_tags_button
modal.filter("tag")
expect(modal).to have_tag_checkboxes([tag, tag2, tag3])
modal.filter("tag2")
expect(modal).to have_tag_checkboxes([tag2])
modal.filter("someinvalidterm")
expect(modal).to have_no_tag_checkboxes
end
end

View File

@@ -20,6 +20,14 @@ module PageObjects
end
end
def has_no_tag_checkboxes?
has_no_css?(".sidebar-tags-form-modal .sidebar-tags-form__tag") &&
has_css?(
".sidebar-tags-form-modal .sidebar-tags-form__no-tags",
text: I18n.t("js.sidebar.tags_form_modal.no_tags"),
)
end
def toggle_tag_checkbox(tag)
find(
".sidebar-tags-form-modal .sidebar-tags-form__tag[data-tag-name='#{tag.name}'] .sidebar-tags-form__input",
@@ -32,6 +40,11 @@ module PageObjects
find(".sidebar-tags-form-modal .sidebar-tags-form__save-button").click
self
end
def filter(text)
find(".sidebar-tags-form-modal .sidebar-tags-form__filter-input-field").fill_in(with: text)
self
end
end
end
end