Skip to content

Commit

Permalink
ADJST-657 Update date format and tests (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-virden authored Oct 31, 2024
1 parent b75bb75 commit a921ce4
Show file tree
Hide file tree
Showing 24 changed files with 92 additions and 90 deletions.
2 changes: 1 addition & 1 deletion server/model/lawfullyAtLargeForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default class LawfullyAtLargeForm extends AdjustmentsForm<LawfullyAtLarge
const minSentenceDate = this.getMinSentenceDate(sentencesWithOffenceDates)
if (fromDate < minSentenceDate) {
errors.push({
text: `The lawfully at large period cannot start before the earliest sentence date, on ${dayjs(minSentenceDate).format('DD MMM YYYY')}`,
text: `The lawfully at large period cannot start before the earliest sentence date, on ${dayjs(minSentenceDate).format('D MMMM YYYY')}`,
fields: ['from-day', 'from-month', 'from-year'],
})
}
Expand Down
4 changes: 2 additions & 2 deletions server/model/recallModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export default class RecallModel {

private remandText(adjustment: Adjustment) {
return `Remand ${adjustment.days} days from ${dayjs(adjustment.fromDate).format(
'D MMM YYYY',
)} to ${dayjs(adjustment.toDate).format('D MMM YYYY')}`
'D MMMM YYYY',
)} to ${dayjs(adjustment.toDate).format('D MMMM YYYY')}`
}

private taggedBailText(adjustment: Adjustment) {
Expand Down
2 changes: 1 addition & 1 deletion server/model/remandDatesForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class RemandDatesForm extends AbstractForm<RemandDatesForm> {
if (fromDate < minOffenceDate) {
errors.push({
text: `The remand period cannot start before the earliest offence date, on ${dayjs(minOffenceDate).format(
'DD MMM YYYY',
'D MMMM YYYY',
)}`,
fields: ['from-day', 'from-month', 'from-year'],
})
Expand Down
8 changes: 4 additions & 4 deletions server/model/remandReviewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class RemandReviewModel {
return [
...Object.values(this.adjustments).map(it => {
return [
{ text: `From ${dayjs(it.fromDate).format('DD MMM YYYY')} to ${dayjs(it.toDate).format('DD MMM YYYY')}` },
{ text: `From ${dayjs(it.fromDate).format('D MMMM YYYY')} to ${dayjs(it.toDate).format('D MMMM YYYY')}` },
{ text: daysBetween(new Date(it.fromDate), new Date(it.toDate)) },
]
}),
Expand All @@ -65,8 +65,8 @@ export default class RemandReviewModel {
public adjustmentSummary(id: string) {
const adjustment = this.adjustments[id]
const offences = offencesForRemandAdjustment(adjustment, this.sentencesAndOffences)
const adjustmentFromDate = dayjs(adjustment.fromDate).format('DD MMM YYYY')
const adjustmentToDate = dayjs(adjustment.toDate).format('DD MMM YYYY')
const adjustmentFromDate = dayjs(adjustment.fromDate).format('D MMMM YYYY')
const adjustmentToDate = dayjs(adjustment.toDate).format('D MMMM YYYY')
return {
rows: [
{
Expand Down Expand Up @@ -152,7 +152,7 @@ export default class RemandReviewModel {
}

private formatDate(date: string, noWrapDate: boolean) {
const formattedDate = dayjs(date).format('DD MMM YYYY')
const formattedDate = dayjs(date).format('D MMMM YYYY')
return noWrapDate ? `<span class="govuk-!-white-space-nowrap">${formattedDate}</span> ` : formattedDate
}

Expand Down
2 changes: 1 addition & 1 deletion server/model/remandSaveModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class RemandSaveModel {
return this.adjustments.map(it => {
return [
{
text: `${dayjs(it.fromDate).format('DD MMM YYYY')} to ${dayjs(it.toDate).format('DD MMM YYYY')}`,
text: `${dayjs(it.fromDate).format('D MMMM YYYY')} to ${dayjs(it.toDate).format('D MMMM YYYY')}`,
},
{
text: daysBetween(new Date(it.fromDate), new Date(it.toDate)),
Expand Down
2 changes: 1 addition & 1 deletion server/model/remandViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class RemandViewModel {
return [
...this.adjustments.map(it => {
return [
{ text: `From ${dayjs(it.fromDate).format('DD MMM YYYY')} to ${dayjs(it.toDate).format('DD MMM YYYY')}` },
{ text: `From ${dayjs(it.fromDate).format('D MMMM YYYY')} to ${dayjs(it.toDate).format('D MMMM YYYY')}` },
{ text: it.days },
]
}),
Expand Down
10 changes: 5 additions & 5 deletions server/model/reviewAndSubmitAdaViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class ReviewAndSubmitAdaViewModel {
rows: [
...this.adjustments.map(it => {
return [
{ text: dayjs(it.fromDate).format('D MMM YYYY') },
{ text: dayjs(it.fromDate).format('D MMMM YYYY') },
{ html: it.additionalDaysAwarded.adjudicationId.join('<br/>') },
{ text: it.days, format: 'numeric' },
]
Expand Down Expand Up @@ -55,7 +55,7 @@ export default class ReviewAndSubmitAdaViewModel {
rows: [
...this.quashedAdjustments.map(it => {
return [
{ text: dayjs(it.fromDate).format('D MMM YYYY') },
{ text: dayjs(it.fromDate).format('D MMMM YYYY') },
{ html: it.additionalDaysAwarded.adjudicationId.join('<br/>') },
{ text: it.days, format: 'numeric' },
]
Expand Down Expand Up @@ -86,9 +86,9 @@ export default class ReviewAndSubmitAdaViewModel {
rows: [
...this.existingAdjustments.map(it => {
return [
{ text: dayjs(it.lastUpdatedDate).format('D MMM YYYY') },
{ text: dayjs(it.fromDate).format('D MMM YYYY') },
{ text: dayjs(it.toDate).format('D MMM YYYY') },
{ text: dayjs(it.lastUpdatedDate).format('D MMMM YYYY') },
{ text: dayjs(it.fromDate).format('D MMMM YYYY') },
{ text: dayjs(it.toDate).format('D MMMM YYYY') },
{ text: it.days, format: 'numeric' },
]
}),
Expand Down
2 changes: 1 addition & 1 deletion server/model/unlawfullyAtLargeForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default class UnlawfullyAtLargeForm extends AdjustmentsForm<UnlawfullyAtL
const minSentenceDate = this.getMinSentenceDate(sentencesWithOffenceDates)
if (fromDate < minSentenceDate) {
errors.push({
text: `The unlawfully at large period cannot start before the earliest sentence date, on ${dayjs(minSentenceDate).format('DD MMM YYYY')}`,
text: `The unlawfully at large period cannot start before the earliest sentence date, on ${dayjs(minSentenceDate).format('D MMMM YYYY')}`,
fields: ['from-day', 'from-month', 'from-year'],
})
}
Expand Down
14 changes: 7 additions & 7 deletions server/model/viewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class ViewModel {
if (this.adjustmentType.value === 'RESTORATION_OF_ADDITIONAL_DAYS_AWARDED') {
return this.adjustments.map(it => {
return [
{ text: dayjs(it.fromDate).format('D MMM YYYY') },
{ text: dayjs(it.fromDate).format('D MMMM YYYY') },
{ text: it.prisonName || 'Unknown' },
{ text: it.days, format: 'numeric' },
this.actionCell(it),
Expand All @@ -88,8 +88,8 @@ export default class ViewModel {
if (this.adjustmentType.value === 'UNLAWFULLY_AT_LARGE') {
return this.adjustments.map(it => {
return [
{ text: dayjs(it.fromDate).format('D MMM YYYY') },
{ text: dayjs(it.toDate).format('D MMM YYYY') },
{ text: dayjs(it.fromDate).format('D MMMM YYYY') },
{ text: dayjs(it.toDate).format('D MMMM YYYY') },
{ text: it.prisonName || 'Unknown' },
{ text: it.unlawfullyAtLarge ? ualType.find(u => u.value === it.unlawfullyAtLarge.type)?.text : 'Unknown' },
{ text: it.days, format: 'numeric' },
Expand All @@ -100,8 +100,8 @@ export default class ViewModel {
if (this.adjustmentType.value === 'LAWFULLY_AT_LARGE') {
return this.adjustments.map(it => {
return [
{ text: dayjs(it.fromDate).format('D MMM YYYY') },
{ text: dayjs(it.toDate).format('D MMM YYYY') },
{ text: dayjs(it.fromDate).format('D MMMM YYYY') },
{ text: dayjs(it.toDate).format('D MMMM YYYY') },
{ text: it.prisonName || 'Unknown' },
{
text: it.lawfullyAtLarge
Expand All @@ -115,8 +115,8 @@ export default class ViewModel {
}
return this.adjustments.map(it => {
return [
{ text: dayjs(it.fromDate).format('D MMM YYYY') },
...(this.adjustmentType.value === 'REMAND' ? [{ text: dayjs(it.toDate).format('D MMM YYYY') }] : []),
{ text: dayjs(it.fromDate).format('D MMMM YYYY') },
...(this.adjustmentType.value === 'REMAND' ? [{ text: dayjs(it.toDate).format('D MMMM YYYY') }] : []),
{ text: it.days, format: 'numeric' },
{ text: it.prisonName || 'Unknown' },
this.actionCell(it),
Expand Down
4 changes: 2 additions & 2 deletions server/routes/additionalDaysAwardedRoutes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ describe('Additional Days Awarded routes tests', () => {
.expect(res => {
expect(res.text).toContain('Review and delete ADAs')
expect(res.text).toContain('Pending deletion')
expect(res.text).toContain('03 Aug 2023')
expect(res.text).toContain('3 August 2023')
expect(res.text).toContain('Total ADAs removed from calculation')
expect(res.text).toContain('10')
})
Expand Down Expand Up @@ -356,7 +356,7 @@ describe('Additional Days Awarded routes tests', () => {
.expect('Content-Type', /html/)
.expect(res => {
expect(res.text).toContain('Select all the relevant PADAs')
expect(res.text).toContain('Date charge proved 03 Aug 2023 at Moorland')
expect(res.text).toContain('Date charge proved 3 August 2023 at Moorland')
})
})

Expand Down
24 changes: 12 additions & 12 deletions server/routes/adjustmentRoutes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ describe('Adjustment routes tests', () => {
.expect(res => {
expect(res.text).toContain('Anon')
expect(res.text).toContain('Date of days restored')
expect(res.text).toContain('5 Apr 2023')
expect(res.text).toContain('5 April 2023')
expect(res.text).toContain('Number of days')
expect(res.text).toContain('24')
expect(res.text).toContain('Confirm and save')
Expand All @@ -451,8 +451,8 @@ describe('Adjustment routes tests', () => {
expect(res.text).toContain('Anon')
expect(res.text).toContain('First day spent UAL')
expect(res.text).toContain('Last day spent UAL')
expect(res.text).toContain('5 Jun 2023')
expect(res.text).toContain('25 Jul 2023')
expect(res.text).toContain('5 June 2023')
expect(res.text).toContain('25 July 2023')
expect(res.text).toContain('Number of days')
expect(res.text).toContain('51')
expect(res.text).toContain('Type of UAL')
Expand All @@ -472,8 +472,8 @@ describe('Adjustment routes tests', () => {
expect(res.text).toContain('Anon')
expect(res.text).toContain('First day spent LAL')
expect(res.text).toContain('Last day spent LAL')
expect(res.text).toContain('5 Jul 2023')
expect(res.text).toContain('5 Sep 2023')
expect(res.text).toContain('5 July 2023')
expect(res.text).toContain('5 September 2023')
expect(res.text).toContain('Number of days')
expect(res.text).toContain('61')
expect(res.text).toContain('Delay release dates')
Expand Down Expand Up @@ -605,9 +605,9 @@ describe('Adjustment routes tests', () => {
expect(res.text).toContain('remove/this-is-an-id')
expect(res.text).toContain('Total days')
expect(res.text).toContain('First day')
expect(res.text).toContain('5 Jun 2023')
expect(res.text).toContain('5 June 2023')
expect(res.text).toContain('Last day')
expect(res.text).toContain('25 Jul 2023')
expect(res.text).toContain('25 July 2023')
expect(res.text).toContain('Type')
expect(res.text).toContain('Recall')
})
Expand Down Expand Up @@ -665,9 +665,9 @@ describe('Adjustment routes tests', () => {
expect(res.text).toContain('remove/this-is-an-id')
expect(res.text).toContain('Total days')
expect(res.text).toContain('First day')
expect(res.text).toContain('5 Jul 2023')
expect(res.text).toContain('5 July 2023')
expect(res.text).toContain('Last day')
expect(res.text).toContain('5 Sep 2023')
expect(res.text).toContain('5 September 2023')
expect(res.text).toContain('Delay release dates')
expect(res.text).toContain('Yes')
})
Expand Down Expand Up @@ -707,7 +707,7 @@ describe('Adjustment routes tests', () => {
.get(`/${NOMS_ID}/restored-additional-days/remove/this-is-an-id`)
.expect('Content-Type', /html/)
.expect(res => {
expect(res.text).toContain('5 Apr 2023')
expect(res.text).toContain('5 April 2023')
expect(res.text).toContain('22')
})
})
Expand Down Expand Up @@ -773,7 +773,7 @@ describe('Adjustment routes tests', () => {
.expect('Content-Type', /html/)
.expect(res => {
expect(res.text).toContain(
'The unlawfully at large period cannot start before the earliest sentence date, on 06 May 2023',
'The unlawfully at large period cannot start before the earliest sentence date, on 6 May 2023',
)
})
})
Expand Down Expand Up @@ -922,7 +922,7 @@ describe('Adjustment routes tests', () => {
.expect('Content-Type', /html/)
.expect(res => {
expect(res.text).toContain(
'The lawfully at large period cannot start before the earliest sentence date, on 06 May 2023',
'The lawfully at large period cannot start before the earliest sentence date, on 6 May 2023',
)
})
})
Expand Down
2 changes: 1 addition & 1 deletion server/routes/hubRoutes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ describe('GET /:nomsId', () => {
expect(res.text).toContain('Nobody')
expect(res.text).not.toContain('Nobody may have 20 days remand')
expect(res.text).toContain('24')
expect(res.text).toContainInOrder(['Last update', 'on 05 Apr 2023', 'by Leeds'])
expect(res.text).toContainInOrder(['Last update', 'on 5 April 2023', 'by Leeds'])
expect(res.text).toContain('including 10 days unused')
})
})
Expand Down
42 changes: 22 additions & 20 deletions server/routes/remandRoutes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('Remand routes tests', () => {
.expect(200)
.expect(res => {
expect(res.text).toContain('Remand overview')
expect(res.text).toContain('From 01 Jan 2023 to 10 Jan 2023')
expect(res.text).toContain('From 1 January 2023 to 10 January 2023')
expect(res.text).toContain('Doing a crime')
expect(res.text).toContain('Heard at Court 1')
expect(res.text).toContain('edit-remand')
Expand Down Expand Up @@ -378,7 +378,9 @@ describe('Remand routes tests', () => {
.type('form')
.expect('Content-Type', /html/)
.expect(res => {
expect(res.text).toContain('The remand period cannot start before the earliest offence date, on 04 Jan 2021')
expect(res.text).toContain(
'The remand period cannot start before the earliest offence date, on 4 January 2021',
)
})
})

Expand Down Expand Up @@ -411,7 +413,7 @@ describe('Remand routes tests', () => {
.expect('Content-Type', /html/)
.expect(res => {
expect(res.text).toContain(
'The remand period cannot start before the earliest offence date, on 04 Jan 2021',
'The remand period cannot start before the earliest offence date, on 4 January 2021',
)
})
},
Expand Down Expand Up @@ -455,8 +457,8 @@ describe('Remand routes tests', () => {
fromDate: '2023-01-06',
toDate: '2023-01-10',
id: '123-abb',
from: '06 Jan 2023',
to: '10 Jan 2023',
from: '6 January 2023',
to: '10 January 2023',
},
from: { year: '2023', month: '01', day: '01' },
to: { year: '2023', month: '03', day: '20' },
Expand All @@ -468,8 +470,8 @@ describe('Remand routes tests', () => {
fromDate: '2023-01-07',
toDate: '2023-01-10',
id: '123-abb',
from: '07 Jan 2023',
to: '10 Jan 2023',
from: '7 January 2023',
to: '10 January 2023',
},
from: { year: '2023', month: '01', day: '01' },
to: { year: '2023', month: '01', day: '07' },
Expand All @@ -481,8 +483,8 @@ describe('Remand routes tests', () => {
fromDate: '2023-01-06',
toDate: '2023-01-10',
id: '123-abb',
from: '06 Jan 2023',
to: '10 Jan 2023',
from: '6 January 2023',
to: '10 January 2023',
},
from: { year: '2023', month: '01', day: '1' },
to: { year: '2023', month: '01', day: '10' },
Expand Down Expand Up @@ -541,12 +543,12 @@ describe('Remand routes tests', () => {
'CASE001',
'Doing a crime',
'Committed from',
'04 Jan 2021',
'4 January 2021',
'to',
'05 Jan 2021',
'5 January 2021',
'Doing a different crime',
'Committed on',
'06 Mar 2021',
'6 March 2021',
])
})
})
Expand Down Expand Up @@ -608,12 +610,12 @@ describe('Remand routes tests', () => {
)
expect(res.text).toContainInOrder([
'Remand cannot be applied when a sentence is being served.',
'The remand dates from 02 Jan 2021 to 02 Feb 2021 overlaps with the sentence starting on 01 Jan 2021 with a release date of the 01 Feb 2021',
'The remand dates from 2 January 2021 to 2 February 2021 overlaps with the sentence starting on 1 January 2021 with a release date of the 1 February 2021',
])
expect(res.text).toContain('Review remand details')
expect(res.text).toContainInOrder([
'Remand period',
'01 Jan 2023 to 10 Jan 2023',
'1 January 2023 to 10 January 2023',
'Offences',
'Doing a crime',
'Doing a different crime',
Expand Down Expand Up @@ -724,8 +726,8 @@ describe('Remand routes tests', () => {
expect(res.text).toContain('Anon')
expect(res.text).toContain('Nobody')
expect(res.text).toContain('Delete remand')
expect(res.text).toContain('01 Jan 2023 to 10 Jan 2023')
expect(res.text).toContainInOrder(['Committed from', '04 Jan 2021', 'to', '05 Jan 2021'])
expect(res.text).toContain('1 January 2023 to 10 January 2023')
expect(res.text).toContainInOrder(['Committed from', '4 January 2021', 'to', '5 January 2021'])
expect(res.text).toContain('Doing a crime')
})
})
Expand Down Expand Up @@ -756,8 +758,8 @@ describe('Remand routes tests', () => {
expect(res.text).toContain('Anon')
expect(res.text).toContain('Nobody')
expect(res.text).toContain('Edit remand')
expect(res.text).toContain('01 Jan 2023 to 10 Jan 2023')
expect(res.text).toContainInOrder(['Committed from', '04 Jan 2021', 'to', '05 Jan 2021'])
expect(res.text).toContain('1 January 2023 to 10 January 2023')
expect(res.text).toContainInOrder(['Committed from', '4 January 2021', 'to', '5 January 2021'])
expect(res.text).toContain('Doing a crime')
})
})
Expand Down Expand Up @@ -959,7 +961,7 @@ describe('Remand routes tests', () => {
.expect(res => {
expect(res.text).toContainInOrder([
'Remand cannot be applied when a sentence is being served.',
'The remand dates from 02 Jan 2021 to 02 Feb 2021 overlaps with the sentence starting on 01 Jan 2021 with a release date of the 01 Feb 2021',
'The remand dates from 2 January 2021 to 2 February 2021 overlaps with the sentence starting on 1 January 2021 with a release date of the 1 February 2021',
'Update the remand dates to continue.',
])
})
Expand All @@ -980,7 +982,7 @@ describe('Remand routes tests', () => {
expect(res.text).toContain(
'Some of the details recorded cannot be used for a sentence calculation. This means unused deductions cannot be automatically calculated by this service',
)
expect(res.text).toContain('From 01 Jan 2023 to 10 Jan 2023')
expect(res.text).toContain('From 1 January 2023 to 10 January 2023')
expect(res.text).toContain('Doing a crime')
})
})
Expand Down
Loading

0 comments on commit a921ce4

Please sign in to comment.