Selase Krakani 3d554aa10e
FIX: Keep ReviewableQueuedPosts even with user delete reviewable actions (#22501)
Performing a `Delete User`/`Delete and Block User` reviewable actions for a
queued post reviewable from the `review.show` route results in an error
popup even if the action completes successfully.

This happens because unlike other reviewable types, a user delete action
on a queued post reviewable results in the deletion of the reviewable
itself. A subsequent attempt to reload the reviewable record results in
404. The deletion happens as part of the call to `UserDestroyer` which
includes a step for destroying reviewables created by the user being
destroyed. At the root of this is the creator of the queued post
being set as the creator of the reviewable as instead of the system
user.

This change assigns the creator of the reviewable to the system user and
uses the more approapriate `target_created_by` column for the creator of the
post being queued.
2023-07-18 11:50:31 +00:00

74 lines
1.9 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Pages
class Review < PageObjects::Pages::Base
POST_BODY_TOGGLE_SELECTOR = ".post-body__toggle-btn"
POST_BODY_COLLAPSED_SELECTOR = ".post-body.is-collapsed"
REVIEWABLE_ACTION_DROPDOWN = ".reviewable-action-dropdown"
def visit_reviewable(reviewable)
page.visit("/review/#{reviewable.id}")
self
end
def select_bundled_action(reviewable, value)
within(reviewable_by_id(reviewable.id)) do
reviewable_action_dropdown.select_row_by_value(value)
end
end
def reviewable_by_id(id)
find(".reviewable-item[data-reviewable-id=\"#{id}\"]")
end
def click_post_body_toggle
find(POST_BODY_TOGGLE_SELECTOR).click
end
def has_post_body_toggle?
page.has_css?(POST_BODY_TOGGLE_SELECTOR)
end
def has_no_post_body_toggle?
page.has_no_css?(POST_BODY_TOGGLE_SELECTOR)
end
def has_post_body_collapsed?
page.has_css?(POST_BODY_COLLAPSED_SELECTOR)
end
def has_no_post_body_collapsed?
page.has_no_css?(POST_BODY_COLLAPSED_SELECTOR)
end
def has_reviewable_action_dropdown?
page.has_css?(REVIEWABLE_ACTION_DROPDOWN)
end
def has_reviewable_with_pending_status?(reviewable)
within(reviewable_by_id(reviewable.id)) { page.has_css?(".status .pending") }
end
def has_reviewable_with_rejected_status?(reviewable)
within(reviewable_by_id(reviewable.id)) { page.has_css?(".status .rejected") }
end
def has_error_dialog_visible?
page.has_css?(".dialog-container .dialog-content")
end
def has_no_error_dialog_visible?
!has_error_dialog_visible?
end
private
def reviewable_action_dropdown
@reviewable_action_dropdown ||=
PageObjects::Components::SelectKit.new(REVIEWABLE_ACTION_DROPDOWN)
end
end
end
end