Skip to content

Commit

Permalink
Use wait instead of sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
mpw5 committed Dec 20, 2023
1 parent cecb14f commit 0ea30fe
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 29 deletions.
7 changes: 4 additions & 3 deletions features/step_definitions/advocate_claim_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
end

When(/^I select the advocate offence class '(.*)'$/) do |offence_class|
sleep 1
@claim_form_page.select_offence_class(offence_class)
using_wait_time 1 do
@claim_form_page.select_offence_class(offence_class)
end
end

When(/I enter (.*?)(retrial|trial) start and end dates(?: with (\d+) day interval)?$/i) do |scheme_text, trial_type, interval|
Expand Down Expand Up @@ -167,7 +168,7 @@
@claim_form_page.miscellaneous_fees.last.govuk_fee_type_autocomplete.choose_autocomplete_option(fee_name)
@claim_form_page.miscellaneous_fees.last.govuk_fee_type_autocomplete_input.send_keys(:tab)

sleep(2)
# sleep(2)
wait_for_debounce
wait_for_ajax
end
Expand Down
46 changes: 24 additions & 22 deletions features/step_definitions/common_claim_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,34 +130,36 @@
end

When(/^I click "Continue" I should be on the 'Case details' page and see a "([^"]*)" error$/) do |error_message|
sleep 3
@claim_form_page.continue_button.click
wait_for_ajax
using_wait_time(6) do
if !page.has_content?(error_message)
#clicking again because the first one didn't work
@claim_form_page.continue_button.click
wait_for_ajax
end
within('div.govuk-error-summary') do
expect(page).to have_content(error_message)
using_wait_time 3 do
@claim_form_page.continue_button.click
wait_for_ajax
using_wait_time(6) do
if !page.has_content?(error_message)
#clicking again because the first one didn't work
@claim_form_page.continue_button.click
wait_for_ajax
end
within('div.govuk-error-summary') do
expect(page).to have_content(error_message)
end
end
end
end

When(/^I click "Continue" in the claim form and move to the '(.*?)' form page$/) do |page_title|
original_header = page.first('h2.govuk-heading-l').text
sleep 3
@claim_form_page.continue_button.click
wait_for_ajax
using_wait_time(6) do
if page.first('h2.govuk-heading-l').text.eql?(original_header)
#clicking again because the first one didn't work
@claim_form_page.continue_button.click
wait_for_ajax
end
within('#claim-form') do
expect(page.first('h2.govuk-heading-l')).to have_content(page_title)
using_wait_time 3 do
@claim_form_page.continue_button.click
wait_for_ajax
using_wait_time(6) do
if page.first('h2.govuk-heading-l').text.eql?(original_header)
#clicking again because the first one didn't work
@claim_form_page.continue_button.click
wait_for_ajax
end
within('#claim-form') do
expect(page.first('h2.govuk-heading-l')).to have_content(page_title)
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/messaging_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

When(/^I click send$/) do
@external_user_claim_show_page.messages_panel.send.click
sleep 1
# sleep 1
end

Then(/^the claim should be visible with 1 new message$/) do
Expand Down
7 changes: 4 additions & 3 deletions features/step_definitions/offence_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

# AGFS 10/11 only
Then(/^I select the first search result$/) do
sleep 1
find(:xpath, '//*[@id="offence-list"]/div[3]/div').hover
find(:xpath, '//*[@id="offence-list"]/div[3]/div/div[2]/a').click
using_wait_time 1 do
find(:xpath, '//*[@id="offence-list"]/div[3]/div').hover
find(:xpath, '//*[@id="offence-list"]/div[3]/div/div[2]/a').click
end
wait_for_ajax
end

Expand Down

0 comments on commit 0ea30fe

Please sign in to comment.