Skip to content

Commit

Permalink
[Automated] Merged master into target k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
va-vsp-bot authored Apr 12, 2024
2 parents 65f9e7b + 4ee9a78 commit 2a87305
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 62 deletions.
1 change: 1 addition & 0 deletions lib/common/client/concerns/mhv_fhir_session_client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'common/client/concerns/mhv_jwt_session_client'
require 'medical_records/patient_not_found'

module Common
module Client
Expand Down
26 changes: 8 additions & 18 deletions modules/simple_forms_api/spec/requests/v1/uploads_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'rails_helper'
require 'simple_forms_api_submission/metadata_validator'
require 'common/file_helpers'

RSpec.describe 'Forms uploader', type: :request do
non_ivc_forms = [
Expand Down Expand Up @@ -30,6 +31,13 @@
]

describe '#submit' do
let(:metadata_file) { "#{file_seed}.SimpleFormsApi.metadata.json" }
let(:file_seed) { 'tmp/some-unique-simple-forms-file-seed' }

before { allow(Common::FileHelpers).to receive(:random_file_path).and_return(file_seed) }

after { Common::FileHelpers.delete_file_if_exists(metadata_file) }

non_ivc_forms.each do |form|
fixture_path = Rails.root.join('modules', 'simple_forms_api', 'spec', 'fixtures', 'form_json', form)
data = JSON.parse(fixture_path.read)
Expand All @@ -43,9 +51,6 @@

expect(SimpleFormsApiSubmission::MetadataValidator).to have_received(:validate)
expect(response).to have_http_status(:ok)
ensure
metadata_file = Dir['tmp/*.SimpleFormsApi.metadata.json'][0]
Common::FileHelpers.delete_file_if_exists(metadata_file) if defined?(metadata_file)
end
end
end
Expand All @@ -58,9 +63,6 @@
expect do
post '/simple_forms_api/v1/simple_forms', params: data
end.to change(FormSubmissionAttempt, :count).by(1)
ensure
metadata_file = Dir['tmp/*.SimpleFormsApi.metadata.json'][0]
Common::FileHelpers.delete_file_if_exists(metadata_file) if defined?(metadata_file)
end
end
end
Expand All @@ -85,9 +87,6 @@
expect do
post '/simple_forms_api/v1/simple_forms', params: data
end.to change(InProgressForm, :count).by(-1)
ensure
metadata_file = Dir['tmp/*.SimpleFormsApi.metadata.json'][0]
Common::FileHelpers.delete_file_if_exists(metadata_file) if defined?(metadata_file)
end
end
end
Expand Down Expand Up @@ -201,9 +200,6 @@
expect_any_instance_of(SimpleFormsApi::PdfFiller).to receive(:generate).with(3)

post '/simple_forms_api/v1/simple_forms', params: data
ensure
metadata_file = Dir['tmp/*.SimpleFormsApi.metadata.json'][0]
Common::FileHelpers.delete_file_if_exists(metadata_file) if defined?(metadata_file)
end
end
end
Expand All @@ -225,9 +221,6 @@
post '/simple_forms_api/v1/simple_forms', params: data

expect(response).to have_http_status(:ok)
ensure
metadata_file = Dir['tmp/*.SimpleFormsApi.metadata.json'][0]
Common::FileHelpers.delete_file_if_exists(metadata_file) if defined?(metadata_file)
end
end
end
Expand All @@ -244,9 +237,6 @@
expect(PersistentAttachment).to receive(:where).with(guid: ['a-random-uuid']).and_return([attachment])
post '/simple_forms_api/v1/simple_forms', params: data
expect(response).to have_http_status(:ok)
ensure
metadata_file = Dir['tmp/*.SimpleFormsApi.metadata.json'][0]
Common::FileHelpers.delete_file_if_exists(metadata_file) if defined?(metadata_file)
end
end
end
Expand Down
36 changes: 11 additions & 25 deletions spec/controllers/v0/virtual_agent/virtual_agent_claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@
end

describe 'GET /v0/virtual_agent/claim' do
let!(:claim) do
FactoryBot.create(:evss_claim, id: 11, evss_id: 600_118_854,
user_uuid: user.uuid)
FactoryBot.create(:evss_claim, id: 22, evss_id: 600_118_855,
user_uuid: user.uuid)
FactoryBot.create(:evss_claim, id: 33, evss_id: 600_118_851,
user_uuid: user.uuid)
end
let!(:claim1) { FactoryBot.create(:evss_claim, evss_id: 600_118_854, user_uuid: user.uuid) }
let!(:claim2) { FactoryBot.create(:evss_claim, evss_id: 600_118_855, user_uuid: user.uuid) }
let!(:claim3) { FactoryBot.create(:evss_claim, evss_id: 600_118_851, user_uuid: user.uuid) }

it 'returns information on multiple open compensation claims in descending chronological order by updated date' do
sign_in_as(user)
Expand All @@ -41,13 +36,13 @@
EVSS::RetrieveClaimsFromRemoteJob.new.perform(user.uuid)
end
VCR.use_cassette('evss/claims/claim_with_docs1') do
EVSS::UpdateClaimFromRemoteJob.new.perform(user.uuid, 11)
EVSS::UpdateClaimFromRemoteJob.new.perform(user.uuid, claim1.id)
end
VCR.use_cassette('evss/claims/claim_with_docs2') do
EVSS::UpdateClaimFromRemoteJob.new.perform(user.uuid, 22)
EVSS::UpdateClaimFromRemoteJob.new.perform(user.uuid, claim2.id)
end
VCR.use_cassette('evss/claims/claim_with_docs3') do
EVSS::UpdateClaimFromRemoteJob.new.perform(user.uuid, 33)
EVSS::UpdateClaimFromRemoteJob.new.perform(user.uuid, claim3.id)
end

get '/v0/virtual_agent/claim'
Expand Down Expand Up @@ -81,10 +76,7 @@
end

describe 'for a single claim' do
let!(:claim) do
FactoryBot.create(:evss_claim, id: 3, evss_id: 600_118_851,
user_uuid: user.uuid)
end
let!(:claim) { FactoryBot.create(:evss_claim, evss_id: 600_118_851, user_uuid: user.uuid) }

it 'returns information on single open compensation claim' do
sign_in_as(user)
Expand All @@ -99,7 +91,7 @@
EVSS::RetrieveClaimsFromRemoteJob.new.perform(user.uuid)
end
VCR.use_cassette('evss/claims/claim_with_docs1') do
EVSS::UpdateClaimFromRemoteJob.new.perform(user.uuid, 3)
EVSS::UpdateClaimFromRemoteJob.new.perform(user.uuid, claim.id)
end

get '/v0/virtual_agent/claim'
Expand Down Expand Up @@ -183,10 +175,7 @@
end

describe 'for a user who has non-compensation and compensation claims' do
let!(:claim) do
FactoryBot.create(:evss_claim, id: 3, evss_id: 600_114_693,
user_uuid: user.uuid)
end
let!(:claim) { FactoryBot.create(:evss_claim, evss_id: 600_114_693, user_uuid: user.uuid) }

it 'returns information when there is a more recent non-compensation open claim' do
sign_in_as(user)
Expand All @@ -200,7 +189,7 @@
EVSS::RetrieveClaimsFromRemoteJob.new.perform(user.uuid)
end
VCR.use_cassette('evss/claims/claim_with_docs4') do
EVSS::UpdateClaimFromRemoteJob.new.perform(user.uuid, 3)
EVSS::UpdateClaimFromRemoteJob.new.perform(user.uuid, claim.id)
end

get '/v0/virtual_agent/claim'
Expand All @@ -218,10 +207,7 @@
end

describe 'GET /v0/virtual_agent/claim/{EVSS_ID}' do
let!(:claim) do
FactoryBot.create(:evss_claim, id: 1, evss_id: 600_117_255,
user_uuid: user.uuid)
end
let!(:claim) { FactoryBot.create(:evss_claim, evss_id: 600_117_255, user_uuid: user.uuid) }

it 'returns claims details of a specific claim' do
sign_in_as(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'rails_helper'
require 'medical_records/client_session'
require_relative '../../../../../lib/common/client/concerns/mhv_fhir_session_client'
require 'common/client/concerns/mhv_fhir_session_client'

describe Common::Client::Concerns::MhvFhirSessionClient do
let(:dummy_class) do
Expand Down
40 changes: 22 additions & 18 deletions spec/lib/simple_forms_api_submission/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,51 @@
require 'simple_forms_api_submission/service'

describe SimpleFormsApiSubmission::Service do
mock_metadata = '
{"veteranFirstName"=>"Veteran", "veteranLastName"=>"Surname", "fileNumber"=>"123456789",
"zipCode"=>"12345", "source"=>"test", "docType"=>"test", "businessLine"=>"OTH"}
'

before(:all) do
@service = SimpleFormsApiSubmission::Service.new
let(:mock_metadata) do
'{"veteranFirstName"=>"Veteran", "veteranLastName"=>"Surname", "fileNumber"=>"123456789",
"zipCode"=>"12345", "source"=>"test", "docType"=>"test", "businessLine"=>"OTH"}'
end

let(:simple_forms_service) { SimpleFormsApiSubmission::Service.new }
let(:file_seed) { 'some-unique-simple-forms-service-spec-file-seed' }

before { allow(SecureRandom).to receive(:hex).and_return(file_seed) }

describe 'get uuid and upload location' do
it 'retrieves uuid and upload location from the Lighthouse API' do
VCR.use_cassette('lighthouse/benefits_intake/200_lighthouse_intake_upload_location') do
response = @service.get_upload_location
response = simple_forms_service.get_upload_location
expect(response.status).to equal(200)
end
end
end

describe 'generate metadata file' do
let(:mock_file_path_metadata) { "#{file_seed}.SimpleFormsApi.metadata.json" }

it 'generates a json file from the metadata' do
@service.generate_tmp_metadata(mock_metadata)
simple_forms_service.generate_tmp_metadata(mock_metadata)
expect(Dir['tmp/*.SimpleFormsApi.metadata.json'].any?).to equal(true)
ensure
metadata_file = Dir['tmp/*.SimpleFormsApi.metadata.json'][0]
Common::FileHelpers.delete_file_if_exists(metadata_file) if defined?(metadata_file)
Common::FileHelpers.delete_file_if_exists(mock_file_path_metadata)
end
end

describe 'upload doc' do
let(:mock_file) { Common::FileHelpers.random_file_path }
let(:mock_file_path_pdf) { "#{mock_file}-mock-upload.pdf" }
let(:mock_file_path_metadata) { "#{mock_file}.SimpleFormsApi.metadata.json" }

it 'upload doc to mock location' do
VCR.use_cassette('lighthouse/benefits_intake/200_lighthouse_intake_upload') do
mock_upload_url = 'https://sandbox-api.va.gov/services_user_content/vba_documents/id-path-doesnt-matter'
mock_file_path = "#{Common::FileHelpers.random_file_path}-mock-upload.pdf"
Prawn::Document.new.render_file mock_file_path
response = @service.upload_doc(upload_url: mock_upload_url, file: mock_file_path, metadata: mock_metadata)
Prawn::Document.new.render_file mock_file_path_pdf
response = simple_forms_service.upload_doc(upload_url: mock_upload_url,
file: mock_file_path_pdf,
metadata: mock_metadata)
expect(response.status).to equal(200)
ensure
metadata_file = Dir['tmp/*.SimpleFormsApi.metadata.json'][0]
pdf_file = Dir['tmp/*-mock-upload.pdf'][0]
Common::FileHelpers.delete_file_if_exists(metadata_file) if defined?(metadata_file)
Common::FileHelpers.delete_file_if_exists(pdf_file) if defined?(pdf_file)
Common::FileHelpers.delete_file_if_exists(mock_file_path_pdf)
end
end
end
Expand Down

0 comments on commit 2a87305

Please sign in to comment.