Skip to content

Commit

Permalink
Additional date_prefix locations
Browse files Browse the repository at this point in the history
  • Loading branch information
rhys-burendo committed Jan 24, 2025
1 parent 893a373 commit 68d12b4
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 4 deletions.
2 changes: 1 addition & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
}
},
"timestamp": {
"value": "Up to and including {{value, dateShort}}"
"value": "{{prefix}} {{value, dateShortest}}"
},
"table": {
"toggle": "View data in a tabular format",
Expand Down
3 changes: 2 additions & 1 deletion src/api/models/cms/Page/Body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const chartCardValues = z.object({
y_axis_title: z.string().optional(),
y_axis_minimum_value: z.number().nullable().optional(),
y_axis_maximum_value: z.number().nullable().optional(),
date_prefix: z.string(),
})

export const WithChartHeadlineAndTrendCard = z.object({
Expand All @@ -67,7 +68,7 @@ export const WithSimplifiedChartCardAndLink = z.object({
sub_title: z.string(),
topic_page: z.string(),
})
.omit({ body: true }),
.omit({ body: true, date_prefix: true }),
})

export const ChartCardSchemas = z.discriminatedUnion('type', [
Expand Down
5 changes: 5 additions & 0 deletions src/app/components/cms/Chart/Chart.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ test('renders the chart correctly when successful', async () => {
],
body: 'COVID-19 chart description.',
tag_manager_event_id: '',
date_prefix: 'Up to',
title: '',
headline_number_columns: [],
}
Expand Down Expand Up @@ -133,6 +134,7 @@ test('renders the chart by geography and geography type when both are present in
],
body: 'COVID-19 chart description.',
tag_manager_event_id: '',
date_prefix: 'Up to',
title: '',
headline_number_columns: [],
}
Expand Down Expand Up @@ -191,6 +193,7 @@ test('full width charts should also have an acompanying narrow version for mobil
chart: [],
body: 'COVID-19 chart description.',
tag_manager_event_id: '',
date_prefix: 'Up to',
title: '',
headline_number_columns: [],
}
Expand Down Expand Up @@ -231,6 +234,7 @@ test('renders a fallback message when the chart requests fail', async () => {
title: 'Cases by specimen date',
headline_number_columns: [],
tag_manager_event_id: '',
date_prefix: 'Up to',
}

const { getByText, getByRole } = render((await Chart({ data, size: 'narrow' })) as ReactElement)
Expand Down Expand Up @@ -267,6 +271,7 @@ test('Fallback message with escaped characters', async () => {
chart: [],
body: 'COVID-19 chart description.',
tag_manager_event_id: '',
date_prefix: 'Up to',
title: 'Cases by specimen date',
headline_number_columns: [],
}
Expand Down
1 change: 1 addition & 0 deletions src/app/components/cms/Download/Download.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const props: ComponentProps<typeof Download> = {
y_axis: 'y-axis',
x_axis: 'x-axis',
tag_manager_event_id: '',
date_prefix: 'Up to',
headline_number_columns: [],
title: 'Table Title',
body: 'Table Body',
Expand Down
1 change: 1 addition & 0 deletions src/app/components/cms/Table/Table.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const mockData: ComponentProps<typeof Table>['data'] = {
y_axis: 'y-axis',
x_axis: 'x-axis',
tag_manager_event_id: '',
date_prefix: 'Up to and including',
headline_number_columns: [],
title: 'Table Title ABC/XYZ',
body: 'Table Body',
Expand Down
2 changes: 2 additions & 0 deletions src/app/components/cms/Timestamp/Timestamp.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ test('renders the timestamp correctly when successful', async () => {
y_axis: null,
chart: [],
tag_manager_event_id: '',
date_prefix: 'Up to and including',
body: '',
title: '',
headline_number_columns: [],
Expand Down Expand Up @@ -53,6 +54,7 @@ test('renders null when the timestamp request fails', async () => {
y_axis: null,
chart: [],
tag_manager_event_id: '',
date_prefix: '',
body: '',
title: '',
headline_number_columns: [],
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/cms/Timestamp/Timestamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface TimestampProps {
export async function Timestamp({ data, size }: TimestampProps) {
const { t } = await getServerTranslation('common')

const { chart, x_axis, y_axis } = data
const { chart, x_axis, y_axis, date_prefix: datePrefix } = data

const plots = chart.map((plot) => plot.value)

Expand All @@ -40,7 +40,7 @@ export async function Timestamp({ data, size }: TimestampProps) {

return (
<h4 className="govuk-body-s govuk-!-margin-bottom-0 text-dark-grey">
{t('cms.blocks.timestamp.value', { value: lastUpdated })}
{t('cms.blocks.timestamp.value', { prefix: datePrefix, value: lastUpdated })}
</h4>
)
}
Expand Down
14 changes: 14 additions & 0 deletions src/mock-server/handlers/cms/pages/fixtures/page/covid-19.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'Cases by specimen date',
body: 'Number of cases by specimen date. Data for the last 5 days, highlighted in grey, are incomplete.',
tag_manager_event_id: 'cases_by_specimen_date',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -87,6 +88,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: '7-day case rates by specimen date',
body: 'Rate of cases per 100,000 people in the rolling 7-day period ending on the dates shown.',
tag_manager_event_id: '7day_case_rates_by_specimen_date',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -119,6 +121,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'Case rates by age',
body: 'Rates per 100,000 people of the total number of cases since the start of the pandemic, by age.',
tag_manager_event_id: 'case_rates_by_age',
date_prefix: 'Up to',
x_axis: 'stratum',
y_axis: 'metric',
chart: [
Expand Down Expand Up @@ -168,6 +171,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'Daily deaths with COVID-19 on the death certificate by date of death',
body: 'Daily numbers of deaths of people whose death certificate mentioned COVID-19 as one of the causes, and 7-day rolling average. Because of the time it takes for deaths to be registered, there is a lag in reporting of at least 11 days, and data are not shown for the 14 days before the most recent reported date as they are considered incomplete. Data are shown by date of death.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -236,6 +240,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'Bar chart with overlaying line comparing patients \r\nadmitted to hospital with COVID-19',
body: 'Daily and total numbers of COVID-19 patients admitted to hospital. The overlaying line shows the 7-day average.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -268,6 +273,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'Patients in hospital',
body: 'Daily count of confirmed COVID-19 patients in hospital at 8am. The overlaying line shows the 7-day average.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -308,6 +314,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'Admissions rate by age',
body: 'Age breakdown of people admitted to hospital, shown as the rate per 100,000 people, since the start of the pandemic. There are fewer people in the oldest age group so the rates show the relative impact on different age groups.',
tag_manager_event_id: 'admissions_rate_by_age',
date_prefix: 'Up to',
x_axis: 'stratum',
y_axis: 'metric',
chart: [
Expand Down Expand Up @@ -340,6 +347,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'Patients in mechanical ventilation beds',
body: 'Daily count of COVID-19 patients in mechanical ventilation beds, and 7-day rolling average. Data are not updated every day.',
tag_manager_event_id: null,
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -389,6 +397,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'Total daily number of PCR tests reported',
body: 'The daily number of new polymerase chain reaction (PCR) tests reported. Data is shown by specimen date (the date the sample was collected from the person).',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -421,6 +430,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'Weekly positivity of people receiving a PCR test',
body: 'The percentage positivity of people who received a polymerase chain reaction (PCR) and had at least one positive COVID-19 PCR test result in the same 7 days. Data is shown by specimen date (the date the sample was collected). People tested more than once in the period are only counted once in the denominator. People with more than one positive result in the period are only included once in the numerator.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -470,6 +480,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'People aged 50 and over who have received autumn booster vaccinations, by vaccination date',
body: 'The number of people aged 50 and over who have received an autumn booster COVID-19 vaccination. Data for the latest 2 days, marked in grey, are incomplete. Data are shown by date of vaccination.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -502,6 +513,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'Autumn booster vaccination uptake (50+), by vaccination date',
body: 'The percentage of people aged 50 and over who have received an autumn booster COVID-19 vaccination. The denominator is the number of people aged 50 and over on the National Immunisation Management Service (NIMS) database.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -694,6 +706,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'People aged 75 and over who have received spring booster vaccinations, by vaccination date',
body: 'The number of people aged 75 and over who have received a spring booster COVID-19 vaccination. Data for the latest 2 days, marked in grey, are incomplete. Data are shown by date of vaccination.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -726,6 +739,7 @@ export const covid19PageMock: PageResponse<PageType.Topic> = {
title: 'Spring booster vaccination uptake (75+), by vaccination date',
body: 'The percentage of people aged 75 and over who have received a spring booster COVID-19 vaccination. The denominator is the number of people aged 75 and over on the National Immunisation Management Service (NIMS) database.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down
4 changes: 4 additions & 0 deletions src/mock-server/handlers/cms/pages/fixtures/page/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export const dashboardMock: PageResponse<PageType.Landing> = {
title: 'Cases',
body: 'Positive tests reported in England',
tag_manager_event_id: 'positive_tests_reported_in_england',
date_prefix: 'Up to',
x_axis: '',
y_axis: '',
chart: [
Expand Down Expand Up @@ -232,6 +233,7 @@ export const dashboardMock: PageResponse<PageType.Landing> = {
title: 'Deaths',
body: 'Deaths with COVID-19 on the death certificate in England',
tag_manager_event_id: 'deaths_with_covid-19_on_death_certificate',
date_prefix: 'Up to',
x_axis: '',
y_axis: '',
chart: [
Expand Down Expand Up @@ -353,6 +355,7 @@ export const dashboardMock: PageResponse<PageType.Landing> = {
title: 'Healthcare',
body: 'Weekly hospital admission rates for Influenza',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: '',
y_axis: '',
chart: [
Expand Down Expand Up @@ -396,6 +399,7 @@ export const dashboardMock: PageResponse<PageType.Landing> = {
title: 'Testing',
body: 'Weekly positivity',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: '',
y_axis: '',
chart: [
Expand Down
6 changes: 6 additions & 0 deletions src/mock-server/handlers/cms/pages/fixtures/page/influenza.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const influenzaPageMock: PageResponse<PageType.Topic> = {
'Line chart with overlaying line comparing hospital admission rates of patients admitted to hospital with Influenza',
body: 'Weekly admissions rates of patients admitted to hospital with Influenza as a weekly time series, shown as the rate per 100,000 people.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -80,6 +81,7 @@ export const influenzaPageMock: PageResponse<PageType.Topic> = {
title: 'Line chart comparing Influenza hospital admission rates by age',
body: 'Age breakdown of people admitted to hospital, shown as the rate per 100,000 people.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -254,6 +256,7 @@ export const influenzaPageMock: PageResponse<PageType.Topic> = {
'Line chart with overlaying line comparing ICU admission rates of patients admitted to hospital with Influenza',
body: 'Weekly admissions rates of patients admitted to ICU with Influenza as a weekly time series, shown as the rate per 100,000 people.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -286,6 +289,7 @@ export const influenzaPageMock: PageResponse<PageType.Topic> = {
title: 'Line chart comparing Influenza ICU admission rates by age',
body: 'Age breakdown of people admitted to ICU, shown as the rate per 100,000 people.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -468,6 +472,7 @@ export const influenzaPageMock: PageResponse<PageType.Topic> = {
title: 'Bar chart with overlaying line comparing positivity for Influenza tests',
body: 'Weekly admissions rates of patients admitted to hospital with Influenza as a weekly time series, shown as the rate per 100,000 people.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down Expand Up @@ -500,6 +505,7 @@ export const influenzaPageMock: PageResponse<PageType.Topic> = {
title: 'Line chart comparing weekly positivity for Influenza \r\ntests by age',
body: 'Weekly time series of positivity for people testing positive for Influenza broken down by age.',
tag_manager_event_id: '',
date_prefix: 'Up to',
x_axis: null,
y_axis: null,
chart: [
Expand Down
Loading

0 comments on commit 68d12b4

Please sign in to comment.