FEATURE: Add Revise... option for queued post reviewable (#23454)

This commit adds a new Revise... action that can be taken
for queued post reviewables. This will open a modal where
the user can select a Reason from a preconfigured list
(or by choosing Other..., a custom reason) and provide feedback
to the user about their post.

The post will be rejected still, but a PM will also be sent to
the user so they have an opportunity to improve their post when
they resubmit it.
This commit is contained in:
Martin Brennan
2023-10-13 11:28:31 +10:00
committed by GitHub
parent 5fe4e0ed48
commit 9762e65758
16 changed files with 385 additions and 7 deletions

View File

@@ -22,6 +22,10 @@ module PageObjects
find(".modal-footer .btn-primary").click
end
def has_content?(content)
find(".modal-body").has_content?(content)
end
def open?
has_css?(".modal.d-modal")
end

View File

@@ -18,6 +18,12 @@ module PageObjects
end
end
def select_action(reviewable, value)
within(reviewable_by_id(reviewable.id)) do
find(".reviewable-action.#{value.dasherize}").click
end
end
def reviewable_by_id(id)
find(".reviewable-item[data-reviewable-id=\"#{id}\"]")
end

View File

@@ -76,6 +76,55 @@ describe "Reviewables", type: :system do
expect(queued_post_reviewable.reload).to be_rejected
expect(queued_post_reviewable.target_created_by).to be_nil
end
it "allows revising and rejecting to send a PM to the user" do
revise_modal = PageObjects::Modals::Base.new
review_page.visit_reviewable(queued_post_reviewable)
expect(queued_post_reviewable).to be_pending
expect(queued_post_reviewable.target_created_by).to be_present
review_page.select_action(queued_post_reviewable, "revise_and_reject_post")
expect(revise_modal).to be_open
reason_dropdown =
PageObjects::Components::SelectKit.new(".revise-and-reject-reviewable__reason")
reason_dropdown.select_row_by_value(SiteSetting.reviewable_revision_reasons_map.first)
find(".revise-and-reject-reviewable__feedback").fill_in(with: "This is a test")
revise_modal.click_primary_button
expect(review_page).to have_reviewable_with_rejected_status(queued_post_reviewable)
expect(queued_post_reviewable.reload).to be_rejected
expect(Topic.where(archetype: Archetype.private_message).last.title).to eq(
I18n.t(
"system_messages.reviewable_queued_post_revise_and_reject.subject_template",
topic_title: queued_post_reviewable.topic.title,
),
)
end
it "allows selecting a custom reason for revise and reject" do
revise_modal = PageObjects::Modals::Base.new
review_page.visit_reviewable(queued_post_reviewable)
expect(queued_post_reviewable).to be_pending
expect(queued_post_reviewable.target_created_by).to be_present
review_page.select_action(queued_post_reviewable, "revise_and_reject_post")
expect(revise_modal).to be_open
reason_dropdown =
PageObjects::Components::SelectKit.new(".revise-and-reject-reviewable__reason")
reason_dropdown.select_row_by_value("other_reason")
find(".revise-and-reject-reviewable__custom-reason").fill_in(with: "I felt like it")
find(".revise-and-reject-reviewable__feedback").fill_in(with: "This is a test")
revise_modal.click_primary_button
expect(review_page).to have_reviewable_with_rejected_status(queued_post_reviewable)
end
end
end
end