discourse/spec/system/page_objects/components/review/flag_reason.rb
Alan Guo Xiang Tan 7ee96e398f
DEV: Update colors for flag reasons in new reviewable UI (#33462)
Prior to this change, off topic and something else flags did not have
the right CSS classes set resulting in the right colors not being set
for the badges used to display the flag reasons.

This commit also updates the colors used for the off topic and illegal
flags to reflect the severity. Before this change, the badge color for
illegal was green while the badge color for off topic is blue. Those
colors are too "positive".

### Screenshots

#### Before

<img width="718" alt="Screenshot 2025-07-03 at 3 22 49 PM"
src="https://github.com/user-attachments/assets/cc10d078-fe58-41aa-8c15-4bba86eb90e5"
/>

#### After

<img width="715" alt="Screenshot 2025-07-03 at 3 23 02 PM"
src="https://github.com/user-attachments/assets/e039e042-68ae-4e76-bd5a-62116ef020a3"
/>
2025-07-03 15:56:39 +08:00

45 lines
1.5 KiB
Ruby
Vendored

# frozen_string_literal: true
module PageObjects
module Components
module Review
class FlagReason < PageObjects::Components::Base
def has_spam_flag_reason?(reviewable, count: 1)
has_flag_reason?(reviewable, css_class: "spam", type: :spam, count:)
end
def has_off_topic_flag_reason?(reviewable, count: 1)
has_flag_reason?(reviewable, css_class: "off-topic", type: :off_topic, count:)
end
def has_illegal_flag_reason?(reviewable, count: 1)
has_flag_reason?(reviewable, css_class: "illegal", type: :illegal, count:)
end
def has_inappropriate_flag_reason?(reviewable, count: 1)
has_flag_reason?(reviewable, css_class: "inappropriate", type: :inappropriate, count:)
end
def has_needs_approval_flag_reason?(reviewable, count: 1)
has_flag_reason?(reviewable, css_class: "needs-approval", type: :needs_approval, count:)
end
private
def has_flag_reason?(reviewable, css_class:, type:, count: 1)
within_reviewable_item(reviewable) do
expect(find(".review-item__flag-reason.--#{css_class}").text.gsub(/\s+/, " ")).to eq(
"#{count} #{ReviewableScore.type_title(type)}",
)
expect(page).to have_css(".review-item__flag-count.--#{css_class}")
end
end
def within_reviewable_item(reviewable)
within(".review-item[data-reviewable-id='#{reviewable.id}']") { yield }
end
end
end
end
end