Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions spec/system/page_objects/components/tag_icon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
module PageObjects
module Components
class TagIcon < PageObjects::Components::Base
# Tags are matched on the name the viewer reads, so these assertions hold
# whether or not a localization applies.
def has_icon_for_tag?(tag_name:, icon:, color: nil)
selector = ".discourse-tag[data-tag-name='#{tag_name}']"
selector = ".discourse-tag"
selector += "[style*='--color1: #{color}; --color2: #fffd;']" if color
selector += " .tag-icon .d-icon-#{icon}"
page.has_css?(selector)

page.has_css?("#{selector}:has(.tag-icon .d-icon-#{icon})", text: tag_name)
end

def has_no_icon_for_tag?(tag_name:)
page.has_css?(".discourse-tag[data-tag-name='#{tag_name}']") &&
page.has_no_css?(".discourse-tag[data-tag-name='#{tag_name}'] .tag-icon")
page.has_css?(".discourse-tag", text: tag_name) &&
page.has_no_css?(".discourse-tag:has(.tag-icon)", text: tag_name)
end
end
end
Expand Down