Add system tests for markdown paste in Lexxy editor

Test that pasting markdown with block separators produces extra spacing
between blocks, and that single line breaks are preserved.
This commit is contained in:
Mike Dalessio
2026-03-16 13:39:12 -04:00
parent 29a29094bd
commit fc18ba8e07
+40
View File
@@ -76,6 +76,38 @@ class SmokeTest < ApplicationSystemTestCase
assert_no_selector "div##{dom_id(notification)}"
end
test "markdown paste adds block spacing" do
sign_in_as(users(:david))
visit card_url(cards(:layout))
find("lexxy-editor").click
paste_markdown("Hello\n\nWorld")
within("lexxy-editor") do
assert_selector "p", text: "Hello"
assert_selector "p br", visible: :all
assert_selector "p", text: "World"
end
end
test "markdown paste preserves line breaks" do
sign_in_as(users(:david))
visit card_url(cards(:layout))
find("lexxy-editor").click
paste_markdown("Hello\nWorld")
inner_html = find("lexxy-editor p", text: "Hello").native.property("innerHTML")
children = Nokogiri::HTML5.fragment(inner_html).children
assert_pattern do
children => [
{ name: "span", inner_html: "Hello" },
{ name: "br" },
{ name: "span", inner_html: "World" }
]
end
end
test "dragging card to a new column" do
sign_in_as(users(:david))
@@ -105,4 +137,12 @@ class SmokeTest < ApplicationSystemTestCase
editor_element.set with
page.execute_script("arguments[0].value = '#{with}'", editor_element)
end
def paste_markdown(markdown)
page.execute_script(<<~JS, markdown)
const dt = new DataTransfer();
dt.setData("text/plain", arguments[0]);
document.activeElement.dispatchEvent(new ClipboardEvent("paste", { clipboardData: dt, bubbles: true }));
JS
end
end