diff --git a/package-lock.json b/package-lock.json
index a1acc461..1be652c4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "business-edit-ui",
- "version": "4.7.6",
+ "version": "4.7.7",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "business-edit-ui",
- "version": "4.7.6",
+ "version": "4.7.7",
"dependencies": {
"@babel/compat-data": "^7.21.5",
"@bcrs-shared-components/action-chip": "1.1.5",
diff --git a/package.json b/package.json
index 88929d22..769588b9 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "business-edit-ui",
- "version": "4.7.6",
+ "version": "4.7.7",
"private": true,
"appName": "Edit UI",
"sbcName": "SBC Common Components",
diff --git a/src/dialogs/NameRequestErrorDialog.vue b/src/dialogs/NameRequestErrorDialog.vue
index ebd8da28..453bf9ce 100644
--- a/src/dialogs/NameRequestErrorDialog.vue
+++ b/src/dialogs/NameRequestErrorDialog.vue
@@ -28,8 +28,8 @@
We could not find a match for the information you have entered.
Please verify the NR Number and the phone number or email address and try again.
diff --git a/src/enums/nameRequestStates.ts b/src/enums/nameRequestStates.ts
index 854b5783..a541cac8 100644
--- a/src/enums/nameRequestStates.ts
+++ b/src/enums/nameRequestStates.ts
@@ -12,6 +12,8 @@ export enum NameRequestStates {
INPROGRESS = 'INPROGRESS',
REJECTED = 'REJECTED',
NRO_UPDATING = 'NRO_UPDATING',
+ NO_CONTACT = 'NO_CONTACT',
+ INCORRECT_CONTACT = 'INCORRECT_CONTACT',
// ADDITIONAL UI STATES FOR ERROR HANDLING
NOT_APPROVED = 'NOT_APPROVED',
@@ -19,8 +21,4 @@ export enum NameRequestStates {
NOT_FOUND = 'NOT_FOUND',
NEED_CONSENT = 'NEED_CONSENT',
INVALID = 'INVALID',
-
- // ADDITIONAL UI STATES FOR NR VALIDATION
- INCORRECT_EMAIL = 'INCORRECT_EMAIL',
- INCORRECT_PHONE = 'INCORRECT_PHONE',
}
diff --git a/src/mixins/name-request-mixin.ts b/src/mixins/name-request-mixin.ts
index 2baf3a49..6d9010bf 100644
--- a/src/mixins/name-request-mixin.ts
+++ b/src/mixins/name-request-mixin.ts
@@ -6,6 +6,7 @@ import { NrRequestActionCodes } from '@bcrs-shared-components/enums'
import { LegalServices } from '@/services/'
import { NrResponseIF, ResourceIF } from '@/interfaces/'
import { useStore } from '@/store/store'
+import { StatusCodes } from 'http-status-codes'
/**
* Mixin for processing Name Request objects.
@@ -23,23 +24,20 @@ export default class NameRequestMixin extends Vue {
* @returns the name request response payload
*/
async validateNameRequest (nrNumber: string, phone?: string, email?: string): Promise {
- const nrResponse: NrResponseIF = await LegalServices.fetchNameRequest(nrNumber).catch(error => {
- this.$root.$emit('invalid-name-request', NameRequestStates.NOT_FOUND)
+ const nrResponse: NrResponseIF = await LegalServices.fetchNameRequest(nrNumber, phone, email).catch(error => {
+ if (error?.response?.status === StatusCodes.NOT_FOUND) {
+ this.$root.$emit('invalid-name-request', NameRequestStates.NOT_FOUND)
+ throw new Error(`${nrNumber} not found`) // Sent invalid NR number
+ } else if (error?.response?.status === StatusCodes.BAD_REQUEST) {
+ this.$root.$emit('invalid-name-request', NameRequestStates.INCORRECT_CONTACT)
+ throw new Error('Sent invalid email or phone number.') // Sent invalid email or phone
+ } else if (error?.response?.status === StatusCodes.FORBIDDEN) {
+ this.$root.$emit('invalid-name-request', NameRequestStates.NO_CONTACT)
+ throw new Error('Not sent email or phone number.') // Not sent the email or phone
+ }
throw new Error(`Fetch Name Request error: ${error}`)
})
- // validate email
- if (email && nrResponse.applicants?.emailAddress !== email) {
- this.$root.$emit('invalid-name-request', NameRequestStates.INCORRECT_EMAIL)
- throw new Error(`Incorrect Email`)
- }
-
- // validate phone
- if (phone && nrResponse.applicants?.phoneNumber !== phone) {
- this.$root.$emit('invalid-name-request', NameRequestStates.INCORRECT_PHONE)
- throw new Error(`Incorrect Phone`)
- }
-
// ensure NR is valid
const isNrValid = this.isNrValid(nrResponse)
if (!nrResponse || !isNrValid) {
diff --git a/src/services/legal-services.ts b/src/services/legal-services.ts
index 7ba2b798..21665193 100644
--- a/src/services/legal-services.ts
+++ b/src/services/legal-services.ts
@@ -312,10 +312,12 @@ export default class LegalServices {
/**
* Fetches name request data.
* @param nrNumber the name request number (eg, NR 1234567) to fetch
+ * @param phone the name request phone (eg, 12321232)
+ * @param email the name request email (eg, nr@example.com)
* @returns a promise to return the NR data, or null if not found
*/
- static async fetchNameRequest (nrNumber: string): Promise {
- const url = `nameRequests/${nrNumber}`
+ static async fetchNameRequest (nrNumber: string, phone = '', email = ''): Promise {
+ const url = `nameRequests/${nrNumber}/validate?phone=${phone}&email=${email}`
return axios.get(url)
.then(response => {
diff --git a/tests/unit/Actions.spec.ts b/tests/unit/Actions.spec.ts
index 181e0956..1229d219 100644
--- a/tests/unit/Actions.spec.ts
+++ b/tests/unit/Actions.spec.ts
@@ -236,7 +236,7 @@ describe.skip('Emits error event if NR validation fails in file and pay', () =>
expiredNR['expirationDate'] = 'Thu, 31 Dec 2019 23:59:59 GMT'
// GET NR data
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=&email=')
.returns(Promise.resolve({
data: expiredNR
}))
@@ -487,7 +487,7 @@ describe.skip('Actions component - Filing Functionality', () => {
const get = sinon.stub(axios, 'get')
// GET NR data
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=&email=')
.returns(Promise.resolve({
data:
{
diff --git a/tests/unit/App.spec.ts b/tests/unit/App.spec.ts
index f06459b1..4747a23a 100644
--- a/tests/unit/App.spec.ts
+++ b/tests/unit/App.spec.ts
@@ -439,7 +439,7 @@ describe.skip('App component', () => {
}))
// GET NR data
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=&email=')
.returns(Promise.resolve({
data:
{
diff --git a/tests/unit/CorrectNameRequest.spec.ts b/tests/unit/CorrectNameRequest.spec.ts
index a70efe36..05ebb8ed 100644
--- a/tests/unit/CorrectNameRequest.spec.ts
+++ b/tests/unit/CorrectNameRequest.spec.ts
@@ -293,7 +293,7 @@ describe('CorrectNameRequest', () => {
store.stateModel.tombstone.currentDate = '2021-01-20'
// GET NR Data
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=250 516 8257&email=')
.returns(Promise.resolve({
data:
{
@@ -338,7 +338,7 @@ describe('CorrectNameRequest', () => {
const vm = wrapper.vm as any
// GET NR Data
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=250 516 8258&email=mock@example.com')
.returns(Promise.resolve({
data:
{
@@ -383,7 +383,7 @@ describe('CorrectNameRequest', () => {
const vm = wrapper.vm as any
// GET NR Data
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=250 516 8258&email=mock@example.com')
.returns(Promise.resolve({
data:
{
@@ -430,7 +430,7 @@ describe('CorrectNameRequest', () => {
store.stateModel.tombstone.currentDate = '2021-01-20'
// GET NR Data
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=250 516 8257&email=')
.returns(Promise.resolve({
data:
{
@@ -483,7 +483,7 @@ describe('CorrectNameRequest', () => {
store.stateModel.tombstone.entityType = CorpTypeCd.PARTNERSHIP
// GET NR Data
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=250 516 8257&email=')
.returns(Promise.resolve({
data:
{
@@ -531,7 +531,7 @@ describe('CorrectNameRequest', () => {
store.stateModel.tombstone.entityType = CorpTypeCd.SOLE_PROP
// GET NR Data
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=250 516 8258&email=')
.returns(Promise.resolve({
data:
{
diff --git a/tests/unit/NameRequestErrorDialog.spec.ts b/tests/unit/NameRequestErrorDialog.spec.ts
index 06a2ae0d..9b6187e9 100644
--- a/tests/unit/NameRequestErrorDialog.spec.ts
+++ b/tests/unit/NameRequestErrorDialog.spec.ts
@@ -30,7 +30,7 @@ describe('Name Request Error Dialog', () => {
it('displays "incorrect email" message', async () => {
const wrapper = mount(NameRequestErrorDialog, {
vuetify,
- propsData: { dialog: true, type: 'INCORRECT_EMAIL' }
+ propsData: { dialog: true, type: 'INCORRECT_CONTACT' }
})
await Vue.nextTick()
@@ -48,7 +48,7 @@ describe('Name Request Error Dialog', () => {
it('displays "incorrect phone" message', async () => {
const wrapper = mount(NameRequestErrorDialog, {
vuetify,
- propsData: { dialog: true, type: 'INCORRECT_PHONE' }
+ propsData: { dialog: true, type: 'NO_CONTACT' }
})
await Vue.nextTick()
diff --git a/tests/unit/legal-services.spec.ts b/tests/unit/legal-services.spec.ts
index ae4851b0..55f5d7f8 100644
--- a/tests/unit/legal-services.spec.ts
+++ b/tests/unit/legal-services.spec.ts
@@ -223,7 +223,7 @@ describe('Legal Services', () => {
}
// mock endpoint
- get.withArgs('nameRequests/NR1234567')
+ get.withArgs('nameRequests/NR1234567/validate?phone=&email=')
.returns(Promise.resolve({ data: NR }))
// call method
@@ -332,7 +332,7 @@ describe('Legal Services', () => {
await expect(LegalServices.fetchResolutions('CP1234567')).rejects.toThrow('Invalid API response')
// verify fetchNameRequest with no response.data
- get.withArgs('nameRequests/NR1234567').returns(Promise.resolve({}))
+ get.withArgs('nameRequests/NR1234567/validate?phone=&email=').returns(Promise.resolve({}))
await expect(LegalServices.fetchNameRequest('NR1234567')).rejects.toThrow('Invalid API response')
// verify fetchBusinessDocuments with no response.data
diff --git a/tests/unit/name-request-mixin.spec.ts b/tests/unit/name-request-mixin.spec.ts
index 7b672425..548e3587 100644
--- a/tests/unit/name-request-mixin.spec.ts
+++ b/tests/unit/name-request-mixin.spec.ts
@@ -50,7 +50,7 @@ describe('Name Request Mixin', () => {
console.log = vi.fn()
// mock fetchNameRequest to throw an error
- get.withArgs('nameRequests/NR 1234567').returns(Promise.resolve(null))
+ get.withArgs('nameRequests/NR 1234567/validate?phone=phone&email=email').returns(Promise.resolve(null))
try {
await vm.validateNameRequest('NR 1234567', 'phone', 'email')
@@ -65,43 +65,9 @@ describe('Name Request Mixin', () => {
console.log = log
})
- it('handles incorrect email errors', async () => {
- // mock fetchNameRequest to return different email address
- get.withArgs('nameRequests/NR 1234567')
- .returns(Promise.resolve({ data: {
- applicants: { emailAddress: 'other' }
- } }))
-
- try {
- await vm.validateNameRequest('NR 1234567', 'phone', 'email')
- } catch (err) {
- // verify thrown error
- expect((err as any).message).toBe('Incorrect Email')
- // FUTURE: figure out how to verify emitted error (invalid-name-request)
- // expect(wrapper.emitted('invalid-name-request')).toEqual([['INCORRECT_EMAIL']])
- }
- })
-
- it('handles incorrect phone errors', async () => {
- // mock fetchNameRequest to return different phone number
- get.withArgs('nameRequests/NR 1234567')
- .returns(Promise.resolve({ data: {
- applicants: { emailAddress: 'email', phoneNumber: 'other' }
- } }))
-
- try {
- await vm.validateNameRequest('NR 1234567', 'phone', 'email')
- } catch (err) {
- // verify thrown error
- expect((err as any).message).toBe('Incorrect Phone')
- // FUTURE: figure out how to verify emitted error (invalid-name-request)
- // expect(wrapper.emitted('invalid-name-request')).toEqual([['INCORRECT_PHONE']])
- }
- })
-
it('handles invalid name requests', async () => {
// mock fetchNameRequest to return invalid NR
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=phone&email=email')
.returns(Promise.resolve({ data: {
applicants: { emailAddress: 'email', phoneNumber: 'phone' }
} }))
@@ -118,7 +84,7 @@ describe('Name Request Mixin', () => {
it('handles invalid name request states', async () => {
// mock fetchNameRequest to return invalid NR state
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=phone&email=email')
.returns(Promise.resolve({ data: {
applicants: { emailAddress: 'email', phoneNumber: 'phone' },
state: 'DRAFT',
@@ -141,7 +107,7 @@ describe('Name Request Mixin', () => {
it('handles conditional state with consent required', async () => {
// mock fetchNameRequest to return invalid NR state
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=phone&email=email')
.returns(Promise.resolve({ data: {
applicants: { emailAddress: 'email', phoneNumber: 'phone' },
state: 'CONDITIONAL',
@@ -165,7 +131,7 @@ describe('Name Request Mixin', () => {
it('handles conditional state with consent received', async () => {
// mock fetchNameRequest to return valid NR state
- get.withArgs('nameRequests/NR 1234567')
+ get.withArgs('nameRequests/NR 1234567/validate?phone=phone&email=email')
.returns(Promise.resolve({ data: {
applicants: { emailAddress: 'email', phoneNumber: 'phone' },
state: 'CONDITIONAL',