Skip to content

Commit

Permalink
test: increase number of retries until expected change happens
Browse files Browse the repository at this point in the history
To avoid test flakiness, we are increasing the nuber of retries.
  • Loading branch information
sofia-gomes-onfido committed Jan 20, 2025
1 parent 1042804 commit 7c62593
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions spec/integrations/report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ def sort_reports(reports_list)
end

it 'finds a report' do
get_document_report = onfido_api.find_report(document_report_id)
get_document_report = repeat_request_until_status_changes(Onfido::ReportStatus::COMPLETE) {
onfido_api.find_report(document_report_id)
}
get_identity_report = onfido_api.find_report(identity_report_id)

expect(get_document_report).to be_an_instance_of Onfido::DocumentReport
expect(get_document_report.id).to eq document_report_id
expect(get_document_report.name).to eq Onfido::ReportName::DOCUMENT
expect(get_document_report.status).to eq Onfido::ReportStatus::AWAITING_DATA
expect(get_document_report.status).to eq Onfido::ReportStatus::COMPLETE

expect(get_identity_report).to be_an_instance_of Onfido::IdentityEnhancedReport
expect(get_identity_report.id).to eq identity_report_id
Expand Down
6 changes: 3 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
Kernel.srand config.seed
end

def repeat_request_until_status_changes(expected_status, max_retries = 10,
def repeat_request_until_status_changes(expected_status, max_retries = 15,
interval = 1, &proc)
# expected_status --> desired status
# max_retries --> how many times to retry the request
Expand All @@ -86,7 +86,7 @@ def repeat_request_until_status_changes(expected_status, max_retries = 10,
instance
end

def repeat_request_until_task_output_changes(max_retries = 10,
def repeat_request_until_task_output_changes(max_retries = 15,
interval = 1, &proc)
# max_retries --> how many times to retry the request
# interval --> how many seconds to wait until the next retry
Expand All @@ -106,7 +106,7 @@ def repeat_request_until_task_output_changes(max_retries = 10,
instance
end

def repeat_request_unti_http_code_changes(max_retries = 10,
def repeat_request_unti_http_code_changes(max_retries = 15,
interval = 1, &proc)
# max_retries --> how many times to retry the request
# interval --> how many seconds to wait until the next retry
Expand Down

0 comments on commit 7c62593

Please sign in to comment.