Skip to content

Commit

Permalink
get greedy, try additional test with retry
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed Oct 17, 2024
1 parent 306f556 commit af3dc93
Showing 1 changed file with 50 additions and 37 deletions.
87 changes: 50 additions & 37 deletions tests/rails/test/system/attachment_galleries_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,57 +78,70 @@ def check
end

test "Should not allow to insert multiple attachments in the gallery are inserted at the same time" do
page.get_by_role('link', name: /New Post/i).click
def run_test
page.get_by_role('link', name: /New Post/i).click

wait_for_network_idle
wait_for_network_idle

files = [
"screenshot-1.png",
"addresses.csv"
]
files = [
"screenshot-1.png",
"addresses.csv"
]

page.locator("rhino-editor").nth(0).click
attach_files(files)
page.wait_for_selector(".attachment-gallery .attachment[sgid]", state: "visible")
page.wait_for_selector(":not(.attachment-gallery) .attachment[sgid]", state: "visible")
page.locator("rhino-editor").nth(0).click
attach_files(files)
page.wait_for_selector(".attachment-gallery .attachment[sgid]", state: "visible")
page.wait_for_selector(":not(.attachment-gallery) .attachment[sgid]", state: "visible")

def check
wait_for_network_idle
def check
wait_for_network_idle

page.locator("body").click
assert page.locator(".attachment-gallery .attachment").nth(0).wait_for(state: 'visible')
assert page.locator(".attachment").nth(1).wait_for(state: 'visible')
page.locator("body").click
assert page.locator(".attachment-gallery .attachment").nth(0).wait_for(state: 'visible')
assert page.locator(".attachment").nth(1).wait_for(state: 'visible')

assert_equal page.locator(".attachment-gallery .attachment").count, 1
assert_equal page.locator(".attachment").count, 2
page.locator("body").click
end
assert_equal page.locator(".attachment-gallery .attachment").count, 1
assert_equal page.locator(".attachment").count, 2
page.locator("body").click
end

check
check

# For some silly reason, this test only fails in GH Actions
return if ENV["CI"] == "true"
# For some silly reason, this test only fails in GH Actions
# return if ENV["CI"] == "true"

# Save the attachment, make sure we render properly.
page.get_by_role('button', name: /Create Post/i).click
# Save the attachment, make sure we render properly.
page.get_by_role('button', name: /Create Post/i).click

assert page.get_by_text("Post was successfully created")
check
assert page.get_by_text("Post was successfully created")
check

# Go back and edit the file and make sure it renders properly in editor
page.get_by_role('link', name: /Edit this post/i).click
# Go back and edit the file and make sure it renders properly in editor
page.get_by_role('link', name: /Edit this post/i).click

assert page.get_by_text("Editing post")
assert page.get_by_text("Editing post")

check
check

# Go back and edit the file and make sure it renders properly in editor
page.get_by_role('link', name: /Show this post/i).click
wait_for_network_idle
page.locator("body").click
page.get_by_role('link', name: /Edit raw post/i).click
assert page.get_by_text("Editing raw post")
check
# Go back and edit the file and make sure it renders properly in editor
page.get_by_role('link', name: /Show this post/i).click
wait_for_network_idle
page.locator("body").click
page.get_by_role('link', name: /Edit raw post/i).click
assert page.get_by_text("Editing raw post")
check
end

count = 0

# Hacky retry
begin
run_test
rescue => e
count += 1
raise e if count > 2
run_test
end
end

test "Should not allow to insert multiple attachments in the gallery in sequence" do
Expand Down

0 comments on commit af3dc93

Please sign in to comment.