Skip to content

Commit

Permalink
appointment multistatus update
Browse files Browse the repository at this point in the history
  • Loading branch information
aherzberg committed Apr 23, 2024
1 parent 36f10a5 commit d087ab4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def merge_provider_names(appointments)
names, appointment_missing_providers =
provider_names_proxy.form_names_from_appointment_practitioners_list(practitioners_list)
appt[:healthcare_provider] = names
missing_providers << appointment_missing_providers
missing_providers.concat(appointment_missing_providers) unless names
end

[appointments, missing_providers]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
before do
Flipper.enable('va_online_scheduling')
allow_any_instance_of(VAOS::UserService).to receive(:session).and_return('stubbed_token')
allow(Rails.logger).to receive(:info)
Timecop.freeze(Time.zone.parse('2022-01-01T19:25:00Z'))
end

Expand Down Expand Up @@ -97,6 +98,9 @@
end
end
end
expect(response).to have_http_status(:multi_status)
expect(Rails.logger).to have_received(:info).with('Mobile Appointment Partial Error',
errors: [{ missing_facilities: ['983'] }])
expect(response.body).to match_json_schema('VAOS_v2_appointments')
location = response.parsed_body.dig('data', 0, 'attributes', 'location')
expect(location).to eq({ 'id' => nil,
Expand Down Expand Up @@ -155,6 +159,10 @@
end
end
end
expect(response).to have_http_status(:multi_status)
expect(Rails.logger).to have_received(:info).with('Mobile Appointment Partial Error',
errors: [{ missing_facilities: ['999AA'] },
{ missing_clinics: ['999'] }])
expect(response.body).to match_json_schema('VAOS_v2_appointments')
expect(response.parsed_body.dig('data', 0, 'attributes', 'healthcareService')).to be_nil
end
Expand Down Expand Up @@ -187,6 +195,14 @@
end

expect(response).to have_http_status(:multi_status)
appointment_error = { errors: [{ appointment_errors: [{ system: 'the system',
id: 'id-string',
status: 'status-string',
code: 0,
trace_id: 'traceId-string',
message: 'msg-string',
detail: 'detail-string' }] }] }
expect(Rails.logger).to have_received(:info).with('Mobile Appointment Partial Error', appointment_error)
expect(response.parsed_body['data'].count).to eq(1)
expect(response.parsed_body['meta']).to include(
{
Expand Down Expand Up @@ -285,8 +301,10 @@ def fetch_appointments
end
end
end
expect(response).to have_http_status(:ok)
expect(response).to have_http_status(:multi_status)
expect(appointment['attributes']['healthcareProvider']).to be_nil
expect(Rails.logger).to have_received(:info).with('Mobile Appointment Partial Error',
errors: [{ missing_providers: ['1407938061'] }])
end

it 'falls back to nil when provider service returns 500' do
Expand All @@ -302,8 +320,10 @@ def fetch_appointments
end
end
end
expect(response).to have_http_status(:ok)
expect(response).to have_http_status(:multi_status)
expect(appointment['attributes']['healthcareProvider']).to be_nil
expect(Rails.logger).to have_received(:info).with('Mobile Appointment Partial Error',
errors: [{ missing_providers: ['1407938061'] }])
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
],
"properties": {
"errors": {
"type": "null"
"type": ["array","null"]
},
"pagination": {
"type": "object",
Expand Down

0 comments on commit d087ab4

Please sign in to comment.