From 8e16ae26d880f6c5f487bc0f3cde8926e1aa5029 Mon Sep 17 00:00:00 2001 From: Sylar Z Date: Tue, 1 Aug 2023 09:54:03 -0700 Subject: [PATCH 1/4] added genderTxtMap to handle diverse and unknown --- .../page/applicationForm/ApplicationForm.js | 10 ++- .../applicationForm/ApplicationForm.test.js | 82 +++++++++++++++++++ 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.js b/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.js index ee011ced..8fb57732 100644 --- a/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.js +++ b/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.js @@ -148,7 +148,13 @@ export default function ApplicationForm({ loader: { width: "100%", textAlign: "center", display: "inline-block" }, content: { display: "none" } }); - + // Create a gender text Map + const genderTxtMap = new Map([ + ["female", "F"], + ["male", "M"], + ["diverse", "X"], + ["unknown", "U"] + ]); const location = useLocation(); const getAge = birthdateString => { @@ -228,7 +234,7 @@ export default function ApplicationForm({ } // Convert gender text - const formatGender = gender === "female" ? "F" : "M"; + const formatGender = genderTxtMap.get(gender.toLowerCase()); const age = getAge(birthdate); diff --git a/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.test.js b/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.test.js index 2c261125..edba8850 100644 --- a/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.test.js +++ b/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.test.js @@ -193,6 +193,88 @@ describe("ApplicationForm Component", () => { expect(asFragment()).toMatchSnapshot(); }); + test("Matches the snapshot with gender being diverse", async () => { + const newApplicant = { + ...applicant, + genderTxt: "Diverse" + }; + + const newPage = { + ...page, + applicant: newApplicant + }; + + const updatePayload = { + userInfo: { + birthdate: "04/04/04", + address: { + street_address: "123 addy", + locality: "local", + region: "British Columbia", + postal_code: "v9n1d4" + }, + gender: "X", + given_name: "given", + given_names: "givens", + family_name: "fam", + identity_assurance_level: 3 + }, + authorities: ["Authorized"] + }; + const token = generateJWTToken(updatePayload); + + mock.onGet(API_REQUEST_JWT).reply(200, token); + + const { asFragment } = render( + + + + ); + + expect(asFragment()).toMatchSnapshot(); + }); + + test("Matches the snapshot with gender being unknown", async () => { + const newApplicant = { + ...applicant, + genderTxt: "Unknown" + }; + + const newPage = { + ...page, + applicant: newApplicant + }; + + const updatePayload = { + userInfo: { + birthdate: "04/04/04", + address: { + street_address: "123 addy", + locality: "local", + region: "British Columbia", + postal_code: "v9n1d4" + }, + gender: "U", + given_name: "given", + given_names: "givens", + family_name: "fam", + identity_assurance_level: 3 + }, + authorities: ["Authorized"] + }; + const token = generateJWTToken(updatePayload); + + mock.onGet(API_REQUEST_JWT).reply(200, token); + + const { asFragment } = render( + + + + ); + + expect(asFragment()).toMatchSnapshot(); + }); + test("Matches the snapshot with valid region/province", async () => { const updatePayload = { userInfo: { From 9a4f6b50029edd555d997d21b901ba68dbac872a Mon Sep 17 00:00:00 2001 From: Sylar Z Date: Tue, 1 Aug 2023 10:05:26 -0700 Subject: [PATCH 2/4] Update ApplicationForm.test.js.snap --- .../ApplicationForm.test.js.snap | 2618 ++++++++++++++++- 1 file changed, 2617 insertions(+), 1 deletion(-) diff --git a/src/ecrc-frontend/src/components/page/applicationForm/__snapshots__/ApplicationForm.test.js.snap b/src/ecrc-frontend/src/components/page/applicationForm/__snapshots__/ApplicationForm.test.js.snap index 53b5436e..9c3db424 100644 --- a/src/ecrc-frontend/src/components/page/applicationForm/__snapshots__/ApplicationForm.test.js.snap +++ b/src/ecrc-frontend/src/components/page/applicationForm/__snapshots__/ApplicationForm.test.js.snap @@ -1308,6 +1308,1314 @@ exports[`ApplicationForm Component Matches the snapshot 1`] = ` `; +exports[`ApplicationForm Component Matches the snapshot with gender being diverse 1`] = ` + +
+
+
+ +
+
+
+

+ Criminal Record Check - Application +

+

+ Complete the application form below to continue. +

+
+
+
+
+
+ Loading... Please Wait +
+
+
+
+ PERSONAL INFORMATION +
+
    +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
+
+
+ + PREVIOUS NAME  + + + - Including birth name, previous name, maiden name, and/or alias + +
+
+
+
    +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
+
+
+ + If you have more than one previous name, please  + + +
+
+
+
+
+
    +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
+
+
+
+
+
+
+
+
+
+
+ Position Information +
+
    +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
+
+
+
+
+
+ + Addresses + +
+
+ + Current Residential Address + +
+
+
    +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
+
+

+ Is your current mailing address the same as your current residential address?  +

+
+ + Yes  + + + +  No  + + +
+
+
+ + Current Mailing Address + +
+
+
+
+
+
+
+
    +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
+
+
+
+
+
+
+
+
+ Entering your mailing address in this application will not update your BC Services Card Address. To update your BC Services Card information you must contact  + + Service BC + + ,  + + ICBC + +  or  + + AddressChangeBC + + . +
+
+ + +
+
+
+
+
+
+
+
+
+

+

+

+
+
+
+ + + +
+
+ Update your BC Services Card Information +
+
+
+

+
+ + If you find an error with your: +
    +
  • + First Name +
  • +
  • + Middle Name +
  • +
  • + Last Name +
  • +
  • + Date Of Birth +
  • +
  • + Sex +
  • +
  • + Current Street Address +
  • +
+ Please visit the + + BC Services Card website + + to change your personal information +
+
+
+
+
+
+
+
+
+
+
+

+

+

+ Collection Notice +

+
+ +
+ The Security Programs Division will collect your personal information for the purpose of fulfilling the criminal record check requirements of the Criminal Records Review Act and in accordance with section 26(c) of the Freedom of Information and Protection of Privacy Act (FoIPPA). Additionally, SPD may collect personal information under section 26(e) of FoIPPA for the purpose of evaluating the Criminal Records Review Program and activities to better serve you. Should you have any questions about the collection, use, or disclosure of your personal information, please contact the Policy Analyst of the Criminal Records Review Program, Security Programs Division via mail to PO Box 9217 Stn Prov Govt Victoria, BC V8W 9J1; email to  + + criminalrecords@gov.bc.ca + +  or by telephone at 1- 855-587-0185 (option 2). +
+
+
+
+
+
+
+
+
+
+
+ +
+
+`; + exports[`ApplicationForm Component Matches the snapshot with gender being female 1`] = `
@@ -1681,7 +2989,1315 @@ exports[`ApplicationForm Component Matches the snapshot with gender being female id="genderTxt" readonly="" type="text" - value="Female" + value="Female" + /> +
+ + + +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • +
  • +
    + + +
    + +
    +
  • + + + + + + +
    +
    +
    +
    +
    + Position Information +
    +
      +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    +
    +
    +
    +
    +
    + + Addresses + +
    +
    + + Current Residential Address + +
    +
    +
      +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    +
    +

    + Is your current mailing address the same as your current residential address?  +

    +
    + + Yes  + + + +  No  + + +
    +
    +
    + + Current Mailing Address + +
    +
    +
    +
    +
    +
    +
    +
      +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    +
    +
    +
    +
    +
    +
    +
    +
    + Entering your mailing address in this application will not update your BC Services Card Address. To update your BC Services Card information you must contact  + + Service BC + + ,  + + ICBC + +  or  + + AddressChangeBC + + . +
    +
    + + +
    + + +
    +
    +
    +
    +
    +
    +

    +

    +

    +
    +
    +
    + + + +
    +
    + Update your BC Services Card Information +
    +
    +
    +

    +
    + + If you find an error with your: +
      +
    • + First Name +
    • +
    • + Middle Name +
    • +
    • + Last Name +
    • +
    • + Date Of Birth +
    • +
    • + Sex +
    • +
    • + Current Street Address +
    • +
    + Please visit the + + BC Services Card website + + to change your personal information +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    +

    +

    + Collection Notice +

    +
    + +
    + The Security Programs Division will collect your personal information for the purpose of fulfilling the criminal record check requirements of the Criminal Records Review Act and in accordance with section 26(c) of the Freedom of Information and Protection of Privacy Act (FoIPPA). Additionally, SPD may collect personal information under section 26(e) of FoIPPA for the purpose of evaluating the Criminal Records Review Program and activities to better serve you. Should you have any questions about the collection, use, or disclosure of your personal information, please contact the Policy Analyst of the Criminal Records Review Program, Security Programs Division via mail to PO Box 9217 Stn Prov Govt Victoria, BC V8W 9J1; email to  + + criminalrecords@gov.bc.ca + +  or by telephone at 1- 855-587-0185 (option 2). +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +`; + +exports[`ApplicationForm Component Matches the snapshot with gender being unknown 1`] = ` + +
    +
    +
    + +
    +
    +
    +

    + Criminal Record Check - Application +

    +

    + Complete the application form below to continue. +

    +
    +
    +
    +
    +
    + Loading... Please Wait +
    +
    +
    +
    + PERSONAL INFORMATION +
    +
      +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    +
    +
    + + PREVIOUS NAME  + + + - Including birth name, previous name, maiden name, and/or alias + +
    +
    +
    +
      +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    +
    +
    + + If you have more than one previous name, please  + + +
    +
    +
    +
    +
    +
      +
    • +
      + + +
      + +
      +
    • +
    • +
      + + +
      + +
      +
    • +
    • +
      + +
      Date: Tue, 1 Aug 2023 10:06:38 -0700 Subject: [PATCH 3/4] Update package.json --- src/ecrc-frontend/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ecrc-frontend/package.json b/src/ecrc-frontend/package.json index 61ea387c..730ce204 100644 --- a/src/ecrc-frontend/package.json +++ b/src/ecrc-frontend/package.json @@ -50,6 +50,7 @@ "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", + "test:update-snapshot": "test -- -u", "test": "jest --env='jsdom'", "eject": "react-scripts eject", "storybook": "start-storybook -p 9009 -s public", From b81225218b7d296e79d9b503045d8a4ca2177076 Mon Sep 17 00:00:00 2001 From: Sylar Z Date: Tue, 1 Aug 2023 10:10:16 -0700 Subject: [PATCH 4/4] diverse is set to U according to the requirement --- src/ecrc-frontend/package.json | 1 - .../src/components/page/applicationForm/ApplicationForm.js | 2 +- .../src/components/page/applicationForm/ApplicationForm.test.js | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ecrc-frontend/package.json b/src/ecrc-frontend/package.json index 730ce204..61ea387c 100644 --- a/src/ecrc-frontend/package.json +++ b/src/ecrc-frontend/package.json @@ -50,7 +50,6 @@ "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", - "test:update-snapshot": "test -- -u", "test": "jest --env='jsdom'", "eject": "react-scripts eject", "storybook": "start-storybook -p 9009 -s public", diff --git a/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.js b/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.js index 8fb57732..6e0b01ff 100644 --- a/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.js +++ b/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.js @@ -152,7 +152,7 @@ export default function ApplicationForm({ const genderTxtMap = new Map([ ["female", "F"], ["male", "M"], - ["diverse", "X"], + ["diverse", "U"], ["unknown", "U"] ]); const location = useLocation(); diff --git a/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.test.js b/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.test.js index edba8850..0042ea93 100644 --- a/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.test.js +++ b/src/ecrc-frontend/src/components/page/applicationForm/ApplicationForm.test.js @@ -213,7 +213,7 @@ describe("ApplicationForm Component", () => { region: "British Columbia", postal_code: "v9n1d4" }, - gender: "X", + gender: "U", given_name: "given", given_names: "givens", family_name: "fam",