From 4c99d4f95ef415307db259ab3af32bb762d3c39f Mon Sep 17 00:00:00 2001 From: Kial Jinnah Date: Wed, 27 Feb 2019 10:13:04 -0800 Subject: [PATCH 1/4] edit name validation working Signed-off-by: Kial Jinnah --- .../application/Examine/RequestInfoHeader.vue | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/client/src/components/application/Examine/RequestInfoHeader.vue b/client/src/components/application/Examine/RequestInfoHeader.vue index a64a44c5..fdcf4ad2 100644 --- a/client/src/components/application/Examine/RequestInfoHeader.vue +++ b/client/src/components/application/Examine/RequestInfoHeader.vue @@ -159,13 +159,18 @@
The first name choice is required.
- + 2. - + + +
To include a 3rd name choice the 2nd name choice is required.
+ 3. - + + + @@ -267,6 +272,24 @@ export default { }, } + // if compName3 exists then compName2 must exist + console.log(this.compName3) + console.log('HERE1') + if (this.compName3.name) { + console.log('HERE2') + validations.compName2 = { + name: { + required, + } + } + } else { + validations.compName2 = { + name: { + } + } + } + console.log('AHA') + // validate jurisdiction if required if (this.jurisdiction_required && !this.is_closed) { validations.jurisdiction = { @@ -337,7 +360,7 @@ export default { }, } } - + console.log('end') return validations; }, From 13413ecd070f07168b95db3745e34b77c5f4a776 Mon Sep 17 00:00:00 2001 From: Kial Jinnah Date: Wed, 27 Feb 2019 13:52:53 -0800 Subject: [PATCH 2/4] cleaned up log statements --- .../src/components/application/Examine/RequestInfoHeader.vue | 5 ----- 1 file changed, 5 deletions(-) diff --git a/client/src/components/application/Examine/RequestInfoHeader.vue b/client/src/components/application/Examine/RequestInfoHeader.vue index fdcf4ad2..43706c88 100644 --- a/client/src/components/application/Examine/RequestInfoHeader.vue +++ b/client/src/components/application/Examine/RequestInfoHeader.vue @@ -273,10 +273,7 @@ export default { } // if compName3 exists then compName2 must exist - console.log(this.compName3) - console.log('HERE1') if (this.compName3.name) { - console.log('HERE2') validations.compName2 = { name: { required, @@ -288,7 +285,6 @@ export default { } } } - console.log('AHA') // validate jurisdiction if required if (this.jurisdiction_required && !this.is_closed) { @@ -360,7 +356,6 @@ export default { }, } } - console.log('end') return validations; }, From c8d6d3d8f6df344ea108da91a6a79d4fa39b41cc Mon Sep 17 00:00:00 2001 From: Kial Jinnah Date: Thu, 28 Feb 2019 17:08:29 -0800 Subject: [PATCH 3/4] tests for edit name choice validation added Signed-off-by: Kial Jinnah --- .../application/Examine/CompName.vue | 1 - .../test/unit/specs/RequestInfoHeader.spec.js | 25 +++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/client/src/components/application/Examine/CompName.vue b/client/src/components/application/Examine/CompName.vue index 911ee41f..850c2dd0 100644 --- a/client/src/components/application/Examine/CompName.vue +++ b/client/src/components/application/Examine/CompName.vue @@ -472,7 +472,6 @@ }, runManualRecipe(){ console.log("Running manual recipe on " + this.searchStr + '/' + this.exactPhrase); - console.log('HERE2: ', this.exactPhrase) this.$store.dispatch('runManualRecipe', {searchStr:this.searchStr, exactPhrase:this.exactPhrase}); }, setIcon(name_state) { diff --git a/client/test/unit/specs/RequestInfoHeader.spec.js b/client/test/unit/specs/RequestInfoHeader.spec.js index 16f692f0..ac217d57 100644 --- a/client/test/unit/specs/RequestInfoHeader.spec.js +++ b/client/test/unit/specs/RequestInfoHeader.spec.js @@ -499,7 +499,7 @@ describe('RequestInfoHeader.vue', () => { state: "NE" }], natureBusinessInfo: "Nature of business can be pretty long so this one is more realistic. It even contains " + - "spaces and punctuation.", + "spaces and punctuation.", nrNum: "NR 2000948", nwpta: [], previousNr: null, @@ -565,7 +565,7 @@ describe('RequestInfoHeader.vue', () => { state: "NE" }], natureBusinessInfo: "Nature of business can be pretty long so this one is more realistic. It even contains " + - "spaces and punctuation.", + "spaces and punctuation.", nrNum: "NR 2000948", nwpta: [], previousNr: null, @@ -650,6 +650,27 @@ describe('RequestInfoHeader.vue', () => { console.log('finished'); }); }); + + it('Validates the name choices properly', () => { + vm.compName2.name = ''; + vm.compName3.name = ''; + expect(vm.validate()).toBeTruthy(); + vm.compName3.name = 'Test add name choice 3'; + expect(vm.validate()).toBeFalsy(); + vm.compName2.name = 'Test add name choice 2'; + expect(vm.validate()).toBeTruthy(); + vm.compName2.name = ''; + expect(vm.validate()).toBeFalsy(); + + // this should do nothing + click('#nr-details-save-button'); + + // reset names and cancel edit - if above 'saved' this will error + vm.compName2.name = ''; + vm.compName3.name = ''; + expect(vm.validate()).toBeTruthy(); + click('#nr-details-cancel-button'); + }); }); describe('Edit button hiding testing', () => { From c9884dd71d9f1b8202e72a42db8adbfa916466ba Mon Sep 17 00:00:00 2001 From: Kial Jinnah Date: Mon, 4 Mar 2019 11:45:10 -0800 Subject: [PATCH 4/4] updated validations to handle whitespace Signed-off-by: Kial Jinnah --- client/custom_validations/validators.js | 6 ++++++ .../application/Examine/RequestInfoHeader.vue | 10 ++++++---- client/test/unit/specs/RequestInfoHeader.spec.js | 8 ++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 client/custom_validations/validators.js diff --git a/client/custom_validations/validators.js b/client/custom_validations/validators.js new file mode 100644 index 00000000..3623e8e4 --- /dev/null +++ b/client/custom_validations/validators.js @@ -0,0 +1,6 @@ +/*eslint-disable*/ +export function isNotBlankSpace(value) { + if (value) + return value.replace(/\s/g,'')!=''; + return false; +} diff --git a/client/src/components/application/Examine/RequestInfoHeader.vue b/client/src/components/application/Examine/RequestInfoHeader.vue index 43706c88..9a4f3c0a 100644 --- a/client/src/components/application/Examine/RequestInfoHeader.vue +++ b/client/src/components/application/Examine/RequestInfoHeader.vue @@ -156,14 +156,14 @@ @@ -243,6 +243,7 @@ import clientinfoview from '@/components/application/Examine/client/ClientInfoHeader.vue'; import nwpta from '@/components/application/Examine/nwpta/nwpta.vue'; import { required } from 'vuelidate/lib/validators' +import { isNotBlankSpace } from "../../../../custom_validations/validators"; import axios from '@/axios-auth'; @@ -261,22 +262,23 @@ export default { } }, validations: function () { - // set basic validations that aren't conditional on any other fields var validations = { // first name choice is always required compName1: { name: { required, + isNotBlankSpace } }, } // if compName3 exists then compName2 must exist - if (this.compName3.name) { + if (this.compName3.name && this.compName3.name.replace(/\s/g,'')) { validations.compName2 = { name: { required, + isNotBlankSpace } } } else { diff --git a/client/test/unit/specs/RequestInfoHeader.spec.js b/client/test/unit/specs/RequestInfoHeader.spec.js index ac217d57..bfd6bf80 100644 --- a/client/test/unit/specs/RequestInfoHeader.spec.js +++ b/client/test/unit/specs/RequestInfoHeader.spec.js @@ -652,6 +652,9 @@ describe('RequestInfoHeader.vue', () => { }); it('Validates the name choices properly', () => { + vm.compName1.name = ''; + expect(vm.validate()).toBeFalsy(); + vm.compName1.name = 'COLDSTREAM REFRIGERATION HVAC SERVICES LIMITED'; vm.compName2.name = ''; vm.compName3.name = ''; expect(vm.validate()).toBeTruthy(); @@ -659,7 +662,12 @@ describe('RequestInfoHeader.vue', () => { expect(vm.validate()).toBeFalsy(); vm.compName2.name = 'Test add name choice 2'; expect(vm.validate()).toBeTruthy(); + vm.compName2.name = ' '; + expect(vm.validate()).toBeFalsy(); vm.compName2.name = ''; + vm.compName3.name = ' '; + expect(vm.validate()).toBeTruthy(); + vm.compName3.name = 'Test add name choice 3'; expect(vm.validate()).toBeFalsy(); // this should do nothing
1. -
The first name choice is required.
+
The first name choice is required.
2. -
To include a 3rd name choice the 2nd name choice is required.
+
To include a 3rd name choice the 2nd name choice is required.