Skip to content

Commit

Permalink
Simplified obtaining the token identifier for the unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
degradification committed Nov 21, 2024
1 parent 923df2f commit b3d3e2f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ class DTRQuestionnaireRenderingAttestationTest < Inferno::Test
questionnaire package and attest that the application renders the questionnaire.
)

config(options: { token: SecureRandom.uuid })

def token
config.options[:token]
end

run do
load_tagged_requests QUESTIONNAIRE_PACKAGE_TAG
skip_if request.blank?, 'A Questionnaire Package request must be made prior to running this test'
token = SecureRandom.uuid

wait(
identifier: token,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def app
let(:resume_fail_url) { "/custom/#{suite_id}/resume_fail" }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:test_session) { repo_create(:test_session, test_suite_id: suite_id) }
let(:test_runs_repo) { Inferno::Repositories::TestRuns.new }

def run(runnable, test_session, inputs = {})
test_run_params = { test_session_id: test_session.id }.merge(runnable.reference_hash)
Expand All @@ -29,11 +30,6 @@ def run(runnable, test_session, inputs = {})
describe 'Behavior of questionnaire rendering attestation test' do
let(:runnable) { group.tests.find { |test| test.id.to_s.end_with? 'dtr_questionnaire_rendering_attestation' } }
let(:results_repo) { Inferno::Repositories::Results.new }
let(:token) { '1234' }

before do
allow_any_instance_of(runnable).to receive(:token).and_return(token)
end

it 'passes if affirmative attestation is given' do
# For some reason it seems to completely ignore an allow...receive for resume_pass_url, so do this instead
Expand All @@ -48,6 +44,7 @@ def run(runnable, test_session, inputs = {})
result = run(runnable, test_session)
expect(result.result).to eq('wait')

token = test_runs_repo.last_test_run(test_session.id).identifier
get("#{resume_pass_url}?token=#{token}")

result = results_repo.find(result.id)
Expand All @@ -67,6 +64,7 @@ def run(runnable, test_session, inputs = {})
result = run(runnable, test_session)
expect(result.result).to eq('wait')

token = test_runs_repo.last_test_run(test_session.id).identifier
get("#{resume_fail_url}?token=#{token}")

result = results_repo.find(result.id)
Expand Down

0 comments on commit b3d3e2f

Please sign in to comment.