-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FSADT1-1349): Create client for staff Step 1 - Individuals (#1008)
* feat(FSADT1-1346): add create client to staff dashboard * chore: updating project files * feat(FSADT1-1346): soft-locking feature behind a feature flag * fix(FSADT1-1346): fixing tests with feature flag * add new business fields * add the individual client component * use the individual page component * update client type codes * add Date of birth tooltip * add the person id fields * fix input fields width * prevent horizontal scroll Prevents horizontal scroll when the vertical scrollbar is present, by accounting for its width. * make province names visible when options are expanded * set default issuing province to BC When ID type is CDL. * copy validations from BCeID * fix validators for empty string * add validations * validate id number * fix ID type codes * add type checking to ID type * validate birth certificate * validate passport * validate citizenship card * validate First Nation status ID * update max default size * improve error message * set the business name as the individual's full name * add button Next * fix message to refer to the applicant * add button Cancel * update max length for non-BC DL * add ID Type Other * validate ID type Other * validate Other ID right-hand side * improve validation for ID type Other * prevent bad data hidden when the input mask gets updated * fix interference on Form BCeID validations * remove duplicated code * add selectorErrorMessage * test validators * improve Other validator * improve Other validation * expose validate function * fix idNumber validations Updates some keys and fixes the FNID type. * test StaffFormValidations * move to next step * fix: keep selected client type stored in state * keep the state of local fields * rename the types for virtual fields * fix: button next is not enabled when returning to the first step * fix component rendering For loading the proper validation and mask. * refactor: create virtual fields refs internally * test IndividualClientInformationWizardStep * test: remove only * test businessName * test: add e2e tests * change Canadian DL codes * fix max validator * test: use all input fields in the test * docs: remove misplaced comment * switch to new DTO structure Among other changes, it adds the identification type and province as independent fields. * use firstName and lastName in businessInformation * load external validations to be used as default * rename input fields and variables In conformation to the new DTO structure. * test: validate firstName and lastName * test the step * fix: clear dropdown programmatically * test: fix test * test: add tests --------- Co-authored-by: Paulo Gomes da Cruz Junior <[email protected]>
- Loading branch information
1 parent
9c3c590
commit 8ab7191
Showing
14 changed files
with
1,985 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,4 +99,172 @@ describe("Staff Form", () => { | |
|
||
}); | ||
|
||
describe("when the user clicks the Create client button", () => { | ||
beforeEach(() => { | ||
cy.login("[email protected]", "Uat Test", "idir", { | ||
given_name: "James", | ||
family_name: "Baxter", | ||
"cognito:groups": ["CLIENT_ADMIN"], | ||
}); | ||
|
||
// Check if the Create client button is visible | ||
cy.get('#menu-list-staff-form') | ||
.should('be.visible') | ||
.click(); | ||
}); | ||
|
||
it("should display the Client type input field", () => { | ||
cy.get("#clientType").should("be.visible").and("have.value", ""); | ||
}); | ||
|
||
it("should not display any Client type specific input fields", () => { | ||
cy.get("#firstName").should("not.exist"); | ||
}); | ||
|
||
describe("when option Individual gets selected", () => { | ||
beforeEach(() => { | ||
cy.get("#clientType") | ||
.should("be.visible") | ||
.and("have.value", "") | ||
.find("[part='trigger-button']") | ||
.click(); | ||
|
||
cy.get("#clientType") | ||
.find('cds-combo-box-item[data-id="I"]') | ||
.should("be.visible") | ||
.click() | ||
.and("have.value", "Individual"); | ||
}); | ||
it("should display the Individual information input fields", () => { | ||
cy.contains("h2", "Client information"); | ||
cy.get("#firstName").should("be.visible"); | ||
cy.get("#middleName").should("be.visible"); | ||
cy.get("#lastName").should("be.visible"); | ||
cy.get("#birthdate").should("be.visible"); | ||
cy.get("#identificationType").should("be.visible"); | ||
cy.get("#clientIdentification").should("be.visible"); | ||
}); | ||
|
||
describe("when all the required information is filled in", () => { | ||
const baseData = { | ||
firstName: "John", | ||
middleName: "Michael", | ||
lastName: "Silver", | ||
birthdateYear: "2001", | ||
birthdateMonth: "05", | ||
birthdateDay: "30", | ||
identificationTypeValue: "Canadian passport", | ||
identificationProvinceValue: undefined, | ||
clientIdentification: "AB345678", | ||
}; | ||
const scenarios = [ | ||
{ | ||
name: "and the selected ID type doesn't require Issuing province", | ||
data: { | ||
...baseData, | ||
}, | ||
}, | ||
{ | ||
name: "and the selected ID type requires Issuing province", | ||
data: { | ||
...baseData, | ||
identificationTypeValue: "Canadian driver's licence", | ||
identificationProvinceValue: "Nova Scotia", | ||
}, | ||
}, | ||
]; | ||
scenarios.forEach(({ name, data }) => { | ||
describe(name, () => { | ||
beforeEach(() => { | ||
cy.get("#firstName").shadow().find("input").type(data.firstName); | ||
|
||
cy.get("#middleName").shadow().find("input").type(data.middleName); | ||
|
||
cy.get("#lastName").shadow().find("input").type(data.lastName); | ||
|
||
cy.get("#birthdateYear").shadow().find("input").type(data.birthdateYear); | ||
cy.get("#birthdateMonth").shadow().find("input").type(data.birthdateMonth); | ||
cy.get("#birthdateDay").shadow().find("input").type(data.birthdateDay); | ||
|
||
cy.get("#identificationType").find("[part='trigger-button']").click(); | ||
cy.get("#identificationType") | ||
.find(`cds-combo-box-item[data-value="${data.identificationTypeValue}"]`) | ||
.click(); | ||
|
||
if (data.identificationProvinceValue) { | ||
cy.get("#identificationProvince").find("[part='trigger-button']").click(); | ||
cy.get("#identificationProvince") | ||
.find(`cds-combo-box-item[data-value="${data.identificationProvinceValue}"]`) | ||
.click(); | ||
} | ||
|
||
cy.get("#clientIdentification") | ||
.shadow() | ||
.find("input") | ||
.type(data.clientIdentification); | ||
|
||
cy.get("#clientIdentification").shadow().find("input").blur(); | ||
}); | ||
it("enables the button Next", () => { | ||
cy.get("[data-test='wizard-next-button']") | ||
.shadow() | ||
.find("button") | ||
.should("be.enabled"); | ||
}); | ||
|
||
describe("and the button Next is clicked", () => { | ||
beforeEach(() => { | ||
cy.get("[data-test='wizard-next-button']").click(); | ||
}); | ||
it("hides the Client information section", () => { | ||
cy.contains("h2", "Client information").should("not.exist"); | ||
}); | ||
describe("and the button Back is clicked", () => { | ||
beforeEach(() => { | ||
cy.get("[data-test='wizard-back-button']").click(); | ||
}); | ||
it("renders the Individual input fields with the same data", () => { | ||
cy.get("#firstName").shadow().find("input").should("have.value", data.firstName); | ||
|
||
cy.get("#middleName") | ||
.shadow() | ||
.find("input") | ||
.should("have.value", data.middleName); | ||
|
||
cy.get("#lastName").shadow().find("input").should("have.value", data.lastName); | ||
|
||
cy.get("#birthdateYear") | ||
.shadow() | ||
.find("input") | ||
.should("have.value", data.birthdateYear); | ||
cy.get("#birthdateMonth") | ||
.shadow() | ||
.find("input") | ||
.should("have.value", data.birthdateMonth); | ||
cy.get("#birthdateDay") | ||
.shadow() | ||
.find("input") | ||
.should("have.value", data.birthdateDay); | ||
|
||
cy.get("#identificationType").should("have.value", data.identificationTypeValue); | ||
|
||
if (data.identificationProvinceValue) { | ||
cy.get("#identificationProvince").should( | ||
"have.value", | ||
data.identificationProvinceValue, | ||
); | ||
} | ||
|
||
cy.get("#clientIdentification") | ||
.shadow() | ||
.find("input") | ||
.should("have.value", data.clientIdentification); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.