discourse/spec/system/viewing_reviewable_spec.rb
Krzysztof Kotlarek 6e39bb9728
FIX: Persist reviewable notes when toggle tabs (#35495)
When adding a note through the timeline tab, the note wasn't being
persisted to the reviewable's reviewable_notes array. This caused the
note to disappear when switching between tabs.
2025-10-21 10:23:41 +08:00

120 lines
4.1 KiB
Ruby

# frozen_string_literal: true
describe "Viewing reviewable item", type: :system do
fab!(:admin)
fab!(:group)
fab!(:reviewable_flagged_post)
let(:review_page) { PageObjects::Pages::Review.new }
let(:review_note_form) { PageObjects::Components::ReviewNoteForm.new }
describe "when user is part of the groups list of the `reviewable_ui_refresh` site setting" do
before do
SiteSetting.reviewable_ui_refresh = group.name
group.add(admin)
sign_in(admin)
end
describe "when the reviewable item is a flagged post" do
it "shows the new reviewable UI" do
review_page.visit_reviewable(reviewable_flagged_post)
expect(page).to have_selector(".review-container")
end
it "shows the reviewable item with badges stating the flag reason and count" do
_spam_reviewable_score =
Fabricate(
:reviewable_score,
reviewable: reviewable_flagged_post,
reviewable_score_type: ReviewableScore.types[:spam],
)
_off_topic_reviewable_score =
Fabricate(
:reviewable_score,
reviewable: reviewable_flagged_post,
reviewable_score_type: ReviewableScore.types[:off_topic],
)
_illegal_reviewable_score =
Fabricate(
:reviewable_score,
reviewable: reviewable_flagged_post,
reviewable_score_type: ReviewableScore.types[:illegal],
)
_inappropriate_reviewable_score =
Fabricate(
:reviewable_score,
reviewable: reviewable_flagged_post,
reviewable_score_type: ReviewableScore.types[:inappropriate],
)
_needs_approval_reviewable_score =
Fabricate(
:reviewable_score,
reviewable: reviewable_flagged_post,
reviewable_score_type: ReviewableScore.types[:needs_approval],
)
flag_reason_component =
review_page.visit_reviewable(reviewable_flagged_post).flag_reason_component
expect(flag_reason_component).to have_spam_flag_reason(reviewable_flagged_post, count: 1)
expect(flag_reason_component).to have_off_topic_flag_reason(
reviewable_flagged_post,
count: 1,
)
expect(flag_reason_component).to have_illegal_flag_reason(reviewable_flagged_post, count: 1)
expect(flag_reason_component).to have_inappropriate_flag_reason(
reviewable_flagged_post,
count: 2,
)
expect(flag_reason_component).to have_needs_approval_flag_reason(
reviewable_flagged_post,
count: 1,
)
end
it "shows the topic status, title link, category badge and tags of the topic associated with the reviewable item correctly" do
post = reviewable_flagged_post.post
topic = reviewable_flagged_post.topic
category = Fabricate(:category)
topic.change_category_to_id(category.id)
tag_1 = Fabricate(:tag)
tag_2 = Fabricate(:tag)
topic.tags = [tag_1, tag_2]
topic.closed = true
topic.save!
topic_link_component =
review_page.visit_reviewable(reviewable_flagged_post).topic_link_component
expect(topic_link_component).to have_closed_topic_status
expect(topic_link_component).to have_topic_link(
topic_title: topic.title,
post_url: post.full_url,
)
expect(topic_link_component).to have_category_badge(category.name)
expect(topic_link_component).to have_tag_link(tag_name: tag_1.name, tag_url: tag_1.url)
expect(topic_link_component).to have_tag_link(tag_name: tag_2.name, tag_url: tag_2.url)
# TODO: Add test for watched words highlighting
end
it "allows to add notes and persists them when toggle tabs" do
review_page.visit_reviewable(reviewable_flagged_post)
review_page.click_timeline_tab
review_note_form.add_note("This is a review note.")
review_page.click_insights_tab
review_page.click_timeline_tab
expect(page).to have_text("This is a review note.")
end
end
end
end