mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +08:00
The setting has been hidden and enabled by default since it was switched on for all sites in mid-2025, making it effectively dead configuration. The rich editor is now always available, and the per-user `composition_mode` preference remains the only way to pick between the markdown and rich text editors. This also makes the first toolbar button focusable when a `composer-force-editor-mode` transformer hides the editor mode toggle, which previously left the toolbar without a tabbable button in that state. Since it comes from the same rollout, this also drops the shim that migrated the pre-`composition_mode` localStorage preference (`d-editor-prefers-rich-editor`) into the user option. The key hasn't been written since the rich editor was enabled everywhere a year ago, and the shim deleted it on first composer open, so any remaining copies belong to browsers that haven't composed since then — for those, the default mode is rich anyway.
110 lines
3.2 KiB
Ruby
Vendored
110 lines
3.2 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
describe "Image Carousel" do
|
|
fab!(:current_user, :admin)
|
|
fab!(:upload1) do
|
|
UploadCreator.new(file_from_fixtures("logo.png", "images"), "logo.png").create_for(
|
|
current_user.id,
|
|
)
|
|
end
|
|
fab!(:upload2) do
|
|
UploadCreator.new(file_from_fixtures("logo.jpg", "images"), "logo.jpg").create_for(
|
|
current_user.id,
|
|
)
|
|
end
|
|
|
|
let(:composer) { PageObjects::Components::Composer.new }
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
|
|
before { sign_in(current_user) }
|
|
|
|
it "renders a carousel in the post stream" do
|
|
post = create_post(raw: <<~MD)
|
|
[grid mode=carousel]
|
|

|
|

|
|
[/grid]
|
|
MD
|
|
|
|
topic_page.visit_topic(post.topic, post_number: post.post_number)
|
|
carousel = PageObjects::Components::ImageCarousel.new(post.post_number)
|
|
|
|
expect(carousel).to have_carousel
|
|
expect(carousel).to have_mode("carousel")
|
|
expect(carousel).to have_track
|
|
expect(carousel).to have_slides(count: 2)
|
|
end
|
|
|
|
it "wraps around in carousel mode" do
|
|
post = create_post(raw: <<~MD)
|
|
[grid mode=carousel]
|
|

|
|

|
|
[/grid]
|
|
MD
|
|
|
|
topic_page.visit_topic(post.topic, post_number: post.post_number)
|
|
carousel = PageObjects::Components::ImageCarousel.new(post.post_number)
|
|
|
|
expect(carousel).to have_active_slide_index(0)
|
|
|
|
carousel.click_prev
|
|
expect(carousel).to have_active_slide_index(1)
|
|
|
|
carousel.click_next
|
|
expect(carousel).to have_active_slide_index(0)
|
|
|
|
carousel.click_next
|
|
expect(carousel).to have_active_slide_index(1)
|
|
|
|
carousel.click_next
|
|
expect(carousel).to have_active_slide_index(0)
|
|
end
|
|
|
|
it "keyboard navigation wraps around in carousel mode" do
|
|
post = create_post(raw: <<~MD)
|
|
[grid mode=carousel]
|
|

|
|

|
|
[/grid]
|
|
MD
|
|
|
|
topic_page.visit_topic(post.topic, post_number: post.post_number)
|
|
carousel = PageObjects::Components::ImageCarousel.new(post.post_number)
|
|
|
|
carousel.focus_track
|
|
|
|
send_keys(:left)
|
|
expect(carousel).to have_active_slide_index(1)
|
|
|
|
wait_for_timeout(150) # we throttle keyboard actions
|
|
|
|
send_keys(:right)
|
|
expect(carousel).to have_active_slide_index(0)
|
|
end
|
|
|
|
it "allows changing modes in the rich text editor", js: true do
|
|
SiteSetting.post_menu_hidden_items = ""
|
|
current_user.user_option.update!(composition_mode: 1)
|
|
|
|
post = create_post(raw: <<~MD)
|
|
[grid mode=carousel]
|
|

|
|
[/grid]
|
|
MD
|
|
|
|
topic_page.visit_topic(post.topic, post_number: post.post_number)
|
|
expect(topic_page).to have_post_action_button(post, :edit)
|
|
topic_page.click_post_action_button(post, :edit)
|
|
|
|
expect(composer).to be_opened
|
|
expect(composer).to have_rich_editor_active
|
|
expect(composer.image_grid).to have_mode_select
|
|
|
|
composer.image_grid.select_mode("Grid")
|
|
expect(composer.image_grid).to have_selected_mode("grid")
|
|
|
|
composer.toggle_rich_editor
|
|
expect(composer.composer_input.value).to include("[grid]")
|
|
end
|
|
end
|