Introduce a few system tests

Primarily I'm trying to exercise active storage and action cable /
turbo streams, both of which have been brittle when making changes to
tenanting.
This commit is contained in:
Mike Dalessio
2025-09-13 13:18:32 -04:00
parent 1ffc2ee9b7
commit 5dec991d7c
3 changed files with 100 additions and 6 deletions
+67
View File
@@ -0,0 +1,67 @@
require "application_system_test_case"
class SmokeTest < ApplicationSystemTestCase
test "create a card" do
sign_in_as(users(:david))
visit cards_url(collection_ids: [ collections(:writebook).id ])
click_on "Add a card"
fill_in "card_title", with: "Hello, world!"
fill_in_lexxy with: "I am editing this thing"
click_on "Create card"
assert_selector "h1", text: "Hello, world!"
end
test "active storage attachments" do
sign_in_as(users(:david))
visit card_url(cards(:layout))
fill_in_lexxy with: "Here is a comment"
attach_file file_fixture("moon.jpg") do
click_on "Upload file"
end
assert_image_figure_attachment content_type: "image/jpeg", caption: "moon.jpg"
click_on "Post this comment"
assert_image_figure_attachment content_type: "image/jpeg", caption: "moon.jpg"
end
test "dismissing notifications" do
sign_in_as(users(:david))
notif = notifications(:logo_card_david_mention_by_jz)
assert_selector "div##{dom_id(notif)}"
within_window(open_new_window) { visit card_url(notif.card) }
assert_no_selector "div##{dom_id(notif)}"
end
private
def sign_in_as(user)
visit session_transfer_url(user.transfer_id)
assert_selector "h1", text: "Activity"
end
def fill_in_lexxy(selector = "lexxy-editor", with:)
editor_element = find(selector)
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']")
assert_selector "figcaption input[placeholder='#{caption}']"
end
end
end