discourse/spec/system/page_objects/pages/admin_watched_words.rb
Natalie Tay 375779df7b
FIX: Watched word tag action broken after TagChooser refactor (#38245)
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.
2026-03-09 11:37:18 +08:00

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