Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/components/content-tab-settings.tsx

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove no longer used imports - Icon, file, getIpcApi, and Button.

Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ export function ContentTabSettings( { selectedSite }: ContentTabSettingsProps )
</CopyTextButton>
</SettingsRow>
<SettingsRow label={ __( 'Local path' ) }>
<Button
aria-label={ `${ selectedSite.path }, ${ __( 'Open local path' ) }` }
className="flex text-wrap items-center gap-1.5 [&.is-link]:text-black [&.is-link]:hover:text-[#2145e6]"
onClick={ () => getIpcApi().openLocalPath( selectedSite.path ) }
variant="link"
>
<span className="line-clamp-1 break-all">{ selectedSite.path }</span>
<Icon size={ 13 } icon={ file } className="shrink-0" />
</Button>
<div className="flex">
<CopyTextButton
text={ selectedSite.path }
label={ __( 'Copy local path to clipboard' ) }
copyConfirmation={ __( 'Copied!' ) }
>
<span className="line-clamp-1 break-all">{ selectedSite.path }</span>
</CopyTextButton>
</div>
</SettingsRow>
<SettingsRow label={ __( 'WP Version' ) }>{ wpVersion }</SettingsRow>
<SettingsRow label={ __( 'PHP Version' ) }>
Expand Down
15 changes: 7 additions & 8 deletions src/components/tests/content-tab-settings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ describe( 'ContentTabSettings', () => {
expect(
screen.getByRole( 'button', { name: 'localhost:8881, Copy site url to clipboard' } )
).toHaveTextContent( 'localhost:8881' );
expect(
screen.getByRole( 'button', { name: '/path/to/site, Open local path' } )
).toBeVisible();
expect( screen.getByRole( 'button', { name: 'Copy local path to clipboard' } ) ).toBeVisible();
expect( screen.getByText( '7.7.7' ) ).toBeVisible();
expect(
screen.getByRole( 'button', {
Expand All @@ -68,14 +66,15 @@ describe( 'ContentTabSettings', () => {
).toHaveTextContent( 'localhost:8881/wp-admin' );
} );

test( 'button opens local path', async () => {
test( 'allows copying the site path', async () => {
const user = userEvent.setup();
render( <ContentTabSettings selectedSite={ selectedSite } /> );

const pathButton = screen.getByRole( 'button', { name: '/path/to/site, Open local path' } );
expect( pathButton ).toBeVisible();
await user.click( pathButton );
expect( openLocalPath ).toHaveBeenCalledWith( '/path/to/site' );
const localPathButton = screen.getByRole( 'button', { name: 'Copy local path to clipboard' } );
expect( localPathButton ).toBeVisible();
await user.click( localPathButton );
expect( copyText ).toHaveBeenCalledTimes( 1 );
expect( copyText ).toHaveBeenCalledWith( '/path/to/site' );
} );

test( 'URL buttons work well when site is running', async () => {
Expand Down