0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-07 13:19:19 +08:00
discourse/plugins/discourse-math/spec/system/composer_spec.rb
Renato Atilio b834edd625
DEV: Remove rich_editor site setting (#41873)
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.
2026-07-23 19:49:20 -03:00

54 lines
1.7 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe "Discourse Math - composer" do
fab!(:current_user) do
# Start in markdown mode so we can type math syntax, then toggle to rich editor
Fabricate(:admin, composition_mode: UserOption.composition_mode_types[:markdown])
end
fab!(:category)
let(:composer) { PageObjects::Components::Composer.new }
let(:rich) { composer.rich_editor }
before do
SiteSetting.discourse_math_enabled = true
sign_in(current_user)
end
def open_composer_and_type_math(math_content)
visit("/new-topic")
expect(composer).to be_opened
composer.fill_title("Math test topic")
# Type math in markdown mode
composer.fill_content(math_content)
# Toggle to rich editor to trigger math parsing and rendering
composer.toggle_rich_editor
expect(composer).to have_rich_editor_active
end
describe "MathJax provider" do
before { SiteSetting.discourse_math_provider = "mathjax" }
it "renders inline math in rich editor" do
open_composer_and_type_math("Inline math: $E=mc^2$ here")
expect(rich).to have_css(".composer-math-node .math-container mjx-container", wait: 10)
end
it "renders block math in rich editor" do
open_composer_and_type_math("Block math:\n\n$$\nx^2 + y^2 = z^2\n$$")
expect(rich).to have_css(".composer-math-node .math-container mjx-container", wait: 10)
end
end
describe "KaTeX provider" do
before { SiteSetting.discourse_math_provider = "katex" }
it "renders inline math in rich editor" do
open_composer_and_type_math("Inline math: $E=mc^2$ here")
expect(rich).to have_css(".composer-math-node .math-container .katex", wait: 10)
end
end
end