Skip to content

Commit

Permalink
feat: change application details tabs content (#50)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
shivanshuit914 authored Nov 21, 2022
1 parent 5d752e4 commit 7245a90
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 33 deletions.
2 changes: 1 addition & 1 deletion app/lib/search-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ module.exports = (searchText) => {
searchType
}
} else {
throw new Error('Invalid search. It should be application reference or status or sbi number.')
throw new Error('Invalid search. It should be agreement number, organisation or single business identifier (SBI) number.')
}
}
6 changes: 4 additions & 2 deletions app/routes/models/application-claim.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
const { formatedDateToUk, upperFirstLetter } = require('../../lib/display-helper')

module.exports = (application) => {
const { data } = application
const { data, updatedAt } = application
const formatedDate = formatedDateToUk(updatedAt)
return {
firstCellIsHeader: true,
rows: [
[{ text: 'Date of claim' }, { text: formatedDate }],
[{ text: 'Review details confirmed' }, { text: upperFirstLetter(data?.confirmCheckDetails) }],
[{ text: 'Date of review' }, { text: formatedDateToUk(data?.visitDate) }],
[{ text: 'Vet’s name' }, { text: data?.vetName }],
[{ text: 'Vet’s RCVS number' }, { text: data?.vetRcvs }],
[{ text: 'Unique reference number (URN)' }, { text: data?.urnResult }]
[{ text: 'Test results unique reference number (URN)' }, { text: data?.urnResult }]
]
}
}
1 change: 0 additions & 1 deletion app/routes/models/application-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ async function createModel (request, page) {
if (apps.total > 0) {
let statusClass
const applications = apps.applications.map(n => {
n.status.status = n.status.status === 'APPLIED' ? 'AGREED' : n.status.status
statusClass = getStyleClassByStatus(n.status.status)
return [
{ text: n.reference },
Expand Down
5 changes: 3 additions & 2 deletions app/routes/models/farmer-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ const speciesNumbers = require('../../../app/constants/species-numbers')
module.exports = (application) => {
const { data, createdAt, status } = application
const formatedDate = formatedDateToUk(createdAt)

return {
firstCellIsHeader: true,
rows: [
[{ text: status.status === 'REJECTED' || status.status === 'NOT AGREED' ? 'Agreement not formed' : 'Agreement formed' }, { text: formatedDate }],
[{ text: status.status === 'NOT AGREED' ? 'Date of agreement rejected' : 'Date of agreement' }, { text: formatedDate }],
[{ text: 'Business details correct' }, { text: upperFirstLetter(data.confirmCheckDetails) }],
[{ text: 'Type of review' }, { text: upperFirstLetter(data.whichReview) }],
[{ text: 'Number of livestock' }, { text: speciesNumbers[data.whichReview] }],
[{ text: 'Agreement accepted' }, { text: data.declaration ? 'Yes' : 'No' }]
[{ text: 'Agreement accepted' }, { text: data.offerStatus === 'accepted' ? 'Yes' : 'No' }]
]
}
}
2 changes: 1 addition & 1 deletion app/routes/view-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module.exports = {
throw boom.badRequest()
}

const status = upperFirstLetter(application.status.status.toLowerCase())
const statusClass = getStyleClassByStatus(application.status.status)
const status = application.status.status === 'APPLIED' ? 'Agreed' : upperFirstLetter(application.status.status.toLowerCase())
return h.view('view-application', {
applicationId: application.reference,
status,
Expand Down
4 changes: 3 additions & 1 deletion app/views/macros/view-application-tabs.njk
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
{% if claimed %}
<h2 class="govuk-heading-l">Claimed</h2>
{{ govukTable(model.claimData) }}
{% elif (status == "Agreed") %}
<h2 class="govuk-heading-l">Not claimed yet</h2>
{% else %}
<h2 class="govuk-heading-l">Never claimed</h2>
<h2 class="govuk-heading-l">Not eligible to claim</h2>
{% endif %}
{% endset -%}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffc-ahwr-backoffice",
"version": "1.14.2",
"version": "1.14.3",
"description": "Back office of the health and welfare of your livestock",
"homepage": "https://github.com/DEFRA/ffc-ahwr-backoffice",
"main": "app/index.js",
Expand Down
6 changes: 3 additions & 3 deletions test/data/applications.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"id": "555afd4c-b095-4ce4-b492-800466b53393",
"reference": "AHWR-555A-FD4C",
"status": { "status": "APPLIED" },
"status": { "status": "AGREED" },
"data": {
"declaration": true,
"whichReview": "sheep",
Expand Down Expand Up @@ -211,9 +211,9 @@
],
"applicationStatus": [
{
"status": "APPLIED",
"status": "AGREED",
"total": "23",
"status.status": "APPLIED"
"status.status": "AGREED"
},
{
"status": "CLAIMED",
Expand Down
7 changes: 4 additions & 3 deletions test/data/view-applications.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"applied": {
"agreed": {
"id": "555afd4c-b095-4ce4-b492-800466b53393",
"reference": "AHWR-555A-FD4C",
"status": { "status": "APPLIED" },
"status": { "status": "AGREED" },
"data": {
"declaration": true,
"whichReview": "sheep",
"offerStatus": "accepted",
"organisation": {
"cph": "33/333/3333",
"sbi": "333333333",
Expand Down Expand Up @@ -96,7 +97,7 @@
},
"claimed": true,
"createdAt": "2022-06-06T14:27:51.251Z",
"updatedAt": "2022-06-06T14:27:51.775Z",
"updatedAt": "2022-12-07T14:27:51.775Z",
"createdBy": "admin"
},
"paid": {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/narrow/routes/applications.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('Applications test', () => {
const res = await global.__SERVER__.inject(options)

const $ = cheerio.load(res.payload)
expect($('p.govuk-error-message').text()).toMatch('Error: Invalid search. It should be application reference or status or sbi number.')
expect($('p.govuk-error-message').text()).toMatch('Error: Invalid search. It should be agreement number, organisation or single business identifier (SBI) number.')
expect(res.statusCode).toBe(400)
})
})
Expand Down
36 changes: 19 additions & 17 deletions test/integration/narrow/routes/view-application.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ describe('View Application test', () => {
expect($('h1.govuk-heading-l').text()).toEqual('400 - Bad Request')
expectPhaseBanner.ok($)
})
test('returns 200 application applied', async () => {
applications.getApplication.mockReturnValueOnce(viewApplicationData.applied)
test('returns 200 application agreed', async () => {
applications.getApplication.mockReturnValueOnce(viewApplicationData.agreed)
const options = {
method: 'GET',
url,
Expand All @@ -64,7 +64,7 @@ describe('View Application test', () => {
expect($('.govuk-summary-list__key').eq(3).text()).toMatch('Email address:')
expect($('.govuk-summary-list__value').eq(3).text()).toMatch('[email protected]')

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

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

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

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

expect($('tbody:nth-child(1) tr:nth-child(1)').text()).toContain('Review details confirmed')
expect($('tbody:nth-child(1) tr:nth-child(1)').text()).toContain('Yes')
expect($('tbody:nth-child(1) tr:nth-child(2)').text()).toContain('Date of review')
expect($('tbody:nth-child(1) tr:nth-child(2)').text()).toContain('07/11/2022')
expect($('tbody:nth-child(1) tr:nth-child(3)').text()).toContain('Vet’s name')
expect($('tbody:nth-child(1) tr:nth-child(3)').text()).toContain('testVet')
expect($('tbody:nth-child(1) tr:nth-child(4)').text()).toContain('Vet’s RCVS number')
expect($('tbody:nth-child(1) tr:nth-child(4)').text()).toContain('1234234')
expect($('tbody:nth-child(1) tr:nth-child(5)').text()).toContain('Unique reference number (URN)')
expect($('tbody:nth-child(1) tr:nth-child(5)').text()).toContain('134242')
expect($('tbody:nth-child(1) tr:nth-child(1)').text()).toContain('Date of claim')
expect($('tbody:nth-child(1) tr:nth-child(1)').text()).toContain('07/12/2022')
expect($('tbody:nth-child(1) tr:nth-child(2)').text()).toContain('Review details confirmed')
expect($('tbody:nth-child(1) tr:nth-child(2)').text()).toContain('Yes')
expect($('tbody:nth-child(1) tr:nth-child(3)').text()).toContain('Date of review')
expect($('tbody:nth-child(1) tr:nth-child(3)').text()).toContain('07/11/2022')
expect($('tbody:nth-child(1) tr:nth-child(4)').text()).toContain('Vet’s name')
expect($('tbody:nth-child(1) tr:nth-child(4)').text()).toContain('testVet')
expect($('tbody:nth-child(1) tr:nth-child(5)').text()).toContain('Vet’s RCVS number')
expect($('tbody:nth-child(1) tr:nth-child(5)').text()).toContain('1234234')
expect($('tbody:nth-child(1) tr:nth-child(6)').text()).toContain('Test results unique reference number (URN)')
expect($('tbody:nth-child(1) tr:nth-child(6)').text()).toContain('134242')
expectPhaseBanner.ok($)
})
test('returns 200 application paid', async () => {
Expand Down

0 comments on commit 7245a90

Please sign in to comment.