Skip to content

Commit b0ff724

Browse files
authored
chore: actions flaky test (#3574)
* chore: actions flaky test * . * lint
1 parent b7d7b34 commit b0ff724

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/avo/wait_for_loaded.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ def wait_for_body_class_missing(klass = "turbo-loading", time = Capybara.default
4545
puts "\n\nMethod '#{__method__}' raised 'Timeout::Error' after #{time}s"
4646
end
4747

48+
def wait_for_path_to_be(path:, time: Capybara.default_max_wait_time)
49+
Timeout.timeout(time) do
50+
break if current_path == path
51+
end
52+
rescue Timeout::Error
53+
puts "\n\nMethod '#{__method__}' raised 'Timeout::Error' after #{time}s"
54+
end
55+
4856
def wait_for_element_missing(identifier = ".element", time = Capybara.default_max_wait_time)
4957
Timeout.timeout(time) do
5058
if page.present?

spec/system/avo/actions_spec.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,11 @@
213213
click_on "Actions"
214214
click_on "Redirect to Posts"
215215

216-
wait_for_loaded
217-
218-
expect(current_path).to eq avo.resources_posts_path
216+
wait_for_path_to_be(path: avo.resources_posts_path)
219217

220218
page.go_back
221-
wait_for_loaded
222219

223-
expect(current_path).to eq avo.resources_users_path
220+
wait_for_path_to_be(path: avo.resources_users_path)
224221
end
225222
end
226223

0 commit comments

Comments
 (0)