Remove cart2cart option from product task (#37285)

* Remove cart2cart option from add product task

* Remove cart2cart link test

* Add changelog

* Fix unit test

* Fix lint
This commit is contained in:
Chi-Hsuan Huang 2023-03-17 20:15:31 +08:00 committed by GitHub
parent a45b67d390
commit 9ea8b630ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 83 deletions

View File

@ -8,7 +8,9 @@
grid-template-columns: auto auto;
grid-column-gap: 16px;
grid-row-gap: 24px;
justify-content: start;
// Set it to center here since we only have one import option.
// We can change it to start when we have more import options.
justify-content: center;
}
.woocommerce-list__item {

View File

@ -3,10 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import PageIcon from 'gridicons/dist/pages';
import ReblogIcon from 'gridicons/dist/reblog';
import { getAdminLink } from '@woocommerce/settings';
import interpolateComponents from '@automattic/interpolate-components';
import { ExternalLink } from '@wordpress/components';
import { recordEvent } from '@woocommerce/tracks';
export const importTypes = [
@ -25,32 +22,4 @@ export const importTypes = [
);
},
},
{
key: 'from-cart2cart' as const,
title: __( 'FROM CART2CART', 'woocommerce' ),
content: interpolateComponents( {
mixedString: __(
'Migrate all store data like products, customers, and orders in no time with this 3rd party plugin. {{link}}Learn more{{/link}}',
'woocommerce'
),
components: {
link: (
<ExternalLink
href="https://woocommerce.com/products/cart2cart/?utm_medium=product"
onClickCapture={ ( e ) => e.preventDefault() }
></ExternalLink>
),
},
} ),
before: <ReblogIcon />,
onClick: () => {
recordEvent( 'tasklist_add_product', { method: 'migrate' } );
window
.open(
'https://woocommerce.com/products/cart2cart/?utm_medium=product',
'_blank'
)
?.focus();
},
},
];

View File

@ -57,24 +57,6 @@ describe( 'Products', () => {
);
} );
test( 'should fire "tasklist_add_product" event when the cart2cart option clicked', async () => {
const { getByRole } = render( <Products /> );
userEvent.click(
getByRole( 'menuitem', {
name: 'FROM CART2CART Migrate all store data like products, customers, and orders in no time with this 3rd party plugin. Learn more (opens in a new tab)',
} )
);
await waitFor( () =>
expect( recordEvent ).toHaveBeenCalledWith(
'tasklist_add_product',
{
method: 'migrate',
}
)
);
} );
test( 'should fire "task_completion_time" event when an option clicked', async () => {
Object.defineProperty( window, 'performance', {
value: {

View File

@ -4,7 +4,6 @@
import { __ } from '@wordpress/i18n';
import interpolateComponents from '@automattic/interpolate-components';
import { Text } from '@woocommerce/experimental';
import { ExternalLink } from '@wordpress/components';
import { Link } from '@woocommerce/components';
import { getAdminLink } from '@woocommerce/settings';
import { recordEvent } from '@woocommerce/tracks';
@ -25,7 +24,7 @@ const Footer: React.FC = () => {
<Text className="woocommerce-products-footer__import-options">
{ interpolateComponents( {
mixedString: __(
'{{importCSVLink}}Import your products from a CSV file{{/importCSVLink}} or {{_3rdLink}}use a 3rd party migration plugin{{/_3rdLink}}.',
'{{importCSVLink}}Import your products from a CSV file{{/importCSVLink}}.',
'woocommerce'
),
components: {
@ -47,20 +46,6 @@ const Footer: React.FC = () => {
<></>
</Link>
),
_3rdLink: (
<ExternalLink
onClick={ () => {
recordEvent( 'tasklist_add_product', {
method: 'migrate',
} );
recordCompletionTime();
} }
href="https://woocommerce.com/products/cart2cart/?utm_medium=product"
type="external"
>
<></>
</ExternalLink>
),
},
} ) }
</Text>

View File

@ -16,9 +16,9 @@ describe( 'Footer', () => {
beforeEach( () => {
( recordEvent as jest.Mock ).mockClear();
} );
it( 'should render footer with two links', () => {
it( 'should render footer with one links', () => {
const { queryAllByRole } = render( <Footer /> );
expect( queryAllByRole( 'link' ) ).toHaveLength( 2 );
expect( queryAllByRole( 'link' ) ).toHaveLength( 1 );
} );
it( 'clicking on import CSV should fire event tasklist_add_product with method:import and task_completion_time', () => {
@ -35,19 +35,4 @@ describe( 'Footer', () => {
{ task_name: 'products', time: '0-2s' }
);
} );
it( 'clicking on start blank should fire event tasklist_add_product with method:migrate and task_completion_time', () => {
const { getByText } = render( <Footer /> );
userEvent.click( getByText( 'use a 3rd party migration plugin' ) );
expect( recordEvent ).toHaveBeenNthCalledWith(
1,
'tasklist_add_product',
{ method: 'migrate' }
);
expect( recordEvent ).toHaveBeenNthCalledWith(
2,
'task_completion_time',
{ task_name: 'products', time: '0-2s' }
);
} );
} );

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
Remove Cart2Cart option from add product task