Skip to content

Commit

Permalink
implement retry
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed Oct 17, 2024
1 parent 1282c97 commit 306f556
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 @@ -132,57 +132,70 @@ def check
end

test "Should not allow to insert multiple attachments in the gallery in sequence" 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",
]
files = [
"screenshot-1.png",
]

attach_files(files)
page.wait_for_selector(".attachment-gallery .attachment[sgid]", state: "visible")
attach_files(files)
page.wait_for_selector(".attachment-gallery .attachment[sgid]", state: "visible")

files = [
"addresses.csv"
]
files = [
"addresses.csv"
]

attach_files(files)
page.wait_for_selector(":not(.attachment-gallery) .attachment[sgid]", state: "visible")
attach_files(files)
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

# 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
end

0 comments on commit 306f556

Please sign in to comment.