-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/be/FSADT1-1116-1
- Loading branch information
Showing
6 changed files
with
228 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import { | |
ClientTypeEnum, | ||
ProgressNotification, | ||
} from "@/dto/CommonTypesDto"; | ||
import { BusinessTypeEnum } from "@/dto/CommonTypesDto"; | ||
import { BusinessTypeEnum, CodeNameType } from "@/dto/CommonTypesDto"; | ||
import type { | ||
FormDataDto, | ||
ForestClientDetailsDto, | ||
|
@@ -96,27 +96,37 @@ const showAutoCompleteInfo = ref<boolean>(false); | |
const showGoodStandingError = ref<boolean>(false); | ||
const showDuplicatedError = ref<boolean>(false); | ||
const showNonPersonSPError = ref<boolean>(false); | ||
const showUnsupportedClientTypeError = ref<boolean>(false); | ||
const showDetailsLoading = ref<boolean>(false); | ||
const detailsData = ref(null); | ||
const toggleErrorMessages = ( | ||
goodStanding: boolean | null = null, | ||
duplicated: boolean | null = null, | ||
nonPersonSP: boolean | null = null | ||
nonPersonSP: boolean | null = null, | ||
unsupportedClientType: boolean | null = null, | ||
) => { | ||
showGoodStandingError.value = goodStanding ?? false; | ||
showDuplicatedError.value = duplicated ?? false; | ||
showNonPersonSPError.value = nonPersonSP ?? false; | ||
showUnsupportedClientTypeError.value = unsupportedClientType ?? false; | ||
if (goodStanding || duplicated || nonPersonSP) { | ||
if (goodStanding || duplicated || nonPersonSP || unsupportedClientType) { | ||
progressIndicatorBus.emit({ kind: "disabled", value: true }); | ||
exitBus.emit({ goodStanding, duplicated, nonPersonSP }); | ||
exitBus.emit({ goodStanding, duplicated, nonPersonSP, unsupportedClientType }); | ||
} else { | ||
progressIndicatorBus.emit({ kind: "disabled", value: false }); | ||
exitBus.emit({ goodStanding: false, duplicated: false, nonPersonSP: false }); | ||
exitBus.emit({ | ||
goodStanding: false, | ||
duplicated: false, | ||
nonPersonSP: false, | ||
unsupportedClientType: false, | ||
}); | ||
} | ||
}; | ||
const receivedClientType = ref<CodeNameType>(); | ||
//Using this as we have to handle the selected result to get | ||
//incorporation number and client type | ||
const autoCompleteResult = ref<BusinessSearchResult>(); | ||
|
@@ -162,6 +172,15 @@ watch([autoCompleteResult], () => { | |
toggleErrorMessages(null, null, true); | ||
return; | ||
} | ||
if (error.value.response?.status === 406) { | ||
toggleErrorMessages(null, null, null, true); | ||
receivedClientType.value = null; | ||
useFetchTo( | ||
`/api/clients/getClientTypeByCode/${formData.value.businessInformation.clientType}`, | ||
receivedClientType, | ||
); | ||
return; | ||
} | ||
if (error.value.response?.status === 404) { | ||
toggleErrorMessages(); | ||
validation.business = true; | ||
|
@@ -282,7 +301,14 @@ const bcRegistryEmail = "[email protected]"; | |
<cds-inline-loading status="active" v-if="showDetailsLoading">Loading client details...</cds-inline-loading> | ||
<div | ||
class="grouping-02" | ||
v-if="(showAutoCompleteInfo && selectedOption === BusinessTypeEnum.R) || showGoodStandingError || showDuplicatedError || showNonPersonSPError"> | ||
v-if=" | ||
(showAutoCompleteInfo && selectedOption === BusinessTypeEnum.R) || | ||
showGoodStandingError || | ||
showDuplicatedError || | ||
showNonPersonSPError || | ||
showUnsupportedClientTypeError | ||
" | ||
> | ||
<cds-inline-notification | ||
v-shadow="2" | ||
v-if="showAutoCompleteInfo && selectedOption === BusinessTypeEnum.R" | ||
|
@@ -360,14 +386,26 @@ const bcRegistryEmail = "[email protected]"; | |
low-contrast="true" | ||
open="true" | ||
kind="error" | ||
title="Sole proprietor not owned by a person" | ||
title="Unknown sole proprietor" | ||
> | ||
<p class="cds--inline-notification-content"> | ||
Looks like “{{ formData.businessInformation.businessName }}” is not | ||
owned by a person. Please select another entry or logout. | ||
We're unable to complete this application because we cannot identify the person who is the sole proprietor. Please email [email protected] for help. | ||
</p> | ||
</cds-inline-notification> | ||
|
||
<cds-inline-notification | ||
v-if="showUnsupportedClientTypeError && receivedClientType" | ||
hide-close-button="true" | ||
low-contrast="true" | ||
open="true" | ||
kind="error" | ||
title="Client type not supported" | ||
> | ||
<p class="cds--inline-notification-content"> | ||
{{ receivedClientType.name }} client type is not supported. Please email | ||
[email protected] for help. | ||
</p> | ||
</cds-inline-notification> | ||
|
||
</div> | ||
</data-fetcher> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,31 @@ import BusinessInformationWizardStep from "@/pages/bceidform/BusinessInformation | |
import type { FormDataDto } from "@/dto/ApplyClientNumberDto"; | ||
|
||
describe('<BusinessInformationWizardStep />', () => { | ||
|
||
|
||
beforeEach(() => { | ||
cy.intercept("/api/clients/name/*", { | ||
fixture: "business.json", | ||
}).as("searchCompany"); | ||
|
||
cy.intercept("GET", "/api/clients/BC1234567", { | ||
statusCode: 406, | ||
body: "Client type BC is not supported at the moment", | ||
}); | ||
|
||
cy.intercept("GET", "/api/clients/SP1234567", { | ||
statusCode: 422, | ||
body: "Unable to process request. This sole proprietor is not owner by a person", | ||
}); | ||
|
||
cy.intercept("GET", "/api/clients/getClientTypeByCode/C", { | ||
statusCode: 200, | ||
body: { | ||
code: "C", | ||
name: "Corporation", | ||
}, | ||
}).as("getClientType"); | ||
}); | ||
|
||
it('renders the BusinessInformationWizardStep component and interacts with elements', () => { | ||
cy.mount(BusinessInformationWizardStep, { | ||
props: { | ||
|
@@ -28,4 +52,97 @@ describe('<BusinessInformationWizardStep />', () => { | |
cy.get('.link-button:visible span').should('exist'); | ||
cy.get('.link-button:visible span').invoke('text').should('not.be.empty'); | ||
}); | ||
|
||
it('shows "Client type not supported"', () => { | ||
cy.mount(BusinessInformationWizardStep, { | ||
props: { | ||
data: { | ||
businessInformation: { | ||
businessType: "", | ||
legalType: "", | ||
clientType: "", | ||
incorporationNumber: "", | ||
businessName: "", | ||
goodStandingInd: "", | ||
birthdate: "", | ||
address: "" | ||
}, | ||
location: { | ||
contacts: [ | ||
{ | ||
email: "[email protected]", | ||
firstName: "John", | ||
}, | ||
], | ||
}, | ||
} as unknown as FormDataDto, | ||
active: false, | ||
}, | ||
}); | ||
|
||
cy.get("#businessTyperbR").click(); | ||
|
||
cy.get("#business") | ||
.should("be.visible") | ||
.shadow() | ||
.find("input") | ||
.should("have.value", "") | ||
.type("Unsupported"); | ||
cy.wait("@searchCompany"); | ||
|
||
cy.get('cds-combo-box-item[data-id="BC1234567"]').click(); | ||
|
||
cy.get("cds-inline-notification") | ||
.shadow() | ||
.contains("Client type not supported") | ||
.should("be.visible"); | ||
|
||
// The name of the client type | ||
cy.contains("cds-inline-notification", "Corporation").should("be.visible"); | ||
}); | ||
|
||
it('shows "Unknown sole proprietor"', () => { | ||
cy.mount(BusinessInformationWizardStep, { | ||
props: { | ||
data: { | ||
businessInformation: { | ||
businessType: "", | ||
legalType: "", | ||
clientType: "", | ||
incorporationNumber: "", | ||
businessName: "", | ||
goodStandingInd: "", | ||
birthdate: "", | ||
address: "" | ||
}, | ||
location: { | ||
contacts: [ | ||
{ | ||
email: "[email protected]", | ||
firstName: "John", | ||
}, | ||
], | ||
}, | ||
} as unknown as FormDataDto, | ||
active: false, | ||
}, | ||
}); | ||
|
||
cy.get("#businessTyperbR").click(); | ||
|
||
cy.get("#business") | ||
.should("be.visible") | ||
.shadow() | ||
.find("input") | ||
.should("have.value", "") | ||
.type("Unknown"); | ||
cy.wait("@searchCompany"); | ||
|
||
cy.get('cds-combo-box-item[data-id="SP1234567"]').click(); | ||
|
||
cy.get("cds-inline-notification") | ||
.shadow() | ||
.contains("Unknown sole proprietor") | ||
.should("be.visible"); | ||
}); | ||
}); |