From 5d752e430369f2777649cf3b4b9869cb657beedd Mon Sep 17 00:00:00 2001 From: Shivanshu Patel Date: Fri, 18 Nov 2022 13:37:20 +0000 Subject: [PATCH] fix: search by reference number and status (#49) * fix: search by reference number and status * bump: version --- app/lib/search-validation.js | 4 ++-- package.json | 2 +- test/data/applications.json | 18 +++++++++--------- test/data/view-applications.json | 16 ++++++++-------- .../narrow/routes/applications.test.js | 4 ++-- .../narrow/routes/view-application.test.js | 4 ++-- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/lib/search-validation.js b/app/lib/search-validation.js index c86eb1b6..1e2af616 100644 --- a/app/lib/search-validation.js +++ b/app/lib/search-validation.js @@ -1,5 +1,5 @@ -const appRefRegEx = /^vv-[\da-f]{4}-[\da-f]{4}$/i -const validStatus = ['applied', 'withdrawn', 'data inputted', 'claimed', 'check', 'accepted', 'rejected', 'paid'] +const appRefRegEx = /^AHWR-[\da-f]{4}-[\da-f]{4}$/i +const validStatus = ['agreed', 'applied', 'withdrawn', 'data inputted', 'claimed', 'check', 'accepted', 'rejected', 'paid', 'not agreed'] const sbiRegEx = /^[\0-9]{9}$/i module.exports = (searchText) => { diff --git a/package.json b/package.json index 2bfdad9b..3e394f63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ffc-ahwr-backoffice", - "version": "1.14.1", + "version": "1.14.2", "description": "Back office of the health and welfare of your livestock", "homepage": "https://github.com/DEFRA/ffc-ahwr-backoffice", "main": "app/index.js", diff --git a/test/data/applications.json b/test/data/applications.json index 7ca36f05..cf58dc1b 100644 --- a/test/data/applications.json +++ b/test/data/applications.json @@ -3,7 +3,7 @@ "applications": [ { "id": "555afd4c-b095-4ce4-b492-800466b53393", - "reference": "VV-555A-FD4C", + "reference": "AHWR-555A-FD4C", "status": { "status": "APPLIED" }, "data": { "declaration": true, @@ -26,7 +26,7 @@ }, { "id": "555afd4c-b095-4ce4-b492-800466b54493", - "reference": "VV-555A-FD4D", + "reference": "AHWR-555A-FD4D", "status": { "status": "REJECTED" }, "data": { "declaration": true, @@ -49,7 +49,7 @@ }, { "id": "555afd4c-b095-4ce4-b492-800466b55593", - "reference": "VV-555A-FD5D", + "reference": "AHWR-555A-FD5D", "status": { "status": "DATA INPUTTED" }, "data": { "declaration": true, @@ -72,7 +72,7 @@ }, { "id": "555afd4c-b095-4ce4-b492-800466b66693", - "reference": "VV-555A-FD6E", + "reference": "AHWR-555A-FD6E", "status": { "status": "WITHDRAWN" }, "data": { "declaration": true, @@ -95,7 +95,7 @@ }, { "id": "555afd4c-b095-4ce4-b492-800466b66693", - "reference": "VV-666A-FD6E", + "reference": "AHWR-666A-FD6E", "status": { "status": "ACCEPTED" }, "data": { "declaration": true, @@ -118,7 +118,7 @@ }, { "id": "555afd4c-b095-4ce4-b492-800466b78693", - "reference": "VV-666A-FD7E", + "reference": "AHWR-666A-FD7E", "status": { "status": "CHECK" }, "data": { "declaration": true, @@ -141,7 +141,7 @@ }, { "id": "555afd4c-b095-4ce4-b492-800466b88893", - "reference": "VV-666A-AB6E", + "reference": "AHWR-666A-AB6E", "status": { "status": "CLAIMED" }, "data": { "declaration": true, @@ -164,7 +164,7 @@ }, { "id": "555afd4c-b095-4ce4-b492-800466b90993", - "reference": "VV-666A-RG6E", + "reference": "AHWR-666A-RG6E", "status": { "status": "PAID" }, "data": { "declaration": true, @@ -187,7 +187,7 @@ }, { "id": "555afd4c-b095-4ce4-b492-800466b10993", - "reference": "VV-666A-RG7E", + "reference": "AHWR-666A-RG7E", "status": { "status": "ACCEPTED" }, "data": { "declaration": true, diff --git a/test/data/view-applications.json b/test/data/view-applications.json index 9a9b4822..3b4f353a 100644 --- a/test/data/view-applications.json +++ b/test/data/view-applications.json @@ -1,7 +1,7 @@ { "applied": { "id": "555afd4c-b095-4ce4-b492-800466b53393", - "reference": "VV-555A-FD4C", + "reference": "AHWR-555A-FD4C", "status": { "status": "APPLIED" }, "data": { "declaration": true, @@ -23,9 +23,9 @@ "updatedAt": "2022-06-06T14:27:51.775Z", "createdBy": "admin" }, - "notaggreed": { + "notagreed": { "id": "555afd4c-b095-4ce4-b492-800466b53393", - "reference": "VV-555A-FD4C", + "reference": "AHWR-555A-FD4C", "status": { "status": "NOT AGREED" }, "data": { "whichReview": "sheep", @@ -48,7 +48,7 @@ }, "dataInputted": { "id": "555afd4c-b095-4ce4-b492-800466b53393", - "reference": "VV-555A-FD4C", + "reference": "AHWR-555A-FD4C", "status": { "status": "DATA INPUTTED" }, "data": { "declaration": true, @@ -72,7 +72,7 @@ }, "claim": { "id": "555afd4c-b095-4ce4-b492-800466b53393", - "reference": "VV-555A-FD4C", + "reference": "AHWR-555A-FD4C", "status": { "status": "CLAIMED" }, "data": { "declaration": true, @@ -101,7 +101,7 @@ }, "paid": { "id": "555afd4c-b095-4ce4-b492-800466b53393", - "reference": "VV-555A-FD4C", + "reference": "AHWR-555A-FD4C", "status": { "status": "ACCEPTED" }, "data": { "declaration": true, @@ -119,11 +119,11 @@ "confirmCheckDetails": "yes" }, "payment": { - "applicationReference": "VV-555A-FD4C", + "applicationReference": "AHWR-555A-FD4C", "data": { "value": 400, "frn": 1102057452, - "invoiceNumber": "VV-F528-5345V001", + "invoiceNumber": "AHWR-F528-5345V001", "invoiceLines": [{ "description": "G00 - Gross value of claim", "value": 400 diff --git a/test/integration/narrow/routes/applications.test.js b/test/integration/narrow/routes/applications.test.js index 8ce163e7..97066029 100644 --- a/test/integration/narrow/routes/applications.test.js +++ b/test/integration/narrow/routes/applications.test.js @@ -148,7 +148,7 @@ describe('Applications test', () => { test.each([ { searchDetails: { searchText: '444444444', searchType: 'sbi' }, status: ['APPLIED', 'DATA INPUTTED'] }, - { searchDetails: { searchText: 'VV-555A-FD6E', searchType: 'ref' }, status: ['APPLIED', 'CLAIMED'] }, + { searchDetails: { searchText: 'AHWR-555A-FD6E', searchType: 'ref' }, status: ['APPLIED', 'CLAIMED'] }, { searchDetails: { searchText: 'applied', searchType: 'status' }, status: 'APPLIED' }, { searchDetails: { searchText: 'data inputted', searchType: 'status' }, status: 'DATA INPUTTED' }, { searchDetails: { searchText: 'claimed', searchType: 'status' }, status: 'CLAIMED' }, @@ -181,7 +181,7 @@ describe('Applications test', () => { test.each([ { searchDetails: { searchText: '333333333' } }, { searchDetails: { searchText: '444444443' } }, - { searchDetails: { searchText: 'VV-555A-F5D5' } }, + { searchDetails: { searchText: 'AHWR-555A-F5D5' } }, { searchDetails: { searchText: '' } }, { searchDetails: { searchText: null } }, { searchDetails: { searchText: undefined } } diff --git a/test/integration/narrow/routes/view-application.test.js b/test/integration/narrow/routes/view-application.test.js index 2d506609..0d95f84b 100644 --- a/test/integration/narrow/routes/view-application.test.js +++ b/test/integration/narrow/routes/view-application.test.js @@ -3,7 +3,7 @@ const expectPhaseBanner = require('../../../utils/phase-banner-expect') const applications = require('../../../../app/api/applications') const { administrator } = require('../../../../app/auth/permissions') const viewApplicationData = require('.././../../data/view-applications.json') -const reference = 'VV-555A-FD4C' +const reference = 'AHWR-555A-FD4C' jest.mock('../../../../app/api/applications') @@ -78,7 +78,7 @@ describe('View Application test', () => { expectPhaseBanner.ok($) }) test('returns 200 application applied', async () => { - applications.getApplication.mockReturnValueOnce(viewApplicationData.notaggreed) + applications.getApplication.mockReturnValueOnce(viewApplicationData.notagreed) const options = { method: 'GET', url,