Skip to content

Commit

Permalink
fix(fe: FSADT1-1511): Clear business information when a new Client na…
Browse files Browse the repository at this point in the history
…me gets selected (#1176)

fix: clear business information when a new client name gets selected
  • Loading branch information
fterra-encora authored Sep 25, 2024
1 parent 920fca7 commit 1a3117e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,57 @@ describe("BC Registered Staff Wizard Step", () => {
});
});

// See FSADT1-1511 (https://apps.nrs.gov.bc.ca/int/jira/browse/FSADT1-1511)
describe("when the selected Client name is replaced from a Sole proprietorship to something else", () => {
it("clears the Doing Business As field", () => {
loginAndNavigateToStaffForm();

cy.get("cds-inline-notification#bcRegistrySearchNotification").should(
"exist"
);

const sppSearch = "spp";
const sppCode = "FM123123";

interceptClientsApi(sppSearch, sppCode);

cy.selectAutocompleteEntry(
"#businessName",
sppSearch,
sppCode,
`@clientSearch${sppSearch}`
);

cy.get(`.read-only-box > #legalType`)
.should("exist")
.and("contains.text", "Sole Proprietorship");

cy.clearFormEntry("#businessName");

const cmpSearch = "cmp";
const cmpCode = "C1231231";

interceptClientsApi(cmpSearch, cmpCode);

cy.selectAutocompleteEntry(
"#businessName",
cmpSearch,
cmpCode,
`@clientSearch${cmpSearch}`
);

cy.get(`.read-only-box > #legalType`)
.should("exist")
.and("contains.text", "Continued In Corporation");

/*
Doing Business As is cleared, instead of holding the name of the previously selected Sole
proprietorship.
*/
cy.get("#doingBusinessAs").should("exist").and("have.value", "");
});
});

const loginAndNavigateToStaffForm = () => {
cy.visit("/");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
type FormDataDto,
type ForestClientDetailsDto,
indexedEmptyAddress,
indexedEmptyContact
indexedEmptyContact,
newFormDataDto,
} from "@/dto/ApplyClientNumberDto";
import { getEnumKeyByEnumValue } from "@/services/ForestClientService";
import { BusinessTypeEnum } from "@/dto/CommonTypesDto";
Expand Down Expand Up @@ -117,6 +118,12 @@ watch([autoCompleteResult], () => {
bcRegistryError.value = false;
showOnError.value = false;
// reset businessInformation
Object.assign(formData.value.businessInformation, {
...newFormDataDto().businessInformation,
businessName: formData.value.businessInformation.businessName,
});
if (autoCompleteResult.value && autoCompleteResult.value.code) {
formData.value.businessInformation.registrationNumber = autoCompleteResult.value.code;
formData.value.businessInformation.legalType = autoCompleteResult.value.legalType;
Expand Down

0 comments on commit 1a3117e

Please sign in to comment.