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

feat(application-page-title): remove case transformations in browser tab title #3601

Merged
merged 4 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -23,7 +23,7 @@ describe('Channels', () => {
});
cy.title().should(
'eq',
`Store Munich - Template-starter - ${Cypress.env(
`Store Munich - template-starter - ${Cypress.env(
'PROJECT_KEY'
)} - Merchant Center`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ const memoryHistory = (route: string) =>

describe.each`
route | title
${`/my-project-key/dashboard`} | ${`Dashboard - my-project-key - Merchant Center`}
${`/my-project-key/products`} | ${`Products - my-project-key - Merchant Center`}
${`/my-project-key/products/new`} | ${`Products - my-project-key - Merchant Center`}
${`/my-project-key/products/<id>`} | ${`Products - my-project-key - Merchant Center`}
${`/my-project-key/products/<id>/variants`} | ${`Products - my-project-key - Merchant Center`}
${`/my-project-key/products/<id>/variants/<id>`} | ${`Products - my-project-key - Merchant Center`}
${`/my-project-key/products/<id>/variants/<id>/prices`} | ${`Products - my-project-key - Merchant Center`}
${`/my-project-key/orders/<id>`} | ${`Orders - my-project-key - Merchant Center`}
${`/my-project-key/settings/project/international`} | ${`Settings - my-project-key - Merchant Center`}
${`/my-project-key/settings/project/stores`} | ${`Settings - my-project-key - Merchant Center`}
${`/my-project-key/settings/project/stores/<id>`} | ${`Settings - my-project-key - Merchant Center`}
${`/my-project-key/settings/product-types`} | ${`Settings - my-project-key - Merchant Center`}
${`/my-project-key/settings/product-types/<id>`} | ${`Settings - my-project-key - Merchant Center`}
${`/my-project-key/settings/product-types/<id>/attribute-definitions/detail/<id>`} | ${`Settings - my-project-key - Merchant Center`}
${`/account/projects`} | ${`Account - Merchant Center`}
${`/account/organizations`} | ${`Account - Merchant Center`}
${`/account/organizations/<id>/teams`} | ${`Account - Merchant Center`}
${`/account/organizations/<id>/teams/<id>/permissions/<id>`} | ${`Account - Merchant Center`}
${`/account/organizations/<id>/custom-applications`} | ${`Account - Merchant Center`}
${`/account/organizations/<id>/custom-applications/owned/<id>`} | ${`Account - Merchant Center`}
${`/account/organizations/<id>/custom-applications/installations/<id>`} | ${`Account - Merchant Center`}
${`/login`} | ${`Login - Merchant Center`}
${`/login/new`} | ${`Login - Merchant Center`}
${`/login/sso`} | ${`Login - Merchant Center`}
${`/login/forgot`} | ${`Login - Merchant Center`}
${`/login/choose`} | ${`Login - Merchant Center`}
${`/my-project-key/dashboard`} | ${`dashboard - my-project-key - Merchant Center`}
${`/my-project-key/products`} | ${`products - my-project-key - Merchant Center`}
${`/my-project-key/products/new`} | ${`products - my-project-key - Merchant Center`}
${`/my-project-key/products/<id>`} | ${`products - my-project-key - Merchant Center`}
${`/my-project-key/products/<id>/variants`} | ${`products - my-project-key - Merchant Center`}
${`/my-project-key/products/<id>/variants/<id>`} | ${`products - my-project-key - Merchant Center`}
${`/my-project-key/products/<id>/variants/<id>/prices`} | ${`products - my-project-key - Merchant Center`}
${`/my-project-key/orders/<id>`} | ${`orders - my-project-key - Merchant Center`}
${`/my-project-key/settings/project/international`} | ${`settings - my-project-key - Merchant Center`}
${`/my-project-key/settings/project/stores`} | ${`settings - my-project-key - Merchant Center`}
${`/my-project-key/settings/project/stores/<id>`} | ${`settings - my-project-key - Merchant Center`}
${`/my-project-key/settings/product-types`} | ${`settings - my-project-key - Merchant Center`}
${`/my-project-key/settings/product-types/<id>`} | ${`settings - my-project-key - Merchant Center`}
${`/my-project-key/settings/product-types/<id>/attribute-definitions/detail/<id>`} | ${`settings - my-project-key - Merchant Center`}
${`/account/projects`} | ${`account - Merchant Center`}
${`/account/organizations`} | ${`account - Merchant Center`}
${`/account/organizations/<id>/teams`} | ${`account - Merchant Center`}
${`/account/organizations/<id>/teams/<id>/permissions/<id>`} | ${`account - Merchant Center`}
${`/account/organizations/<id>/custom-applications`} | ${`account - Merchant Center`}
${`/account/organizations/<id>/custom-applications/owned/<id>`} | ${`account - Merchant Center`}
${`/account/organizations/<id>/custom-applications/installations/<id>`} | ${`account - Merchant Center`}
${`/login`} | ${`login - Merchant Center`}
${`/login/new`} | ${`login - Merchant Center`}
${`/login/sso`} | ${`login - Merchant Center`}
${`/login/forgot`} | ${`login - Merchant Center`}
${`/login/choose`} | ${`login - Merchant Center`}
`(`when location is "$route"`, ({ route, title }) => {
it('should render default page title', async () => {
render(
Expand All @@ -50,10 +50,10 @@ describe.each`

describe.each`
content | title
${[`Short title`]} | ${`Short title - Products - my-project-key - Merchant Center`}
${[`Long title, a very long product name`]} | ${`Long title, ...product name - Products - my-project-key - Merchant Center`}
${['Short title1', 'Short title2']} | ${`Short title1 - Short title2 - Products - my-project-key - Merchant Center`}
${['First title of product, a very long product name', 'Second title of product, a very long product name']} | ${`First title ...product name - Second title...product name - Products - my-project-key - Merchant Center`}
${[`Short title`]} | ${`Short title - products - my-project-key - Merchant Center`}
${[`Long title, a very long product name`]} | ${`Long title, ...product name - products - my-project-key - Merchant Center`}
${['Short title1', 'Short title2']} | ${`Short title1 - Short title2 - products - my-project-key - Merchant Center`}
${['First title of product, a very long product name', 'Second title of product, a very long product name']} | ${`First title ...product name - Second title...product name - products - my-project-key - Merchant Center`}
`(`'when the custom "content" is "$content"`, ({ content, title }) => {
it('should render the custom value', async () => {
render(
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('when page title component content is nested in another component', ()
);
await waitFor(() => {
expect(document.title).toBe(
'Level 3 with...product name - Products - my-project-key - Merchant Center'
'Level 3 with...product name - products - my-project-key - Merchant Center'
);
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useLayoutEffect } from 'react';
import upperFirst from 'lodash/upperFirst';
import { useLocation } from 'react-router-dom';

type TApplicationPageTitleProps = {
Expand Down Expand Up @@ -45,14 +44,14 @@ const getPageTitle = (pathname: string, additionalParts: string[]) => {
if (staticPaths.includes(projectKeyOrStaticPath)) {
return [
...(customTitleParts || []),
upperFirst(projectKeyOrStaticPath),
projectKeyOrStaticPath,
'Merchant Center',
].join(' - ');
}

return [
...(customTitleParts || []),
upperFirst(entryPointUriPath),
entryPointUriPath,
projectKeyOrStaticPath,
'Merchant Center',
].join(' - ');
Expand Down