From 8ba30db4179e9fbe73e2d718012c09f866436f78 Mon Sep 17 00:00:00 2001 From: Eric Sizer Date: Fri, 6 Sep 2024 12:53:29 -0400 Subject: [PATCH] [Copy] Update work preferences copy (#11444) * update labels, move current location * update localized constants * merge work location with preferences * fix format for display * update file work preferences * update order of application csv * add current location heading * add operational requirment translations * fix profile e2e spec * add icon aria labels * format common messages * fix profile workflows spec * reorder city/region * fix icon alignment * add translations * update to use second person for form --- .../Generators/ApplicationDocGenerator.php | 1 - .../Generators/PoolCandidateCsvGenerator.php | 8 +- api/app/Generators/UserCsvGenerator.php | 8 +- api/app/Traits/Generator/GeneratesUserDoc.php | 28 +-- api/lang/en/headings.php | 6 +- api/lang/fr/headings.php | 4 +- .../tests/applicant/profile-workflows.spec.ts | 6 +- .../PersonalInformation/Display.tsx | 26 -- .../PersonalInformation/FormFields.tsx | 34 --- .../components/PersonalInformation/types.ts | 3 - .../components/PersonalInformation/utils.ts | 12 - .../components/WorkPreferences/Display.tsx | 61 ++--- .../components/WorkPreferences/FormFields.tsx | 152 ++++++++---- .../WorkPreferences/WorkPreferences.tsx | 17 +- .../components/WorkPreferences/types.ts | 4 + .../components/WorkPreferences/utils.ts | 38 ++- .../ProfileSections/WorkLocationSection.tsx | 70 ------ .../WorkPreferencesSection.tsx | 234 ++++++++---------- .../components/UserProfile/UserProfile.tsx | 18 +- .../web/src/constants/sections/userProfile.ts | 1 - apps/web/src/lang/fr.json | 96 +++---- apps/web/src/messages/profileMessages.ts | 29 +++ .../profileStep/profileStepValidation.tsx | 4 - .../ApplicationInformation.tsx | 3 +- .../ProfileAndApplicationsHeading.tsx | 2 - apps/web/src/utils/userUtils.ts | 25 +- apps/web/src/validators/profile/about.ts | 10 - apps/web/src/validators/profile/index.ts | 6 - .../src/validators/profile/workLocation.ts | 20 -- .../src/validators/profile/workPreferences.ts | 31 ++- packages/i18n/src/lang/fr.json | 120 ++++----- packages/i18n/src/messages/commonMessages.ts | 10 + .../i18n/src/messages/localizedConstants.tsx | 80 +++--- 33 files changed, 531 insertions(+), 636 deletions(-) delete mode 100644 apps/web/src/components/UserProfile/ProfileSections/WorkLocationSection.tsx delete mode 100644 apps/web/src/validators/profile/workLocation.ts diff --git a/api/app/Generators/ApplicationDocGenerator.php b/api/app/Generators/ApplicationDocGenerator.php index d928254cc5d..cd9ca5d944b 100644 --- a/api/app/Generators/ApplicationDocGenerator.php +++ b/api/app/Generators/ApplicationDocGenerator.php @@ -93,7 +93,6 @@ public function generate(): self $this->status($section, $user); $this->languageInfo($section, $user); $this->governmentInfo($section, $user); - $this->workLocation($section, $user); $this->workPreferences($section, $user); $this->dei($section, $user); diff --git a/api/app/Generators/PoolCandidateCsvGenerator.php b/api/app/Generators/PoolCandidateCsvGenerator.php index 1405a8adeea..e0ec781c46d 100644 --- a/api/app/Generators/PoolCandidateCsvGenerator.php +++ b/api/app/Generators/PoolCandidateCsvGenerator.php @@ -72,10 +72,10 @@ class PoolCandidateCsvGenerator extends CsvGenerator implements FileGeneratorInt 'current_classification', 'priority_entitlement', 'priority_number', - 'location_preferences', - 'location_exemptions', 'accept_temporary', 'accepted_operational_requirements', + 'location_preferences', + 'location_exemptions', 'woman', 'indigenous', 'visible_minority', @@ -143,10 +143,10 @@ public function generate(): self $candidate->user->getClassification(), // Current classification $this->yesOrNo($candidate->user->has_priority_entitlement), // Priority entitlement $candidate->user->priority_number ?? '', // Priority number - $this->localizeEnumArray($candidate->user->location_preferences, WorkRegion::class), - $candidate->user->location_exemptions, // Location exemptions $candidate->user->position_duration ? $this->yesOrNo($candidate->user->wouldAcceptTemporary()) : '', // Accept temporary $this->localizeEnumArray($preferences['accepted'], OperationalRequirement::class), + $this->localizeEnumArray($candidate->user->location_preferences, WorkRegion::class), + $candidate->user->location_exemptions, // Location exemptions $this->yesOrNo($candidate->user->is_woman), // Woman $this->localizeEnumArray($candidate->user->indigenous_communities, IndigenousCommunity::class), $this->yesOrNo($candidate->user->is_visible_minority), // Visible minority diff --git a/api/app/Generators/UserCsvGenerator.php b/api/app/Generators/UserCsvGenerator.php index ddb797d2762..1e94aef512b 100644 --- a/api/app/Generators/UserCsvGenerator.php +++ b/api/app/Generators/UserCsvGenerator.php @@ -47,10 +47,10 @@ class UserCsvGenerator extends CsvGenerator implements FileGeneratorInterface 'current_classification', 'priority_entitlement', 'priority_number', - 'location_preferences', - 'location_exemptions', 'accept_temporary', 'accepted_operational_requirements', + 'location_preferences', + 'location_exemptions', 'woman', 'indigenous', 'visible_minority', @@ -107,10 +107,10 @@ public function generate(): self $user->getClassification(), // Current classification $this->yesOrNo($user->has_priority_entitlement), // Priority entitlement $user->priority_number ?? '', // Priority number - $this->localizeEnumArray($user->location_preferences, WorkRegion::class), - $user->location_exemptions, // Location exemptions $user->position_duration ? $this->yesOrNo($user->wouldAcceptTemporary()) : '', // Accept temporary $this->localizeEnumArray($preferences['accepted'], OperationalRequirement::class), + $this->localizeEnumArray($user->location_preferences, WorkRegion::class), + $user->location_exemptions, // Location exemptions $this->yesOrNo($user->is_woman), // Woman $this->localizeEnumArray($indigenousCommunities, IndigenousCommunity::class), $this->yesOrNo($user->is_visible_minority), // Visible minority diff --git a/api/app/Traits/Generator/GeneratesUserDoc.php b/api/app/Traits/Generator/GeneratesUserDoc.php index 252a0e8a15d..5418ab7814d 100644 --- a/api/app/Traits/Generator/GeneratesUserDoc.php +++ b/api/app/Traits/Generator/GeneratesUserDoc.php @@ -57,7 +57,6 @@ protected function contactInfo(Section $section, User $user, $headingRank = 3) $section->addTitle($this->localizeHeading('contact_info'), $headingRank); $this->addLabelText($section, $this->localizeHeading('email'), $user->email); $this->addLabelText($section, $this->localizeHeading('phone'), $user->telephone); - $this->addLabelText($section, $this->localizeHeading('current_city'), $this->currentLocation($user)); $this->addLabelText($section, $this->localizeHeading('preferred_communication_language'), $this->localizeEnum($user->preferred_lang, Language::class)); $this->addLabelText($section, $this->localizeHeading('preferred_spoken_interview_language'), $this->localizeEnum($user->preferred_language_for_interview, Language::class)); $this->addLabelText($section, $this->localizeHeading('preferred_written_exam_language'), $this->localizeEnum($user->preferred_language_for_exam, Language::class)); @@ -161,19 +160,6 @@ protected function governmentInfo(Section $section, User $user, $headingRank = 4 } } - /** - * Generate information about a users work location - * - * @param Section $section The section to add info to - * @param User $user The user being generated - */ - protected function workLocation(Section $section, User $user, $headingRank = 4) - { - $section->addTitle($this->localizeHeading('work_location'), $headingRank); - $this->addLabelText($section, $this->localizeHeading('work_location'), $this->localizeEnumArray($user->location_preferences, WorkRegion::class)); - $this->addLabelText($section, $this->localizeHeading('location_exemptions'), $user->location_exemptions ?? ''); - } - /** * Generate information about a users work preferences * @@ -183,6 +169,8 @@ protected function workLocation(Section $section, User $user, $headingRank = 4) protected function workPreferences(Section $section, User $user, $headingRank = 4) { $section->addTitle($this->localizeHeading('work_preferences'), $headingRank); + + $section->addText($this->localizeHeading('contract_duration'), $this->strong); foreach ($user?->position_duration ?? [] as $duration) { $section->addListItem($this->localizeEnum($duration, PositionDuration::class)); } @@ -196,13 +184,12 @@ protected function workPreferences(Section $section, User $user, $headingRank = } } - if (count($preferences['not_accepted']) > 0) { - $section->addText($this->localizeHeading('rejected_operational_requirements'), $this->strong); + $section->addText($this->localizeHeading('current_location'), $this->strong); + $this->addLabelText($section, $this->localizeHeading('current_city'), $this->currentLocation($user)); - foreach ($preferences['not_accepted'] as $preference) { - $section->addListItem($this->localizeEnum($preference, OperationalRequirement::class, 'long')); - } - } + $section->addText($this->localizeHeading('location_preferences'), $this->strong); + $this->addLabelText($section, $this->localizeHeading('work_location'), $this->localizeEnumArray($user->location_preferences, WorkRegion::class)); + $this->addLabelText($section, $this->localizeHeading('location_exemptions'), $user->location_exemptions ?? ''); } /** @@ -374,7 +361,6 @@ protected function generateUser(Section $section, User $user, $headingRank = 2) $this->status($section, $user, $headingRank + 2); $this->languageInfo($section, $user, $headingRank + 2); $this->governmentInfo($section, $user, $headingRank + 2); - $this->workLocation($section, $user, $headingRank + 2); $this->workPreferences($section, $user, $headingRank + 2); $this->dei($section, $user, $headingRank + 2); diff --git a/api/lang/en/headings.php b/api/lang/en/headings.php index fd2aec2e61f..59f1a8f7a98 100644 --- a/api/lang/en/headings.php +++ b/api/lang/en/headings.php @@ -9,6 +9,7 @@ 'notes' => 'Notes', 'current_province' => 'Province', 'current_city' => 'City', + 'current_location' => 'Current location', 'date_received' => 'Date received', 'expiry_date' => 'Expiry date', 'archival_date' => 'Archival date', @@ -36,10 +37,11 @@ 'priority_entitlement' => 'Priority entitlement', 'priority_number' => 'Priority number', 'work_location' => 'Work location', - 'location_preferences' => 'Location preferences', + 'location_preferences' => 'Work location preferences', 'location_exemptions' => 'Location exemptions', + 'contract_duration' => 'Contract duration preference', 'accept_temporary' => 'Accept temporary', - 'accepted_operational_requirements' => 'Would consider accepting a job that: ', + 'accepted_operational_requirements' => 'Acceptable job requirements', 'rejected_operational_requirements' => 'Would not consider a job that requires: ', 'woman' => 'Woman', 'indigenous' => 'Indigenous', diff --git a/api/lang/fr/headings.php b/api/lang/fr/headings.php index c5e8b183657..12d1f785b65 100644 --- a/api/lang/fr/headings.php +++ b/api/lang/fr/headings.php @@ -9,6 +9,7 @@ 'notes' => 'Notes', 'current_province' => 'Province actuelle', 'current_city' => 'Ville', + 'current_location' => 'Emplacement actuel', 'date_received' => 'Date de réception', 'expiry_date' => 'Date d\'expiration', 'archival_date' => 'Date d\'archivage', @@ -36,8 +37,9 @@ 'priority_entitlement' => 'Droit de priorité', 'priority_number' => 'Numéro de priorité', 'work_location' => 'Lieu de travail', - 'location_preferences' => 'Préférences de lieux', + 'location_preferences' => 'Préférences pour le lieu de travail', 'location_exemptions' => 'Exemptions de lieux', + 'contract_duration' => 'Préférence pour la durée du contrat', 'accept_temporary' => 'Accepter les temporaires', 'accepted_operational_requirements' => 'Envisagerait d\'accepter un emploi qui : ', 'rejected_operational_requirements' => 'N\'envisagerait pas d\'accepter un emploi qui : ', diff --git a/apps/playwright/tests/applicant/profile-workflows.spec.ts b/apps/playwright/tests/applicant/profile-workflows.spec.ts index b5b8bd2cb65..c2b7cac9a14 100644 --- a/apps/playwright/tests/applicant/profile-workflows.spec.ts +++ b/apps/playwright/tests/applicant/profile-workflows.spec.ts @@ -14,8 +14,8 @@ test.describe("User Profile", () => { "PersonalInformationFormOptions", ); await applicantPage.page - .getByRole("textbox", { name: /current city/i }) - .fill("Test city"); + .getByRole("textbox", { name: /telephone/i }) + .fill("123-456-7890"); await applicantPage.page .getByRole("button", { name: /save changes/i }) .click(); @@ -23,7 +23,7 @@ test.describe("User Profile", () => { await expect(applicantPage.page.getByRole("alert").last()).toContainText( /information updated successfully/i, ); - await expect(applicantPage.page.getByText(/test city/i)).toBeVisible(); + await expect(applicantPage.page.getByText("123-456-7890")).toBeVisible(); // Edit work preferences await applicantPage.page diff --git a/apps/web/src/components/Profile/components/PersonalInformation/Display.tsx b/apps/web/src/components/Profile/components/PersonalInformation/Display.tsx index af817dd9755..8fab9565924 100644 --- a/apps/web/src/components/Profile/components/PersonalInformation/Display.tsx +++ b/apps/web/src/components/Profile/components/PersonalInformation/Display.tsx @@ -37,8 +37,6 @@ type PartialUser = Pick< | "preferredLang" | "preferredLanguageForInterview" | "preferredLanguageForExam" - | "currentCity" - | "currentProvince" | "citizenship" | "armedForcesStatus" >; @@ -58,8 +56,6 @@ const Display = ({ preferredLang, preferredLanguageForInterview, preferredLanguageForExam, - currentCity, - currentProvince, citizenship, armedForcesStatus, }, @@ -186,28 +182,6 @@ const Display = ({ notProvided )} - - {currentCity || notProvided} - - - {currentProvince?.label - ? getLocalizedName(currentProvince.label, intl) - : notProvided} - { required: intl.formatMessage(errorMessages.required), }} /> - - - -
- ({ - value, - label: intl.formatMessage( - getOperationalRequirement(value, "firstPerson"), - ), - }))} + -
-
+ + + + {labels.workLocationPreferences} + { required: intl.formatMessage(errorMessages.required), }} /> -
-