Skip to content

Commit

Permalink
Merge pull request #73 from onfido/test/fix-evidence-folder-test
Browse files Browse the repository at this point in the history
test: wait for evidence folder to be available
  • Loading branch information
sofia-gomes-onfido authored Jan 20, 2025
2 parents f42657f + 7c62593 commit 7cad17e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 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
4 changes: 3 additions & 1 deletion spec/integrations/workflow_run_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@
end

it 'downloads an evidence folder' do
file = onfido_api.download_evidence_folder(workflow_run_id)
file = repeat_request_unti_http_code_changes do
onfido_api.download_evidence_folder(workflow_run_id)
end

Zip::File.open(file.path) do |zip|
expect(zip.entries.size).to be > 0
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 7cad17e

Please sign in to comment.