Skip to content

Commit

Permalink
fix: search by reference number and status (#49)
Browse files Browse the repository at this point in the history
* fix: search by reference number and status

* bump: version
  • Loading branch information
shivanshuit914 authored Nov 18, 2022
1 parent be093cc commit 5d752e4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/lib/search-validation.js
Original file line number Diff line number Diff line change
@@ -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) => {
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.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",
Expand Down
18 changes: 9 additions & 9 deletions test/data/applications.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -26,7 +26,7 @@
},
{
"id": "555afd4c-b095-4ce4-b492-800466b54493",
"reference": "VV-555A-FD4D",
"reference": "AHWR-555A-FD4D",
"status": { "status": "REJECTED" },
"data": {
"declaration": true,
Expand All @@ -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,
Expand All @@ -72,7 +72,7 @@
},
{
"id": "555afd4c-b095-4ce4-b492-800466b66693",
"reference": "VV-555A-FD6E",
"reference": "AHWR-555A-FD6E",
"status": { "status": "WITHDRAWN" },
"data": {
"declaration": true,
Expand All @@ -95,7 +95,7 @@
},
{
"id": "555afd4c-b095-4ce4-b492-800466b66693",
"reference": "VV-666A-FD6E",
"reference": "AHWR-666A-FD6E",
"status": { "status": "ACCEPTED" },
"data": {
"declaration": true,
Expand All @@ -118,7 +118,7 @@
},
{
"id": "555afd4c-b095-4ce4-b492-800466b78693",
"reference": "VV-666A-FD7E",
"reference": "AHWR-666A-FD7E",
"status": { "status": "CHECK" },
"data": {
"declaration": true,
Expand All @@ -141,7 +141,7 @@
},
{
"id": "555afd4c-b095-4ce4-b492-800466b88893",
"reference": "VV-666A-AB6E",
"reference": "AHWR-666A-AB6E",
"status": { "status": "CLAIMED" },
"data": {
"declaration": true,
Expand All @@ -164,7 +164,7 @@
},
{
"id": "555afd4c-b095-4ce4-b492-800466b90993",
"reference": "VV-666A-RG6E",
"reference": "AHWR-666A-RG6E",
"status": { "status": "PAID" },
"data": {
"declaration": true,
Expand All @@ -187,7 +187,7 @@
},
{
"id": "555afd4c-b095-4ce4-b492-800466b10993",
"reference": "VV-666A-RG7E",
"reference": "AHWR-666A-RG7E",
"status": { "status": "ACCEPTED" },
"data": {
"declaration": true,
Expand Down
16 changes: 8 additions & 8 deletions test/data/view-applications.json
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/integration/narrow/routes/applications.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down Expand Up @@ -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 } }
Expand Down
4 changes: 2 additions & 2 deletions test/integration/narrow/routes/view-application.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5d752e4

Please sign in to comment.