-
Notifications
You must be signed in to change notification settings - Fork 0
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
FI-3463: DTR Light EHR: test supported payer endpoint #42
base: main
Are you sure you want to change the base?
Changes from 5 commits
db1e90d
72cc18f
6a7a850
31cec0c
a9543e0
209fa37
078f816
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require_relative 'dtr_light_ehr_supported_payer_endpoint_test' | ||
|
||
module DaVinciDTRTestKit | ||
class DTRLightEhrSupportedEndpointsGroup < Inferno::TestGroup | ||
id :dtr_light_ehr_supported_endpoints | ||
title 'DTR Supported Endpoints' | ||
description %( | ||
Demonstrate the ability to access supported endpoints | ||
) | ||
run_as_group | ||
|
||
test from: :dtr_light_ehr_supported_payer_endpoint | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require_relative '../../urls' | ||
|
||
module DaVinciDTRTestKit | ||
class DtrLightEhrSupportedPayerEndpointTest < Inferno::Test | ||
include URLs | ||
id :dtr_light_ehr_supported_payer_endpoint | ||
title 'Client can retrieve payers from supported payer endpoint' | ||
description %( | ||
Inferno, will wait for a request to return the payer details from the supported endpoint. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a description of what this test checks. something like, 'This test verifies that the app can successfully access the supported payer endpoint via a GET request, including an |
||
) | ||
input :access_token, | ||
description: %( | ||
`Bearer` token that the client under test will send in the | ||
`Authorization` header of each HTTP request to Inferno. Inferno | ||
will look for this value to associate requests with this session. | ||
) | ||
|
||
run do | ||
wait( | ||
identifier: access_token, | ||
message: %( | ||
### Supported Payer Endpoint | ||
|
||
Inferno will wait for the Light EHR to to make a GET request to | ||
|
||
`#{supported_payer_url}` | ||
|
||
Inferno will return the static payers json details | ||
|
||
### Request Identification | ||
|
||
In order to identify requests for this session, Inferno will look for | ||
an `Authorization` header with value: | ||
|
||
``` | ||
Bearer #{access_token} | ||
``` | ||
) | ||
) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
require_relative 'profiles/service_request_group' | ||
require_relative 'profiles/task_group' | ||
require_relative 'profiles/vision_prescription_group' | ||
require_relative 'endpoints/mock_payer/light_ehr_supported_payer_endpoint' | ||
require_relative 'client_groups/light_ehr/dtr_light_ehr_supported_endpoints_group' | ||
require 'smart_app_launch/smart_stu1_suite' | ||
require 'smart_app_launch/smart_stu2_suite' | ||
|
||
|
@@ -55,6 +57,8 @@ class DTRLightEHRSuite < Inferno::TestSuite | |
end | ||
end | ||
|
||
suite_endpoint :get, SUPPORTED_PAYER_PATH, MockPayer::LightEHRSupportedPayerEndpoint | ||
|
||
group do | ||
title 'Authorization' | ||
|
||
|
@@ -136,5 +140,17 @@ class DTRLightEHRSuite < Inferno::TestSuite | |
group from: :task_group | ||
group from: :vision_prescription_group | ||
end | ||
|
||
group do | ||
title 'DTR Light EHR Supported Endpoints' | ||
description %(This test group tests system for their conformance to | ||
the supported endpoint capabilities as defined by the DaVinci Documentation | ||
Templates and Rules (DTR) v2.0.1 Implementation Guide Light DTR EHR | ||
Capability Statement. | ||
|
||
) | ||
|
||
group from: :dtr_light_ehr_supported_endpoints | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don’t need to nest |
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require_relative '../mock_payer' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be removed, since no functionality from that module is being used here. |
||
require_relative '../../tags' | ||
|
||
module DaVinciDTRTestKit | ||
module MockPayer | ||
class LightEHRSupportedPayerEndpoint < Inferno::DSL::SuiteEndpoint | ||
include MockPayer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this as well |
||
|
||
def name | ||
'light_ehr_supported_payer_endpoint' | ||
end | ||
|
||
def test_run_identifier | ||
request.headers['authorization']&.delete_prefix('Bearer ') | ||
end | ||
|
||
def tags | ||
[SUPPORTED_PAYER_TAG] | ||
end | ||
|
||
def make_response | ||
puts "Request method: #{request.request_method}" | ||
if request.headers['Accept'] != 'application/json' | ||
response.status = 406 | ||
response.headers['Content-Type'] = 'application/json' | ||
response.body = { error: 'Not Acceptable', message: 'Accept header must be application/json' }.to_json | ||
return | ||
end | ||
|
||
response.status = 200 | ||
response.headers['Content-Type'] = 'application/json' | ||
response.body = { | ||
payers: [ | ||
{ id: 'payer1', name: 'Payer One' }, | ||
{ id: 'payer2', name: 'Payer Two' } | ||
] | ||
}.to_json | ||
end | ||
|
||
def update_result | ||
results_repo.update_result(result.id, 'pass') unless test.config.options[:accepts_multiple_requests] | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modify this logic so that it fails if the |
||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
require_relative '../request_helper' | ||
|
||
RSpec.describe DaVinciDTRTestKit::DTRLightEhrSupportedEndpointsGroup do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. write spec for the Test directly instead of the group. |
||
include Rack::Test::Methods | ||
include RequestHelpers | ||
|
||
def app | ||
Inferno::Web.app | ||
end | ||
|
||
let(:suite_id) { :dtr_light_ehr } | ||
let(:resume_pass_url) { "/custom/#{suite_id}/resume_pass" } | ||
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 } | ||
let(:results_repo) { Inferno::Repositories::Results.new } | ||
|
||
def run(runnable, test_session, inputs = {}) | ||
test_run_params = { test_session_id: test_session.id }.merge(runnable.reference_hash) | ||
test_run = Inferno::Repositories::TestRuns.new.create(test_run_params) | ||
inputs.each do |name, value| | ||
session_data_repo.save( | ||
test_session_id: test_session.id, | ||
name:, | ||
value:, | ||
type: runnable.config.input_type(name) || :text | ||
) | ||
end | ||
Inferno::TestRunner.new(test_session:, test_run:).run(runnable) | ||
end | ||
|
||
describe 'Supported Payers Endpoint' do | ||
let(:runnable) { Inferno::Repositories::TestGroups.new.find('light_ehr_supported_payer_endpoint') } | ||
|
||
it 'passes when a request is made to the supported payers endpoint' do | ||
header 'Accept', 'application/json' | ||
get '/supported-payers' | ||
|
||
expect(last_response.status).to eq(200) | ||
expect(last_response.content_type).to eq('application/json') | ||
expect(JSON.parse(last_response.body)['payers']).to be_an(Array) | ||
|
||
result = repo_create(:result, test_session_id: test_session.id) | ||
repo_create(:request, result_id: result.id, name: 'supported_payers', request_body: nil, | ||
test_session_id: test_session.id, tags: ['supported_payers']) | ||
|
||
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) | ||
expect(result.result).to eq('pass') | ||
end | ||
|
||
it 'returns 406 when Accept header is missing or incorrect' do | ||
get '/supported-payers' | ||
|
||
expect(last_response.status).to eq(406) | ||
expect(JSON.parse(last_response.body)['error']).to eq('Not Acceptable') | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.