diff --git a/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_endpoints_group.rb b/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_endpoints_group.rb index 6674d66..cc43df1 100644 --- a/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_endpoints_group.rb +++ b/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_endpoints_group.rb @@ -3,10 +3,13 @@ module DaVinciDTRTestKit class DTRLightEhrSupportedEndpointsGroup < Inferno::TestGroup id :dtr_light_ehr_supported_endpoints - title 'DTR Supported Endpoints' - description %( - Demonstrate the ability to access supported endpoints - ) + title '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. + + ) run_as_group test from: :dtr_light_ehr_supported_payer_endpoint diff --git a/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_payer_endpoint_test.rb b/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_payer_endpoint_test.rb index 1f37db7..62668cc 100644 --- a/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_payer_endpoint_test.rb +++ b/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_payer_endpoint_test.rb @@ -1,12 +1,13 @@ require_relative '../../urls' module DaVinciDTRTestKit - class DtrLightEhrSupportedPayerEndpointTest < Inferno::Test + 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. + This test verifies that the app can successfully access the supported payer endpoint via a GET request, + including an Accept header set to application/json ) input :access_token, description: %( diff --git a/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb b/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb index 9361c05..ebbc9ac 100644 --- a/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb +++ b/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb @@ -57,7 +57,7 @@ class DTRLightEHRSuite < Inferno::TestSuite end end - suite_endpoint :get, SUPPORTED_PAYER_PATH, MockPayer::LightEHRSupportedPayerEndpoint + suite_endpoint :get, SUPPORTED_PAYER_PATH, LightEHRSupportedPayerEndpoint group do title 'Authorization' @@ -141,16 +141,6 @@ class DTRLightEHRSuite < Inferno::TestSuite 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 + group from: :dtr_light_ehr_supported_endpoints end end diff --git a/lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint.rb b/lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint.rb index 886ad62..61c32bd 100644 --- a/lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint.rb +++ b/lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint.rb @@ -1,44 +1,43 @@ -require_relative '../mock_payer' require_relative '../../tags' module DaVinciDTRTestKit - module MockPayer - class LightEHRSupportedPayerEndpoint < Inferno::DSL::SuiteEndpoint - include MockPayer - - def name - 'light_ehr_supported_payer_endpoint' - end - - def test_run_identifier - request.headers['authorization']&.delete_prefix('Bearer ') - end + class LightEHRSupportedPayerEndpoint < Inferno::DSL::SuiteEndpoint + def name + 'light_ehr_supported_payer_endpoint' + end - def tags - [SUPPORTED_PAYER_TAG] - end + def test_run_identifier + request.headers['authorization']&.delete_prefix('Bearer ') + 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 + def tags + [SUPPORTED_PAYER_TAG] + end - response.status = 200 + 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 = { - payers: [ - { id: 'payer1', name: 'Payer One' }, - { id: 'payer2', name: 'Payer Two' } - ] - }.to_json + response.body = { error: 'Not Acceptable', message: 'Accept header must be application/json' }.to_json + return end - def update_result - results_repo.update_result(result.id, 'pass') unless test.config.options[:accepts_multiple_requests] + 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 + if request.headers['Accept'] == 'application/json' + results_repo.update_result(result.id, 'pass') + else + results_repo.update_result(result.id, 'fail') end end end diff --git a/spec/davinci_dtr_test_kit/dtr_light_ehr_supported_endpoints_group_spec.rb b/spec/davinci_dtr_test_kit/dtr_light_ehr_supported_payer_endpoint_test_spec.rb similarity index 86% rename from spec/davinci_dtr_test_kit/dtr_light_ehr_supported_endpoints_group_spec.rb rename to spec/davinci_dtr_test_kit/dtr_light_ehr_supported_payer_endpoint_test_spec.rb index 11b64b4..dda3c34 100644 --- a/spec/davinci_dtr_test_kit/dtr_light_ehr_supported_endpoints_group_spec.rb +++ b/spec/davinci_dtr_test_kit/dtr_light_ehr_supported_payer_endpoint_test_spec.rb @@ -1,6 +1,6 @@ require_relative '../request_helper' -RSpec.describe DaVinciDTRTestKit::DTRLightEhrSupportedEndpointsGroup do +RSpec.describe DaVinciDTRTestKit::DTRLightEhrSupportedPayerEndpointTest do include Rack::Test::Methods include RequestHelpers @@ -8,9 +8,11 @@ def app Inferno::Web.app end + let(:group) { Inferno::Repositories::TestGroups.new.find('dtr_light_ehr_supported_payer_endpoint') } 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(:supported_payer_url) { "/custom/#{suite_id}/supported_payers" } 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 } @@ -35,7 +37,7 @@ def run(runnable, test_session, inputs = {}) it 'passes when a request is made to the supported payers endpoint' do header 'Accept', 'application/json' - get '/supported-payers' + get supported_payer_url expect(last_response.status).to eq(200) expect(last_response.content_type).to eq('application/json') @@ -43,7 +45,7 @@ def run(runnable, test_session, inputs = {}) 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']) + test_session_id: test_session.id, tags: [SUPPORTED_PAYER_TAG]) result = run(runnable, test_session) expect(result.result).to eq('wait') @@ -56,7 +58,7 @@ def run(runnable, test_session, inputs = {}) end it 'returns 406 when Accept header is missing or incorrect' do - get '/supported-payers' + get supported_payer_url expect(last_response.status).to eq(406) expect(JSON.parse(last_response.body)['error']).to eq('Not Acceptable')