Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fe: FSADT1-1511): Clear business information when a new Client name gets selected #1176

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading