mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: upgrade reject reason reviewable modal to glimmer component (#24073)
* DEV: add system test for rejecting user from review page * DEV: upgrade reject-reason-reviewable modal to glimmer & DModal
This commit is contained in:
25
spec/system/page_objects/modals/reject_reason_reviewable.rb
Normal file
25
spec/system/page_objects/modals/reject_reason_reviewable.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PageObjects
|
||||
module Modals
|
||||
class RejectReasonReviewable < PageObjects::Modals::Base
|
||||
def modal
|
||||
find(".reject-reason-reviewable-modal")
|
||||
end
|
||||
|
||||
def select_send_rejection_email_checkbox
|
||||
modal.find(".reject-reason-reviewable-modal__send_email--inline").check
|
||||
end
|
||||
|
||||
def fill_in_rejection_reason(reason)
|
||||
modal.find(".reject-reason-reviewable-modal__explain-reviewable textarea").fill_in(
|
||||
with: reason,
|
||||
)
|
||||
end
|
||||
|
||||
def delete_user
|
||||
modal.find(".modal-footer .btn.btn-danger").click
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -64,6 +64,13 @@ module PageObjects
|
||||
within(reviewable_by_id(reviewable.id)) { page.has_css?(".status .rejected") }
|
||||
end
|
||||
|
||||
def has_reviewable_with_rejection_reason?(reviewable, rejection_reason)
|
||||
reviewable_by_id(reviewable.id).has_css?(
|
||||
".reviewable-user-details.reject-reason .value",
|
||||
text: rejection_reason,
|
||||
)
|
||||
end
|
||||
|
||||
def has_error_dialog_visible?
|
||||
page.has_css?(".dialog-container .dialog-content")
|
||||
end
|
||||
|
||||
@@ -56,6 +56,39 @@ describe "Reviewables", type: :system do
|
||||
end
|
||||
end
|
||||
|
||||
describe "when there is a reviewable user" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
let(:rejection_reason_modal) { PageObjects::Modals::RejectReasonReviewable.new }
|
||||
|
||||
before do
|
||||
SiteSetting.must_approve_users = true
|
||||
Jobs.run_immediately!
|
||||
user.update!(approved: false)
|
||||
user.activate
|
||||
end
|
||||
|
||||
it "Rejecting user sends rejection email and updates reviewable with rejection reason" do
|
||||
rejection_reason = "user is spamming"
|
||||
reviewable = ReviewableUser.find_by_target_id(user.id)
|
||||
# cache it for later assertion instead of querying UserHistory
|
||||
user_email = user.email
|
||||
|
||||
review_page.visit_reviewable(reviewable)
|
||||
review_page.select_bundled_action(reviewable, "user-delete_user")
|
||||
rejection_reason_modal.fill_in_rejection_reason(rejection_reason)
|
||||
rejection_reason_modal.select_send_rejection_email_checkbox
|
||||
rejection_reason_modal.delete_user
|
||||
|
||||
expect(review_page).to have_reviewable_with_rejected_status(reviewable)
|
||||
expect(review_page).to have_reviewable_with_rejection_reason(reviewable, rejection_reason)
|
||||
|
||||
mail = ActionMailer::Base.deliveries.first
|
||||
expect(mail.to).to eq([user_email])
|
||||
expect(mail.subject).to match(/You've been rejected on Discourse/)
|
||||
expect(mail.body.raw_source).to include rejection_reason
|
||||
end
|
||||
end
|
||||
|
||||
context "when performing a review action from the show route" do
|
||||
context "with a ReviewableQueuedPost" do
|
||||
fab!(:queued_post_reviewable) { Fabricate(:reviewable_queued_post) }
|
||||
|
||||
Reference in New Issue
Block a user