Skip to content

Commit

Permalink
Merge pull request #9166 from weseek/imprv/page-title-header-max-width
Browse files Browse the repository at this point in the history
imprv: PageTitleHeader max-width
  • Loading branch information
mergify[bot] authored Sep 24, 2024
2 parents 8db2449 + 80e9fda commit 58c65d2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 36 deletions.
20 changes: 12 additions & 8 deletions apps/app/src/client/components/PageHeader/PageTitleHeader.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import '@testing-library/jest-dom/vitest';

import { faker } from '@faker-js/faker';
import type { IPagePopulatedToShowRevision } from '@growi/core';
import {
fireEvent, render, screen, waitFor,
} from '@testing-library/react';
import { mock } from 'vitest-mock-extended';


import { EditorMode } from '~/stores-universal/ui';

import { PageTitleHeader } from './PageTitleHeader';
Expand All @@ -32,7 +34,7 @@ describe('PageTitleHeader Component with untitled page', () => {
it('should render the textbox correctly', async() => {
// arrange
const currentPage = mock<IPagePopulatedToShowRevision>({
_id: 'dummy-id',
_id: faker.database.mongodbObjectId(),
path: '/path/to/page/Untitled-1',
});

Expand Down Expand Up @@ -63,17 +65,18 @@ describe('PageTitleHeader Component', () => {

it('should render the title correctly', async() => {
// arrange
const pageTitle = faker.lorem.slug();
const currentPage = mock<IPagePopulatedToShowRevision>({
_id: 'dummy-id',
path: '/path/to/page/page-title',
_id: faker.database.mongodbObjectId(),
path: `/path/to/page/${pageTitle}`,
});

// act
render(<PageTitleHeader currentPage={currentPage} />);

// assert
// header should be rendered
const headerElement = screen.getByText('page-title');
const headerElement = screen.getByText(pageTitle);
await waitFor(() => {
expect(headerElement).toBeInTheDocument();
expect(headerElement).not.toHaveClass('invisible');
Expand All @@ -85,15 +88,16 @@ describe('PageTitleHeader Component', () => {

it('should render text input after clicking', async() => {
// arrange
const pageTitle = faker.lorem.slug();
const currentPage = mock<IPagePopulatedToShowRevision>({
_id: 'dummy-id',
path: '/path/to/page/page-title',
_id: faker.database.mongodbObjectId(),
path: `/path/to/page/${pageTitle}`,
});

// act
render(<PageTitleHeader currentPage={currentPage} />);

const headerElement = screen.getByText('page-title');
const headerElement = screen.getByText(pageTitle);
await waitFor(() => expect(headerElement).toBeInTheDocument());

// click
Expand All @@ -103,7 +107,7 @@ describe('PageTitleHeader Component', () => {
const inputElement = screen.getByRole('textbox');
await waitFor(() => {
expect(inputElement).toBeInTheDocument();
expect(inputElement).toHaveValue('page-title');
expect(inputElement).toHaveValue(pageTitle);
expect(headerElement).toHaveClass('invisible');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const PageTitleHeader = (props: Props): JSX.Element => {
${isRenameInputShown ? 'invisible' : ''} text-truncate
${isMovable ? 'border border-2 rounded-2' : ''} ${borderColorClass}
`}
style={{ maxWidth: inputMaxWidth }}
onClick={onClickPageTitle}
>
{pageTitle}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-rulesdir": "^0.2.2",
"eslint-plugin-vitest": "^0.2.3",
"@faker-js/faker": "^9.0.1",
"glob": "^8.1.0",
"mock-require": "^3.0.3",
"nodemon": "^3.1.3",
Expand Down
36 changes: 8 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2079,6 +2079,11 @@
resolved "https://registry.yarnpkg.com/@exodus/schemasafe/-/schemasafe-1.1.1.tgz#006ab8b33b1aec6d2992c75e5918c65197388aa2"
integrity sha512-Pd7+aGvWIaTDL5ecV4ZBEtBrjXnk8/ly5xyHbikxVhgcq7qhihzHWHbcYmFupQBT2A5ggNZGvT7Bpj0M6AKHjA==

"@faker-js/faker@^9.0.1":
version "9.0.1"
resolved "https://registry.yarnpkg.com/@faker-js/faker/-/faker-9.0.1.tgz#5e201ffc4524d00a200c648d2be55be6e25b3c3e"
integrity sha512-4mDeYIgM3By7X6t5E6eYwLAa+2h4DeZDF7thhzIg6XB76jeEvMwadYAMCFJL/R4AnEBcAUO9+gL0vhy3s+qvZA==

"@fastify/busboy@^2.0.0":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d"
Expand Down Expand Up @@ -16996,7 +17001,7 @@ string-template@>=1.0.0:
resolved "https://registry.yarnpkg.com/string-template/-/string-template-1.0.0.tgz#9e9f2233dc00f218718ec379a28a5673ecca8b96"
integrity sha1-np8iM9wA8hhxjsN5oopWc+zKi5Y=

"string-width-cjs@npm:string-width@^4.2.0":
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -17014,15 +17019,6 @@ string-width@=4.2.2:
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.0"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^5.0.1, string-width@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
Expand Down Expand Up @@ -17106,7 +17102,7 @@ stringify-entities@^4.0.0:
character-entities-html4 "^2.0.0"
character-entities-legacy "^3.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -17120,13 +17116,6 @@ strip-ansi@^3.0.0:
dependencies:
ansi-regex "^2.0.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1, strip-ansi@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -18921,7 +18910,7 @@ word-wrap@^1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -18939,15 +18928,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 58c65d2

Please sign in to comment.