Skip to content

Commit 7245a90

Browse files
feat: change application details tabs content (#50)
* feat: change application details tabs content * bump: version * fix: linting * feat: fix broken tests * feat: fix broken tests * feat: change eligible test * fix: error message text
1 parent 5d752e4 commit 7245a90

11 files changed

+40
-33
lines changed

app/lib/search-validation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ module.exports = (searchText) => {
2626
searchType
2727
}
2828
} else {
29-
throw new Error('Invalid search. It should be application reference or status or sbi number.')
29+
throw new Error('Invalid search. It should be agreement number, organisation or single business identifier (SBI) number.')
3030
}
3131
}
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
const { formatedDateToUk, upperFirstLetter } = require('../../lib/display-helper')
22

33
module.exports = (application) => {
4-
const { data } = application
4+
const { data, updatedAt } = application
5+
const formatedDate = formatedDateToUk(updatedAt)
56
return {
67
firstCellIsHeader: true,
78
rows: [
9+
[{ text: 'Date of claim' }, { text: formatedDate }],
810
[{ text: 'Review details confirmed' }, { text: upperFirstLetter(data?.confirmCheckDetails) }],
911
[{ text: 'Date of review' }, { text: formatedDateToUk(data?.visitDate) }],
1012
[{ text: 'Vet’s name' }, { text: data?.vetName }],
1113
[{ text: 'Vet’s RCVS number' }, { text: data?.vetRcvs }],
12-
[{ text: 'Unique reference number (URN)' }, { text: data?.urnResult }]
14+
[{ text: 'Test results unique reference number (URN)' }, { text: data?.urnResult }]
1315
]
1416
}
1517
}

app/routes/models/application-list.js

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ async function createModel (request, page) {
6666
if (apps.total > 0) {
6767
let statusClass
6868
const applications = apps.applications.map(n => {
69-
n.status.status = n.status.status === 'APPLIED' ? 'AGREED' : n.status.status
7069
statusClass = getStyleClassByStatus(n.status.status)
7170
return [
7271
{ text: n.reference },

app/routes/models/farmer-application.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ const speciesNumbers = require('../../../app/constants/species-numbers')
44
module.exports = (application) => {
55
const { data, createdAt, status } = application
66
const formatedDate = formatedDateToUk(createdAt)
7+
78
return {
89
firstCellIsHeader: true,
910
rows: [
10-
[{ text: status.status === 'REJECTED' || status.status === 'NOT AGREED' ? 'Agreement not formed' : 'Agreement formed' }, { text: formatedDate }],
11+
[{ text: status.status === 'NOT AGREED' ? 'Date of agreement rejected' : 'Date of agreement' }, { text: formatedDate }],
1112
[{ text: 'Business details correct' }, { text: upperFirstLetter(data.confirmCheckDetails) }],
1213
[{ text: 'Type of review' }, { text: upperFirstLetter(data.whichReview) }],
1314
[{ text: 'Number of livestock' }, { text: speciesNumbers[data.whichReview] }],
14-
[{ text: 'Agreement accepted' }, { text: data.declaration ? 'Yes' : 'No' }]
15+
[{ text: 'Agreement accepted' }, { text: data.offerStatus === 'accepted' ? 'Yes' : 'No' }]
1516
]
1617
}
1718
}

app/routes/view-application.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ module.exports = {
2525
throw boom.badRequest()
2626
}
2727

28+
const status = upperFirstLetter(application.status.status.toLowerCase())
2829
const statusClass = getStyleClassByStatus(application.status.status)
29-
const status = application.status.status === 'APPLIED' ? 'Agreed' : upperFirstLetter(application.status.status.toLowerCase())
3030
return h.view('view-application', {
3131
applicationId: application.reference,
3232
status,

app/views/macros/view-application-tabs.njk

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
{% if claimed %}
1212
<h2 class="govuk-heading-l">Claimed</h2>
1313
{{ govukTable(model.claimData) }}
14+
{% elif (status == "Agreed") %}
15+
<h2 class="govuk-heading-l">Not claimed yet</h2>
1416
{% else %}
15-
<h2 class="govuk-heading-l">Never claimed</h2>
17+
<h2 class="govuk-heading-l">Not eligible to claim</h2>
1618
{% endif %}
1719
{% endset -%}
1820

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ffc-ahwr-backoffice",
3-
"version": "1.14.2",
3+
"version": "1.14.3",
44
"description": "Back office of the health and welfare of your livestock",
55
"homepage": "https://github.com/DEFRA/ffc-ahwr-backoffice",
66
"main": "app/index.js",

test/data/applications.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"id": "555afd4c-b095-4ce4-b492-800466b53393",
66
"reference": "AHWR-555A-FD4C",
7-
"status": { "status": "APPLIED" },
7+
"status": { "status": "AGREED" },
88
"data": {
99
"declaration": true,
1010
"whichReview": "sheep",
@@ -211,9 +211,9 @@
211211
],
212212
"applicationStatus": [
213213
{
214-
"status": "APPLIED",
214+
"status": "AGREED",
215215
"total": "23",
216-
"status.status": "APPLIED"
216+
"status.status": "AGREED"
217217
},
218218
{
219219
"status": "CLAIMED",

test/data/view-applications.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"applied": {
2+
"agreed": {
33
"id": "555afd4c-b095-4ce4-b492-800466b53393",
44
"reference": "AHWR-555A-FD4C",
5-
"status": { "status": "APPLIED" },
5+
"status": { "status": "AGREED" },
66
"data": {
77
"declaration": true,
88
"whichReview": "sheep",
9+
"offerStatus": "accepted",
910
"organisation": {
1011
"cph": "33/333/3333",
1112
"sbi": "333333333",
@@ -96,7 +97,7 @@
9697
},
9798
"claimed": true,
9899
"createdAt": "2022-06-06T14:27:51.251Z",
99-
"updatedAt": "2022-06-06T14:27:51.775Z",
100+
"updatedAt": "2022-12-07T14:27:51.775Z",
100101
"createdBy": "admin"
101102
},
102103
"paid": {

test/integration/narrow/routes/applications.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ describe('Applications test', () => {
225225
const res = await global.__SERVER__.inject(options)
226226

227227
const $ = cheerio.load(res.payload)
228-
expect($('p.govuk-error-message').text()).toMatch('Error: Invalid search. It should be application reference or status or sbi number.')
228+
expect($('p.govuk-error-message').text()).toMatch('Error: Invalid search. It should be agreement number, organisation or single business identifier (SBI) number.')
229229
expect(res.statusCode).toBe(400)
230230
})
231231
})

test/integration/narrow/routes/view-application.test.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ describe('View Application test', () => {
3838
expect($('h1.govuk-heading-l').text()).toEqual('400 - Bad Request')
3939
expectPhaseBanner.ok($)
4040
})
41-
test('returns 200 application applied', async () => {
42-
applications.getApplication.mockReturnValueOnce(viewApplicationData.applied)
41+
test('returns 200 application agreed', async () => {
42+
applications.getApplication.mockReturnValueOnce(viewApplicationData.agreed)
4343
const options = {
4444
method: 'GET',
4545
url,
@@ -64,7 +64,7 @@ describe('View Application test', () => {
6464
expect($('.govuk-summary-list__key').eq(3).text()).toMatch('Email address:')
6565
expect($('.govuk-summary-list__value').eq(3).text()).toMatch('[email protected]')
6666

67-
expect($('tbody tr:nth-child(1)').text()).toContain('Agreement formed')
67+
expect($('tbody tr:nth-child(1)').text()).toContain('Date of agreement')
6868
expect($('tbody tr:nth-child(1)').text()).toContain('06/06/2022')
6969
expect($('tbody tr:nth-child(2)').text()).toContain('Business details correct')
7070
expect($('tbody tr:nth-child(2)').text()).toContain('Yes')
@@ -74,7 +74,7 @@ describe('View Application test', () => {
7474
expect($('tbody tr:nth-child(4)').text()).toContain('At least 21')
7575
expect($('tbody tr:nth-child(5)').text()).toContain('Agreement accepted')
7676
expect($('tbody tr:nth-child(5)').text()).toContain('Yes')
77-
expect($('#claim').text()).toContain('Never claimed')
77+
expect($('#claim').text()).toContain('Not claimed yet')
7878
expectPhaseBanner.ok($)
7979
})
8080
test('returns 200 application applied', async () => {
@@ -103,7 +103,7 @@ describe('View Application test', () => {
103103
expect($('.govuk-summary-list__key').eq(3).text()).toMatch('Email address:')
104104
expect($('.govuk-summary-list__value').eq(3).text()).toMatch('[email protected]')
105105

106-
expect($('tbody tr:nth-child(1)').text()).toContain('Agreement not formed')
106+
expect($('tbody tr:nth-child(1)').text()).toContain('Date of agreement rejected')
107107
expect($('tbody tr:nth-child(1)').text()).toContain('06/06/2022')
108108
expect($('tbody tr:nth-child(2)').text()).toContain('Business details correct')
109109
expect($('tbody tr:nth-child(2)').text()).toContain('Yes')
@@ -113,7 +113,7 @@ describe('View Application test', () => {
113113
expect($('tbody tr:nth-child(4)').text()).toContain('At least 21')
114114
expect($('tbody tr:nth-child(5)').text()).toContain('Agreement accepted')
115115
expect($('tbody tr:nth-child(5)').text()).toContain('No')
116-
expect($('#claim').text()).toContain('Never claimed')
116+
expect($('#claim').text()).toContain('Not eligible to claim')
117117
expectPhaseBanner.ok($)
118118
})
119119
test('returns 200 application data inputted', async () => {
@@ -142,7 +142,7 @@ describe('View Application test', () => {
142142
expect($('.govuk-summary-list__key').eq(3).text()).toMatch('Email address:')
143143
expect($('.govuk-summary-list__value').eq(3).text()).toMatch('[email protected]')
144144

145-
expect($('#claim').text()).toContain('Never claimed')
145+
expect($('#claim').text()).toContain('Not eligible to claim')
146146
expectPhaseBanner.ok($)
147147
})
148148
test('returns 200 application claim', async () => {
@@ -173,16 +173,18 @@ describe('View Application test', () => {
173173

174174
expect($('#claim').text()).toContain('Claimed')
175175

176-
expect($('tbody:nth-child(1) tr:nth-child(1)').text()).toContain('Review details confirmed')
177-
expect($('tbody:nth-child(1) tr:nth-child(1)').text()).toContain('Yes')
178-
expect($('tbody:nth-child(1) tr:nth-child(2)').text()).toContain('Date of review')
179-
expect($('tbody:nth-child(1) tr:nth-child(2)').text()).toContain('07/11/2022')
180-
expect($('tbody:nth-child(1) tr:nth-child(3)').text()).toContain('Vet’s name')
181-
expect($('tbody:nth-child(1) tr:nth-child(3)').text()).toContain('testVet')
182-
expect($('tbody:nth-child(1) tr:nth-child(4)').text()).toContain('Vet’s RCVS number')
183-
expect($('tbody:nth-child(1) tr:nth-child(4)').text()).toContain('1234234')
184-
expect($('tbody:nth-child(1) tr:nth-child(5)').text()).toContain('Unique reference number (URN)')
185-
expect($('tbody:nth-child(1) tr:nth-child(5)').text()).toContain('134242')
176+
expect($('tbody:nth-child(1) tr:nth-child(1)').text()).toContain('Date of claim')
177+
expect($('tbody:nth-child(1) tr:nth-child(1)').text()).toContain('07/12/2022')
178+
expect($('tbody:nth-child(1) tr:nth-child(2)').text()).toContain('Review details confirmed')
179+
expect($('tbody:nth-child(1) tr:nth-child(2)').text()).toContain('Yes')
180+
expect($('tbody:nth-child(1) tr:nth-child(3)').text()).toContain('Date of review')
181+
expect($('tbody:nth-child(1) tr:nth-child(3)').text()).toContain('07/11/2022')
182+
expect($('tbody:nth-child(1) tr:nth-child(4)').text()).toContain('Vet’s name')
183+
expect($('tbody:nth-child(1) tr:nth-child(4)').text()).toContain('testVet')
184+
expect($('tbody:nth-child(1) tr:nth-child(5)').text()).toContain('Vet’s RCVS number')
185+
expect($('tbody:nth-child(1) tr:nth-child(5)').text()).toContain('1234234')
186+
expect($('tbody:nth-child(1) tr:nth-child(6)').text()).toContain('Test results unique reference number (URN)')
187+
expect($('tbody:nth-child(1) tr:nth-child(6)').text()).toContain('134242')
186188
expectPhaseBanner.ok($)
187189
})
188190
test('returns 200 application paid', async () => {

0 commit comments

Comments
 (0)