Skip to content

Commit

Permalink
Updated parameter in dtr_questionnaire_rendering_attestation_test.rb …
Browse files Browse the repository at this point in the history
…to use token instead of client_id

-Addressed rubocop warnings
-Changed lib/davinci_dtr_test_kit/dtr_smart_app_suite.rb to extract the session identifier from the new parameter name using the extract_token_from_query_params
-Updated tests to use the correct token definition
  • Loading branch information
degradification committed Nov 19, 2024
1 parent 84bf302 commit e0ccd78
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ class DTRQuestionnaireRenderingAttestationTest < Inferno::Test
This test provides the tester an opportunity to observe their client application following the receipt of the
questionnaire package and attest that the application renders the questionnaire.
)
input :client_id

def token
SecureRandom.uuid
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'

wait(
identifier: client_id,
identifier: token,
message: %(
I attest that the client application displays the questionnaire and respects the following rendering style:
- The "Signature" field label is rendered with green text
[Click here](#{resume_pass_url}?client_id=#{client_id}) if the above statement is **true**.
[Click here](#{resume_pass_url}?token=#{token}) if the above statement is **true**.
[Click here](#{resume_fail_url}?client_id=#{client_id}) if the above statement is **false**.
[Click here](#{resume_fail_url}?token=#{token}) if the above statement is **false**.
)
)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/davinci_dtr_test_kit/dtr_smart_app_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ class DTRSmartAppSuite < Inferno::TestSuite
end

resume_test_route :get, RESUME_PASS_PATH do |request|
DTRSmartAppSuite.extract_client_id_from_query_params(request)
DTRSmartAppSuite.extract_token_from_query_params(request)
end

resume_test_route :get, RESUME_FAIL_PATH, result: 'fail' do |request|
DTRSmartAppSuite.extract_client_id_from_query_params(request)
DTRSmartAppSuite.extract_token_from_query_params(request)
end

# TODO: Update based on SMART Launch changes. Do we even want to have this group now?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def run(runnable, test_session, inputs = {})
test_session_id: test_session.id,
name:,
value:,
type: runnable.config.input_type(name)
type: runnable.config.input_type(name) || :text
)
end
Inferno::TestRunner.new(test_session:, test_run:).run(runnable)
Expand All @@ -29,7 +29,11 @@ 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(:client_id) { '1234' }
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 @@ -41,10 +45,10 @@ def run(runnable, test_session, inputs = {})
repo_create(:request, result_id: result.id, name: 'questionnaire_package', request_body: nil,
test_session_id: test_session.id, tags: [DaVinciDTRTestKit::QUESTIONNAIRE_PACKAGE_TAG])

result = run(runnable, test_session, client_id:)
result = run(runnable, test_session)
expect(result.result).to eq('wait')

get("#{resume_pass_url}?client_id=#{client_id}")
get("#{resume_pass_url}?token=#{token}")

result = results_repo.find(result.id)
expect(result.result).to eq('pass')
Expand All @@ -60,10 +64,10 @@ def run(runnable, test_session, inputs = {})
repo_create(:request, result_id: result.id, name: 'questionnaire_package', request_body: nil,
test_session_id: test_session.id, tags: [DaVinciDTRTestKit::QUESTIONNAIRE_PACKAGE_TAG])

result = run(runnable, test_session, client_id:)
result = run(runnable, test_session)
expect(result.result).to eq('wait')

get("#{resume_fail_url}?client_id=#{client_id}")
get("#{resume_fail_url}?token=#{token}")

result = results_repo.find(result.id)
expect(result.result).to eq('fail')
Expand Down

0 comments on commit e0ccd78

Please sign in to comment.