mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 08:35:20 +08:00
UX: Add show more btn to reviewable item (#21579)
This commit is contained in:
30
spec/system/page_objects/pages/review.rb
Normal file
30
spec/system/page_objects/pages/review.rb
Normal file
@ -0,0 +1,30 @@
|
||||
# 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"
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
34
spec/system/reviewables_spec.rb
Normal file
34
spec/system/reviewables_spec.rb
Normal file
@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe "Reviewables", type: :system, js: true do
|
||||
let(:review_page) { PageObjects::Pages::Review.new }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:theme) { Fabricate(:theme) }
|
||||
fab!(:long_post) { Fabricate(:post_with_very_long_raw_content) }
|
||||
|
||||
before { sign_in(admin) }
|
||||
|
||||
describe "when there is a reviewable with a long post" do
|
||||
fab!(:long_reviewable) { Fabricate(:reviewable_flagged_post, target: long_post) }
|
||||
|
||||
it "should show a button to expand/collapse the post content" do
|
||||
visit("/review")
|
||||
expect(review_page).to have_post_body_collapsed
|
||||
expect(review_page).to have_post_body_toggle
|
||||
review_page.click_post_body_toggle
|
||||
expect(review_page).to have_no_post_body_collapsed
|
||||
review_page.click_post_body_toggle
|
||||
expect(review_page).to have_post_body_collapsed
|
||||
end
|
||||
end
|
||||
|
||||
describe "when there is a reviewable with a short post" do
|
||||
fab!(:short_reviewable) { Fabricate(:reviewable_flagged_post) }
|
||||
|
||||
it "should not show a button to expand/collapse the post content" do
|
||||
visit("/review")
|
||||
expect(review_page).to have_no_post_body_collapsed
|
||||
expect(review_page).to have_no_post_body_toggle
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user