diff --git a/src/applications/mhv-landing-page/mocks/api/user/index.js b/src/applications/mhv-landing-page/mocks/api/user/index.js index a238cb1f88b6..c033f23ae841 100644 --- a/src/applications/mhv-landing-page/mocks/api/user/index.js +++ b/src/applications/mhv-landing-page/mocks/api/user/index.js @@ -76,6 +76,8 @@ const generateUser = ({ loa = 3, mhvAccountState = 'OK', vaPatient = true, + firstName = 'Gina', + preferredName = 'Ginny', } = {}) => { return { ...defaultUser, @@ -90,6 +92,8 @@ const generateUser = ({ }, profile: { ...defaultUser.data.attributes.profile, + first_name: firstName, + preferred_Name: preferredName, loa: { current: loa }, sign_in: { service_name: serviceName, @@ -108,6 +112,7 @@ const CSP_IDS = { }; const USER_MOCKS = Object.freeze({ + ALL_CAPS_NAME: generateUser({ firstName: 'KEVIN', preferredName: '' }), UNREGISTERED: generateUser({ vaPatient: false }), UNVERIFIED: generateUser({ loa: 1, vaPatient: false }), LOGIN_GOV_UNVERIFIED: generateUser({ diff --git a/src/applications/mhv-landing-page/selectors/personalInformation.js b/src/applications/mhv-landing-page/selectors/personalInformation.js index 686e8ff276f7..cf95c60fb199 100644 --- a/src/applications/mhv-landing-page/selectors/personalInformation.js +++ b/src/applications/mhv-landing-page/selectors/personalInformation.js @@ -1,7 +1,9 @@ +import { startCase, toLower } from 'lodash'; + export const selectGreetingName = state => { return ( state?.user?.profile?.preferredName || - state?.user?.profile?.userFullName?.first || + startCase(toLower(state?.user?.profile?.userFullName?.first)) || null ); }; diff --git a/src/applications/mhv-landing-page/tests/e2e/personalization/welcome-message.cypress.spec.js b/src/applications/mhv-landing-page/tests/e2e/personalization/welcome-message.cypress.spec.js index 7e21a015e39f..5dbd17488813 100644 --- a/src/applications/mhv-landing-page/tests/e2e/personalization/welcome-message.cypress.spec.js +++ b/src/applications/mhv-landing-page/tests/e2e/personalization/welcome-message.cypress.spec.js @@ -1,17 +1,28 @@ import { appName } from '../../../manifest.json'; import ApiInitializer from '../utilities/ApiInitializer'; import LandingPage from '../pages/LandingPage'; +import { USER_MOCKS } from '../../../mocks/api/user'; describe(`${appName} -- Welcome message`, () => { beforeEach(() => { ApiInitializer.initializeMessageData.withUnreadMessages(); }); - it('personalization enabled', () => { - ApiInitializer.initializeFeatureToggle.withAllFeatures(); - LandingPage.visit(); - cy.findByRole('heading', { level: 2, name: /^Welcome/ }).should.exist; - cy.injectAxeThenAxeCheck(); + context('personalization enabled', () => { + beforeEach(() => { + ApiInitializer.initializeFeatureToggle.withAllFeatures(); + }); + + it('shows the Welcome', () => { + LandingPage.visit(); + cy.findByRole('heading', { level: 2, name: /^Welcome/ }).should.exist; + cy.injectAxeThenAxeCheck(); + }); + + it('should match name capitalization to auth header', () => { + LandingPage.visit({ user: USER_MOCKS.ALL_CAPS_NAME }); + cy.findAllByText('Kevin').should('have.length', 2); + }); }); it('personalization disabled', () => {