Skip to content

Commit

Permalink
CRIMAPP-1581 prepare for outcome status user research (#1315)
Browse files Browse the repository at this point in the history
CRIMAPP-1581 show simplified overall result

- remove colour tags from overall result
- show court_type (Means test)
  • Loading branch information
timpeat authored Jan 20, 2025
1 parent a41682c commit 0fee9dc
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 18 deletions.
27 changes: 25 additions & 2 deletions app/presenters/summary/components/funding_decision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ def answers # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metri
Components::FreeTextAnswer.new(
:funding_decision_case_number, funding_decision.case_id
),
Components::ValueAnswer.new(
:funding_decision_court_type, funding_decision.court_type
),
Components::ValueAnswer.new(
:funding_decision_ioj_result, funding_decision.interests_of_justice&.result
),
Expand All @@ -32,8 +35,8 @@ def answers # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metri
Components::DateAnswer.new(
:funding_decision_means_date, funding_decision.means&.assessed_on
),
Components::TagAnswer.new(
:funding_decision_overall_result, funding_decision.funding_decision
Components::ValueAnswer.new(
:funding_decision_overall_result, overall_result
),
Components::FreeTextAnswer.new(
:funding_decision_further_info, funding_decision.comment
Expand All @@ -49,6 +52,26 @@ def status_tag
nil
end

# TODO: source from datastore once decision on simplified statuses resolved
def overall_result
return 'granted_failed_means' if granted? && failed_means?
return 'granted_with_contribution' if granted? && with_contribution?

record.funding_decision
end

def granted?
record.funding_decision == 'granted'
end

def failed_means?
record.means&.result == 'failed'
end

def with_contribution?
record.means&.result == 'passed_with_contribution'
end

def funding_decision
@funding_decision ||= record
end
Expand Down
16 changes: 10 additions & 6 deletions config/locales/en/summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,11 @@ en:
question: MAAT ID
funding_decision_case_number:
question: Case number
funding_decision_court_type:
question: Means test
answers:
crown: Crown Court
magistrates: Magistrates Court
funding_decision_ioj_result:
question: Interests of justice (IoJ) test result
answers:
Expand All @@ -727,12 +732,11 @@ en:
funding_decision_overall_result:
question: Overall result
answers:
granted:
value: Granted
colour: green
refused:
value: Refused
colour: red
granted: Granted
refused: Refused
granted_failed_means: Granted - failed means test
granted_with_contribution: Granted - with a contribution

funding_decision_further_info:
question: Further information about the decision
# END funding decisions section
Expand Down
42 changes: 32 additions & 10 deletions spec/presenters/summary/components/funding_decision_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@

let(:attributes) do
{
case_id:,
maat_id:,
interests_of_justice:,
means:,
funding_decision:,
comment:
case_id: 'APP123',
maat_id: 'M123',
interests_of_justice: interests_of_justice,
means: means,
funding_decision: funding_decision,
court_type: 'crown',
comment: 'Decision comment'
}
end

let(:case_id) { 'APP123' }
let(:maat_id) { 'M123' }
let(:interests_of_justice) do
instance_double(
LaaCrimeSchemas::Structs::TestResult,
Expand All @@ -28,17 +27,19 @@
assessed_on: Date.new(2024, 10, 8),
)
end

let(:means) do
instance_double(
LaaCrimeSchemas::Structs::TestResult,
result: 'failed',
result: means_result,
details: 'Means details',
assessed_by: 'Grace Nolan',
assessed_on: Date.new(2024, 10, 9),
)
end

let(:funding_decision) { 'refused' }
let(:comment) { 'Decision comment' }
let(:means_result) { 'failed' }

before { component }

Expand All @@ -47,6 +48,7 @@
expect(summary_card('Case')).to have_rows(
'MAAT ID', 'M123',
'Case number', 'APP123',
'Means test', 'Crown Court',
'Interests of justice (IoJ) test result', 'Failed',
'IoJ comment', 'IoJ details',
'IoJ caseworker', 'Grace Nolan',
Expand All @@ -59,4 +61,24 @@
)
end
end

context 'when funding decision is "granted" and means "passed"' do
let(:funding_decision) { 'granted' }
let(:means_result) { 'passed' }

it { is_expected.to have_text('Granted') }
end

context 'when funding decision is "granted" and means "passed_with_contribution"' do
let(:funding_decision) { 'granted' }
let(:means_result) { 'passed_with_contribution' }

it { is_expected.to have_text('Granted - with a contribution') }
end

context 'when funding decision is "granted" and means "failed"' do
let(:funding_decision) { 'granted' }

it { is_expected.to have_text('Granted - failed means test') }
end
end

0 comments on commit 0fee9dc

Please sign in to comment.