diff --git a/lib/views/partial__stats_accordion.erb b/lib/views/partial__stats_accordion.erb index f67424b3..a402f1c8 100644 --- a/lib/views/partial__stats_accordion.erb +++ b/lib/views/partial__stats_accordion.erb @@ -15,17 +15,30 @@ }) }}, { heading: { - text: t('service_performance.contents.epcs_upload.tables.titles.england_wales'), + text: t('service_performance.contents.epcs_upload.tables.titles.england'), prefix: t("service_performance.contents.epcs_upload.tables.hidden.certificates_uploaded_country.#{assessment_type.downcase}"), }, content: { html: erb(:partial__stats_table, locals: { assessment_type: assessment_type, - country_key: "england_wales", - values: values["England & Wales"], + country_key: "england", + values: values["England"], show_average_rating: show_average_rating, }) }}, + { heading: { + text: t('service_performance.contents.epcs_upload.tables.titles.wales'), + prefix: t("service_performance.contents.epcs_upload.tables.hidden.certificates_uploaded_country.#{assessment_type.downcase}"), + }, + content: { + html: erb(:partial__stats_table, locals: { + assessment_type: assessment_type, + country_key: "wales", + values: values["Wales"], + show_average_rating: show_average_rating, + }) + }}, + { heading: { text: t('service_performance.contents.epcs_upload.tables.titles.northern_ireland'), prefix: t("service_performance.contents.epcs_upload.tables.hidden.certificates_uploaded_country.#{assessment_type.downcase}"), @@ -38,7 +51,21 @@ show_average_rating: show_average_rating, }) }}, + { heading: { + text: t('service_performance.contents.epcs_upload.tables.titles.other'), + prefix: t("service_performance.contents.epcs_upload.tables.hidden.certificates_uploaded_country.#{assessment_type.downcase}"), + }, + content: { + html: erb(:partial__stats_table, locals: { + assessment_type: assessment_type, + country_key: "other", + values: values["Other"], + show_average_rating: show_average_rating, + }) + }} ] %> + + <%== erb :design_system__accordion, locals: { items: sections, id: "accordion-#{assessment_type.downcase}", diff --git a/locales/cy.yml b/locales/cy.yml index cb5090ea..f3071df6 100644 --- a/locales/cy.yml +++ b/locales/cy.yml @@ -560,8 +560,10 @@ cy: tables: titles: all: "Pob rhanbarth" - england_wales: "Cymru a Lloegr" northern_ireland: "Gogledd Iwerddon" + england: "Lloegr" + wales: "Cymru" + other: "Arall" hidden: certificates_uploaded_all: sap: "Tystysgrifau SAP a uwchlwythwyd ym " diff --git a/locales/en.yml b/locales/en.yml index bcf2112e..58977c7f 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -560,8 +560,10 @@ en: tables: titles: all: "All regions" - england_wales: "England and Wales" northern_ireland: "Northern Ireland" + england: "England" + wales: "Wales" + other: "Other" hidden: certificates_uploaded_all: sap: "SAP certificates uploaded in " diff --git a/spec/acceptance/view_service_performance_spec.rb b/spec/acceptance/view_service_performance_spec.rb index bdbf89b5..8babd98b 100644 --- a/spec/acceptance/view_service_performance_spec.rb +++ b/spec/acceptance/view_service_performance_spec.rb @@ -76,8 +76,10 @@ it "has the correct download links for each region" do expect(response.body).to have_link("Download a copy of the data for all regions", href: "service-performance/download-csv?country=all") - expect(response.body).to have_link("Download a copy of the data for England and Wales", href: "service-performance/download-csv?country=england-wales") + expect(response.body).to have_link("Download a copy of the data for England", href: "service-performance/download-csv?country=england") expect(response.body).to have_link("Download a copy of the data for Northern Ireland", href: "service-performance/download-csv?country=northern-ireland") + expect(response.body).to have_link("Download a copy of the data for Wales", href: "service-performance/download-csv?country=wales") + expect(response.body).to have_link("Download a copy of the data for Other", href: "service-performance/download-csv?country=other") end it "ensure all ids are unique" do diff --git a/spec/test_doubles/service_performance/country_stats_stub.rb b/spec/test_doubles/service_performance/country_stats_stub.rb index d73667cd..2e46cd64 100644 --- a/spec/test_doubles/service_performance/country_stats_stub.rb +++ b/spec/test_doubles/service_performance/country_stats_stub.rb @@ -15,48 +15,48 @@ def self.statistics private_class_method def self.assessments_stats { all: ServicePerformance::Stub.body[:data][:assessments], - englandWales: [ + england: [ { "numAssessments": 121_499, "assessmentType": "RdSAP", "ratingAverage": 61.7122807017544, "month": "2021-09", - "country": "England & Wales", + "country": "England", }, { "numAssessments": 112_499, "assessmentType": "SAP", "ratingAverage": 61.7122807017544, "month": "2021-09", - "country": "England & Wales", + "country": "England", }, { "numAssessments": 92_124, "assessmentType": "CEPC", "ratingAverage": 47.7122807017544, "month": "2021-09", - "country": "England & Wales", + "country": "England", }, { "numAssessments": 367, "assessmentType": "DEC", "ratingAverage": 0.0, "month": "2020-09", - "country": "England & Wales", + "country": "England", }, { "numAssessments": 36, "assessmentType": "DEC-RR", "ratingAverage": 0.0, "month": "2020-09", - "country": "England & Wales", + "country": "England", }, { "numAssessments": 32, "assessmentType": "AC-CERT", "ratingAverage": 0.0, "month": "2020-09", - "country": "England & Wales", + "country": "England", }, ], northernIreland: [ @@ -102,6 +102,55 @@ def self.statistics "month": "2020-09", "country": "Northern Ireland", }, + ], + wales: [ + { + "numAssessments": 5779, + "assessmentType": "RdSAP", + "ratingAverage": 59.1234156, + "month": "2021-09", + "country": "Wales", + }, + { + "numAssessments": 4892, + "assessmentType": "SAP", + "ratingAverage": 61.7122807017544, + "month": "2021-09", + "country": "Wales", + }, + { + "numAssessments": 874, + "assessmentType": "CEPC", + "ratingAverage": 47.7122807017544, + "month": "2021-09", + "country": "Wales", + }, + + ], + other: [ + { + "numAssessments": 5779, + "assessmentType": "RdSAP", + "ratingAverage": 59.1234156, + "month": "2021-09", + "country": "Other", + }, + { + "numAssessments": 4892, + "assessmentType": "SAP", + "ratingAverage": 61.7122807017544, + "month": "2021-09", + "country": "Other", + }, + + { + "numAssessments": 26, + "assessmentType": "CEPC", + "ratingAverage": 61.7122807017544, + "month": "2021-09", + "country": "Other", + }, + ] } end end diff --git a/spec/unit/gateway/statistics_gateway_spec.rb b/spec/unit/gateway/statistics_gateway_spec.rb index d1b205bd..23008fc1 100644 --- a/spec/unit/gateway/statistics_gateway_spec.rb +++ b/spec/unit/gateway/statistics_gateway_spec.rb @@ -15,12 +15,12 @@ expect(response[:data][:assessments][:all].first).to match hash_including({ assessmentType: "CEPC", month: "2020-11", numAssessments: 144_533, ratingAverage: 71.85 }) end - it "returns the expected json for England & Wales" do - expect(response[:data][:assessments][:englandWales].length).to eq(6) - expect(response[:data][:assessments][:englandWales].select { |i| i[:assessmentType] == "RdSAP" }.first).to match hash_including({ assessmentType: "RdSAP", - month: "2021-09", - numAssessments: 121_499, - ratingAverage: 61.7122807017544 }) + it "returns the expected json for England" do + expect(response[:data][:assessments][:england].length).to eq(6) + expect(response[:data][:assessments][:england].select { |i| i[:assessmentType] == "RdSAP" }.first).to match hash_including({ assessmentType: "RdSAP", + month: "2021-09", + numAssessments: 121_499, + ratingAverage: 61.7122807017544 }) end it "returns the expected json for Northern Ireland" do @@ -30,5 +30,12 @@ numAssessments: 5779, ratingAverage: 59.1234156 }) end + + it "contains the the expected countries" do + assessments = response[:data][:assessments] + %i[england wales northernIreland other].each do |country| + expect(assessments.key?(country)).to be true + end + end end end diff --git a/spec/unit/use_case/fetch_statistics_spec.rb b/spec/unit/use_case/fetch_statistics_spec.rb index b3842e55..7699fd53 100644 --- a/spec/unit/use_case/fetch_statistics_spec.rb +++ b/spec/unit/use_case/fetch_statistics_spec.rb @@ -16,25 +16,31 @@ it "contains expected json for assessments" do expect(results[:assessments][:all].length).to eq(17) - expect(results[:assessments][:englandWales].length).to eq(6) + expect(results[:assessments][:england].length).to eq(6) expect(results[:assessments][:northernIreland].length).to eq(6) cepc = results[:assessments][:all].select { |i| i[:assessmentType] == "CEPC" && i[:month] == "2020-11" } expect(cepc.first).to eq({ assessmentType: "CEPC", month: "2020-11", numAssessments: 144_533, ratingAverage: 71.85, country: "all" }) end - it "groups the assessments data by the assessment types and country" do + it "groups the assessments data by the assessment types and country", :aggregate_failures do assessment_types = %w[SAP RdSAP CEPC DEC AC-CERT DEC-RR] expect(results[:assessments][:grouped].length).to eq(assessment_types.length) expect(results[:assessments][:grouped].keys - assessment_types).to eq([]) expect(results[:assessments][:grouped]["CEPC"]).to eq({ - "England & Wales" => [ - { assessmentType: "CEPC", country: "England & Wales", month: "2021-09", numAssessments: 92_124, ratingAverage: 47.7122807017544 }, + "England" => [ + { assessmentType: "CEPC", country: "England", month: "2021-09", numAssessments: 92_124, ratingAverage: 47.7122807017544 }, + ], + "Wales" => [ + { assessmentType: "CEPC", country: "Wales", month: "2021-09", numAssessments: 874, ratingAverage: 47.7122807017544 }, ], "Northern Ireland" => [ { assessmentType: "CEPC", country: "Northern Ireland", month: "2021-09", numAssessments: 874, ratingAverage: 47.7122807017544 }, ], + "Other" => [ + { assessmentType: "CEPC", country: "Other", month: "2021-09", numAssessments: 26, ratingAverage: 61.7122807017544 }, + ], "all" => [ { assessmentType: "CEPC", country: "all", month: "2020-11", numAssessments: 144_533, ratingAverage: 71.85 }, { assessmentType: "CEPC", country: "all", month: "2021-11", numAssessments: 2837, ratingAverage: 66.24 },