59dd8ca549
In order for model ordering to work as expected in tests, we need to
keep two properties:
- Fixtures are all created in the past
- Models sort in the order that they were created
This allows us to do things like this:
post cards_path, params: { ... }
created_card = Card.last
When using UUIDv7 PKs rather than sequential integers, we have to make
sure a couple of things happen in order for this still to be true:
- Fixtures should generate deterministic IDs that translate to UUIDs
that would have been created in the past (i.e. before today)
- Newly created objects must have enough precision in their timestamps
so that they sort in the order they were created, and their random
component doesn't come into play.
To solve this, we use the deterministic numeric ID as a number of
milliseconds after an early year. And we ensure that the new timestamps
we create have sub-millisecond precision.
62 lines
1.7 KiB
Ruby
62 lines
1.7 KiB
Ruby
require "application_system_test_case"
|
|
|
|
class SmokeTest < ApplicationSystemTestCase
|
|
test "create a card" do
|
|
sign_in_as(users(:david))
|
|
|
|
visit board_url(boards(:writebook))
|
|
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 "h3", 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
|
|
|
|
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"
|
|
|
|
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
|
|
sign_in_as(users(:david))
|
|
|
|
notif = notifications(:logo_comment_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.identity.transfer_id, script_name: nil)
|
|
assert_selector "h1", text: "Latest 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
|
|
end
|