mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-04 11:03:50 +08:00
TagChooser's `_onChange` was changed to pass tag objects instead of
name strings (9e99066b07), which broke watched words as
`tags.join(",")` on objects produced `[object Object]` fails
validation.
Instead of restoring the old string-based approach, this switches to
sending tag objects with ids to the backend. The controller resolves
existing tags by ID (we should always ref by id) and creates new
ones via `DiscourseTagging.find_or_create_tags!`. The legacy
`replacement` param still works for backward compatibility.
44 lines
1.2 KiB
Ruby
44 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Pages
|
|
class AdminWatchedWords < PageObjects::Pages::Base
|
|
def visit(action: "block")
|
|
page.visit "admin/customize/watched_words/action/#{action}"
|
|
self
|
|
end
|
|
|
|
def add_word(word)
|
|
ww = page.find("#watched-words")
|
|
ww.find("#watched-words-header").click
|
|
ww.find(".filter-input").send_keys(word)
|
|
ww.find(".select-kit-row").click
|
|
|
|
page.find(".watched-words-detail .btn-primary").click
|
|
end
|
|
|
|
def has_word?
|
|
has_css?(".watched-words-detail .show-words-checkbox")
|
|
end
|
|
|
|
def add_word_with_tag(word, tag_name)
|
|
words_selector = PageObjects::Components::SelectKit.new("#watched-words")
|
|
words_selector.expand
|
|
words_selector.search(word)
|
|
words_selector.select_row_by_name(word)
|
|
words_selector.collapse
|
|
|
|
tag_chooser = PageObjects::Components::SelectKit.new(".tag-chooser")
|
|
tag_chooser.expand
|
|
tag_chooser.search(tag_name)
|
|
tag_chooser.select_row_by_name(tag_name)
|
|
|
|
page.find(".watched-words-detail .btn-primary").click
|
|
end
|
|
|
|
def has_error?(error)
|
|
has_css?(".dialog-container .dialog-body", text: error)
|
|
end
|
|
end
|
|
end
|
|
end
|