mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 14:00:42 +08:00
Our current implementation of lightbox uses Magnific Popup, which is now deprecated and will only receive critical/security bug fixes. Magnific also relies on jQuery, which we would like to remove where possible throughout our codebase. After looking at various options, the general consensus was that PhotoSwipe was a close match to what we need. Regular image types that are supported with our current lightbox (jpg, png etc) will work with their existing cooked markup (no need to rebake posts). This PR also adds support for SVG images and markup from various theme components (ie. Discourse Mermaid). --------- Co-authored-by: Martin Brennan <martin@discourse.org>
48 lines
1.4 KiB
Ruby
Vendored
48 lines
1.4 KiB
Ruby
Vendored
# frozen_string_literal: true
|
||
|
||
RSpec.describe "Channel message selection", type: :system do
|
||
fab!(:current_user, :user)
|
||
fab!(:channel_1, :chat_channel)
|
||
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel_1) }
|
||
|
||
let(:chat) { PageObjects::Pages::Chat.new }
|
||
let(:channel) { PageObjects::Pages::ChatChannel.new }
|
||
let(:image) do
|
||
Fabricate(
|
||
:upload,
|
||
original_filename: "test_image.jpg",
|
||
width: 400,
|
||
height: 300,
|
||
extension: "jpg",
|
||
)
|
||
end
|
||
|
||
before do
|
||
chat_system_bootstrap
|
||
channel_1.add(current_user)
|
||
sign_in(current_user)
|
||
message_1.uploads = [image]
|
||
end
|
||
|
||
it "can collapse/expand an image and still have lightbox working" do
|
||
chat.visit_channel(channel_1)
|
||
|
||
find(".chat-message-collapser-button").click
|
||
expect(page).to have_css(".chat-message-collapser-body.hidden", visible: :hidden)
|
||
find(".chat-message-collapser-button").click
|
||
expect(page).to have_no_css(".chat-message-collapser-body.hidden")
|
||
find(".chat-img-upload").click
|
||
|
||
# visible false is because the upload doesn’t exist but it's enough to know lightbox is working
|
||
expect(page).to have_css(".mfp-image-holder img[src*='#{image.url}']", visible: :hidden)
|
||
end
|
||
|
||
it "can open image in lightbox when using PhotoSwipe" do
|
||
SiteSetting.experimental_lightbox = true
|
||
|
||
chat.visit_channel(channel_1)
|
||
find(".chat-img-upload").click
|
||
|
||
expect(page).to have_css(".pswp")
|
||
end
|
||
end
|