Skip to content

Commit ee2ee31

Browse files
committed
DEV: Match tag icons on the name the viewer reads
The page object located tags through `data-tag-name`, which core is changing to carry the untranslated name so it stays stable across locales. Asserting on the visible text instead holds either way.
1 parent 3302f6b commit ee2ee31

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

spec/system/page_objects/components/tag_icon.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
module PageObjects
44
module Components
55
class TagIcon < PageObjects::Components::Base
6+
# Tags are matched on the name the viewer reads, so these assertions hold
7+
# whether or not a localization applies.
68
def has_icon_for_tag?(tag_name:, icon:, color: nil)
7-
selector = ".discourse-tag[data-tag-name='#{tag_name}']"
9+
selector = ".discourse-tag"
810
selector += "[style*='--color1: #{color}; --color2: #fffd;']" if color
9-
selector += " .tag-icon .d-icon-#{icon}"
10-
page.has_css?(selector)
11+
12+
page.has_css?("#{selector}:has(.tag-icon .d-icon-#{icon})", text: tag_name)
1113
end
1214

1315
def has_no_icon_for_tag?(tag_name:)
14-
page.has_css?(".discourse-tag[data-tag-name='#{tag_name}']") &&
15-
page.has_no_css?(".discourse-tag[data-tag-name='#{tag_name}'] .tag-icon")
16+
page.has_css?(".discourse-tag", text: tag_name) &&
17+
page.has_no_css?(".discourse-tag:has(.tag-icon)", text: tag_name)
1618
end
1719
end
1820
end

0 commit comments

Comments
 (0)