Skip to content

Commit a4aabfd

Browse files
Fix org search (#51)
* fix: organisation name search and content changes * fix: tests * bump: version
1 parent 7245a90 commit a4aabfd

File tree

5 files changed

+15
-34
lines changed

5 files changed

+15
-34
lines changed

app/constants/species-numbers.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
2-
beef: 'At least 11',
3-
dairy: 'At least 11',
4-
pigs: 'At least 51',
5-
sheep: 'At least 21'
2+
beef: 'Minimum 11',
3+
dairy: 'Minimum 11',
4+
pigs: 'Minimum 51',
5+
sheep: 'Minimum 21'
66
}

app/lib/search-validation.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ module.exports = (searchText) => {
1515
case sbiRegEx.test(searchText):
1616
searchType = 'sbi'
1717
break
18+
default:
19+
searchType = 'organisation'
20+
break
1821
}
1922

20-
if (!searchType && searchText.length <= 0) {
23+
if (searchText.length <= 0) {
2124
searchType = 'reset'
2225
}
23-
if (searchType) {
24-
return {
25-
searchText,
26-
searchType
27-
}
28-
} else {
29-
throw new Error('Invalid search. It should be agreement number, organisation or single business identifier (SBI) number.')
26+
27+
return {
28+
searchText,
29+
searchType
3030
}
3131
}

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.3",
3+
"version": "1.14.4",
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/integration/narrow/routes/applications.test.js

-19
Original file line numberDiff line numberDiff line change
@@ -209,24 +209,5 @@ describe('Applications test', () => {
209209
const $ = cheerio.load(res.payload)
210210
expect($('p.govuk-error-message').text()).toMatch('No Applications found.')
211211
})
212-
213-
test.each([
214-
{ searchDetails: { searchText: '1233' } },
215-
{ searchDetails: { searchText: 'sdfgsfgsd' } }
216-
])('returns error', async ({ searchDetails }) => {
217-
const options = {
218-
method,
219-
url,
220-
payload: { crumb, searchText: searchDetails.searchText, status: [] },
221-
auth,
222-
headers: { cookie: `crumb=${crumb}` }
223-
}
224-
225-
const res = await global.__SERVER__.inject(options)
226-
227-
const $ = cheerio.load(res.payload)
228-
expect($('p.govuk-error-message').text()).toMatch('Error: Invalid search. It should be agreement number, organisation or single business identifier (SBI) number.')
229-
expect(res.statusCode).toBe(400)
230-
})
231212
})
232213
})

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('View Application test', () => {
7171
expect($('tbody tr:nth-child(3)').text()).toContain('Type of review')
7272
expect($('tbody tr:nth-child(3)').text()).toContain('Sheep')
7373
expect($('tbody tr:nth-child(4)').text()).toContain('Number of livestock')
74-
expect($('tbody tr:nth-child(4)').text()).toContain('At least 21')
74+
expect($('tbody tr:nth-child(4)').text()).toContain('Minimum 21')
7575
expect($('tbody tr:nth-child(5)').text()).toContain('Agreement accepted')
7676
expect($('tbody tr:nth-child(5)').text()).toContain('Yes')
7777
expect($('#claim').text()).toContain('Not claimed yet')
@@ -110,7 +110,7 @@ describe('View Application test', () => {
110110
expect($('tbody tr:nth-child(3)').text()).toContain('Type of review')
111111
expect($('tbody tr:nth-child(3)').text()).toContain('Sheep')
112112
expect($('tbody tr:nth-child(4)').text()).toContain('Number of livestock')
113-
expect($('tbody tr:nth-child(4)').text()).toContain('At least 21')
113+
expect($('tbody tr:nth-child(4)').text()).toContain('Minimum 21')
114114
expect($('tbody tr:nth-child(5)').text()).toContain('Agreement accepted')
115115
expect($('tbody tr:nth-child(5)').text()).toContain('No')
116116
expect($('#claim').text()).toContain('Not eligible to claim')

0 commit comments

Comments
 (0)