0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-08 17:53:55 +08:00
discourse/spec/system/page_objects/modals/post_history.rb
Régis Hanol 146e41b39a
UX: Explain why a revision diff can't be shown in the edit history (#41367)
Previously, when a post revision was hidden, the history modal showed a
completely blank diff area for the revisions next to it, with no
explanation — the diffs on either side of a hidden revision aren't
rendered because they can expose the hidden revision's content, but
users were left thinking the edit history was broken. Reported in
https://meta.discourse.org/t/diff-between-revisions-no-longer-visible-when-there-is-a-hidden-revision-in-between/406254.

This change shows an explanatory notice in place of the blank diff,
driven by the `previous_hidden`/`current_hidden` flags the serializer
already exposes for exactly these revisions. The `hiddenClasses` dimming
is skipped when the notice shows, since it exists to fade hidden content
staff can still see and would fade the notice in the inline view. It
also rewords the related `diff_too_complex` messages in the same plain
language, since "diff" and "revision" aren't words most users know.
2026-07-02 19:41:25 +02:00

77 lines
1.8 KiB
Ruby
Vendored

# frozen_string_literal: true
module PageObjects
module Modals
class PostHistory < PageObjects::Modals::Base
MODAL_SELECTOR = ".history-modal"
def click_previous_revision
footer.find("button.previous-revision").click
self
end
def previous_locale
body.find(".revision__locale .revision-content.--previous")
end
def current_locale
body.find(".revision__locale .revision-content.--current")
end
def current_revision
revision_numbers.find("strong:nth-child(3)")
end
def hide_revision
footer.find("button.hide-revision").click
self
end
def destroy_revisions
footer.find("button.destroy-revision").click
end
def has_destroy_revisions_button?
footer.has_css?("button.destroy-revision")
end
def has_tag_changes?
body.has_css?(".-tag-revisions")
end
def has_hidden_diff_notice?
body.has_css?(".revision__hidden-notice", text: I18n.t("js.post.revisions.diff_hidden"))
end
def has_no_hidden_diff_notice?
body.has_no_css?(".revision__hidden-notice")
end
def has_body_diff?(text)
body.has_css?(".body-diff", text: text)
end
def previous_tags
body.find(".-tag-revisions .tag-revision__wrapper:first-child")
end
def current_tags
body.find(".-tag-revisions .tag-revision__wrapper:last-child")
end
def deleted_tags
body.all(".-tag-revisions .discourse-tag.diff-del").map(&:text)
end
def inserted_tags
body.all(".-tag-revisions .discourse-tag.diff-ins").map(&:text)
end
private
def revision_numbers
footer.find("#revision-numbers")
end
end
end
end