From 246e8cb64fee5d774345309544486bedaac88c9a Mon Sep 17 00:00:00 2001 From: Fernando Terra Date: Tue, 24 Sep 2024 16:17:52 -0300 Subject: [PATCH] fix: clear business information when a new client name gets selected --- ...egisteredClientInformationWizardStep.cy.ts | 51 +++++++++++++++++++ ...cRegisteredClientInformationWizardStep.vue | 9 +++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/frontend/cypress/e2e/pages/staffform/BcRegisteredClientInformationWizardStep.cy.ts b/frontend/cypress/e2e/pages/staffform/BcRegisteredClientInformationWizardStep.cy.ts index ca8b73c9c3..6c3b2f8cb0 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 04bc3ef6f5..2c6fe4362d 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;