Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve speed of cucumber test suite #6362

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ jobs:
cucumber-tests:
executor: test-executor
resource_class: small
parallelism: 6
parallelism: 8
steps:
- checkout
- run:
Expand Down
3 changes: 2 additions & 1 deletion db/seeds/scheme_11.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
ActiveRecord::Base.connection.set_pk_sequence!('offences', 3000) if Offence.order(:id).last.id < 3000

# create new offences (from csv)
file_path = Rails.root.join('lib', 'assets', 'data', 'scheme_11_offences.csv')
file_name = ENV.fetch('RAILS_ENV', 'development') == 'test' ? 'scheme_11_offences_for_testing.csv' : 'scheme_11_offences.csv'
file_path = Rails.root.join('lib', 'assets', 'data', file_name)
csv_file = File.open(file_path, 'r:ISO-8859-1')
csv = CSV.parse(csv_file, headers: true)

Expand Down
6 changes: 3 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,6 @@
@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)
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
1 change: 0 additions & 1 deletion features/step_definitions/messaging_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

When(/^I click send$/) do
@external_user_claim_show_page.messages_panel.send.click
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 Capybara.default_max_wait_time
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
10 changes: 10 additions & 0 deletions lib/assets/data/scheme_11_offences_for_testing.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
category,band,description,contrary_to,year_chapter
3,3.4,Possession of offensive weapon on school premises,"Criminal Justice Act 1988, s.139A",1996 c. 26
3,3.5,Racially or religiously aggravated common assault,"Crime and Disorder Act 1998, s.29(1)(c ) and (3)",1998 c. 37
5,5.3,Solicitation by men,"Sexual Offences Act 1956, s.32",1956 c. 69
8,8.1,Harbouring escaped prisoner,"Criminal Justice Act 1961, s.22(2)",1961 c. 39
8,8.1,Have in possession or control identity documents with improper intent,"Identity Documents Act 2010, s.4",2010 c. 40
11,11.2,Burglary (domestic),"Theft Act 1968, s.9(3)(a)",1968 c. 60
11,11.2,Burglary (non-domestic),"Theft Act 1968, s.9(3)(b)",1968 c. 60
16,16.3,Unlicensed or unauthorised air traffic controllers,Air Navigation Order 2016,2016 No. 765
17,17.1,Absconding from lawful custody,Common Law,