From e682f2742d38fc585c594135e67975fef7aec6c3 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 3 Nov 2025 15:12:39 -0500 Subject: [PATCH] test: Fix the flaky smoke test on attachments --- test/system/smoke_test.rb | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/test/system/smoke_test.rb b/test/system/smoke_test.rb index 7e0b5e74b..cc84bfef2 100644 --- a/test/system/smoke_test.rb +++ b/test/system/smoke_test.rb @@ -22,11 +22,17 @@ class SmokeTest < ApplicationSystemTestCase click_on "Upload file" end - assert_image_figure_attachment content_type: "image/jpeg", caption: "moon.jpg" + within("form lexxy-editor figure.attachment[data-content-type='image/jpeg']") do + assert_selector "img[src*='/rails/active_storage']" + assert_selector "figcaption input[placeholder='moon.jpg']" + end click_on "Post this comment" - assert_image_figure_attachment content_type: "image/jpeg", caption: "moon.jpg" + within("action-text-attachment") do + assert_selector "a img[src*='/rails/active_storage']" + assert_selector "figcaption span.attachment__name", text: "moon.jpg" + end end test "dismissing notifications" do @@ -53,16 +59,4 @@ class SmokeTest < ApplicationSystemTestCase editor_element.set with page.execute_script("arguments[0].value = '#{with}'", editor_element) end - - def assert_figure_attachment(content_type:, &block) - figure = find("figure.attachment[data-content-type='#{content_type}']") - within(figure, &block) if block_given? - end - - def assert_image_figure_attachment(content_type: "image/png", caption:) - assert_figure_attachment(content_type: content_type) do - assert_selector "img[src*='/rails/active_storage']", wait: 10 - assert_selector "figcaption input[placeholder='#{caption}']", wait: 10 - end - end end