Skip to content

Commit

Permalink
Merge branch 'main' into fix/be/FSADT1-1116-1
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj authored Jan 11, 2024
2 parents 9b48778 + b560982 commit 5af4313
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 10 deletions.
12 changes: 12 additions & 0 deletions frontend/cypress/fixtures/business.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,17 @@
"name": "Totally Shady Company",
"status": "ACTIVE",
"legalType": "SP"
},
{
"code":"BC1234567",
"name":"Unsupported Client Type Inc.",
"status":"ACTIVE",
"legalType": "BC"
},
{
"code":"SP1234567",
"name":"Unknown Sole Proprietor Ltd.",
"status":"ACTIVE",
"legalType": "SP"
}
]
1 change: 1 addition & 0 deletions frontend/src/pages/FormBCeIDPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ exitBus.on((event: Record<string, boolean | null>) => {
endAndLogOut.value = event.goodStanding ? event.goodStanding : false;
mailAndLogOut.value = event.duplicated ? event.duplicated : false;
endAndLogOut.value = event.nonPersonSP ? event.nonPersonSP : endAndLogOut.value;
endAndLogOut.value = event.unsupportedClientType || endAndLogOut.value;
});
progressIndicatorBus.on((event: ProgressNotification) => {
Expand Down
56 changes: 47 additions & 9 deletions frontend/src/pages/bceidform/BusinessInformationWizardStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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>();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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>
Expand Down
6 changes: 6 additions & 0 deletions frontend/stub/__files/response-autocomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@
"name":"British Columbia Forest Products",
"status":"ACTIVE",
"legalType": "SP"
},
{
"code":"BC1234567",
"name":"Unsupported Client Type Inc.",
"status":"ACTIVE",
"legalType": "BC"
}
]
44 changes: 44 additions & 0 deletions frontend/stub/mappings/backend.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@
"transformers": ["response-template"]
}
},
{
"name":"BC Registry Details Unsupported Client Type",
"request": {
"url": "/api/clients/BC1234567",
"method": "GET"
},
"response": {
"status": 406,
"body": "Client type BC is not supported at the moment",
"transformers": ["response-template"]
}
},

{
"name":"Country Codes",
Expand Down Expand Up @@ -98,6 +110,38 @@
"bodyFileName": "response-getCountryByCode-{{request.path.[3]}}.json" }
},

{
"name":"Get ClientType by Code",
"request": {
"urlPattern": "/api/clients/getClientTypeByCode/(.*)",
"method": "GET"
},
"response": {
"status": 200,
"transformers": ["response-template"],
"transformerParameters": {
"clientTypeMapping": {
"A": "Association",
"B": "First Nation Band",
"C": "Corporation",
"F": "Ministry of Forests and Range",
"G": "Government",
"I": "Individual",
"L": "Limited Partnership",
"P": "General Partnership",
"R": "First Nation Group",
"S": "Society",
"T": "First Nation Tribal Council",
"U": "Unregistered Company"
}
},
"jsonBody": {
"code": "{{#assign 'code'}}{{request.pathSegments.[3]}}{{/assign}}{{code}}",
"name": "{{lookup parameters.clientTypeMapping code}}"
}
}
},

{
"name":"Submission Success for XX",
"request": {
Expand Down
119 changes: 118 additions & 1 deletion frontend/tests/pages/bceid/BusinessInformationWizardStep.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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");
});
});

0 comments on commit 5af4313

Please sign in to comment.