diff --git a/frontend/cypress/e2e/pages/staffform/BcRegisteredClientInformationWizardStep.cy.ts b/frontend/cypress/e2e/pages/staffform/BcRegisteredClientInformationWizardStep.cy.ts index 4ba419e204..f070fea051 100644 --- a/frontend/cypress/e2e/pages/staffform/BcRegisteredClientInformationWizardStep.cy.ts +++ b/frontend/cypress/e2e/pages/staffform/BcRegisteredClientInformationWizardStep.cy.ts @@ -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("/"); diff --git a/frontend/src/pages/staffform/BcRegisteredClientInformationWizardStep.vue b/frontend/src/pages/staffform/BcRegisteredClientInformationWizardStep.vue index 44db8686f3..2dce84b1f8 100644 --- a/frontend/src/pages/staffform/BcRegisteredClientInformationWizardStep.vue +++ b/frontend/src/pages/staffform/BcRegisteredClientInformationWizardStep.vue @@ -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"; @@ -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;