Remove compatibility notice from Mini Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/6803)

This commit is contained in:
Tung Du 2022-08-01 23:01:57 +07:00 committed by GitHub
parent 8e2a2636c2
commit 862477f9aa
3 changed files with 1 additions and 63 deletions

View File

@ -4,7 +4,6 @@
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import type { ReactElement } from 'react';
import { formatPrice } from '@woocommerce/price-format';
import { CartCheckoutCompatibilityNotice } from '@woocommerce/editor-components/compatibility-notices';
import { PanelBody, ExternalLink, SelectControl } from '@wordpress/components';
import { getSetting } from '@woocommerce/settings';
import { __ } from '@wordpress/i18n';
@ -108,7 +107,6 @@ const Edit = ( { attributes, setAttributes }: Props ): ReactElement => {
<QuantityBadge count={ productCount } />
</button>
</Noninteractive>
<CartCheckoutCompatibilityNotice blockName="mini-cart" />
</div>
);
};

View File

@ -14,7 +14,7 @@ import { useCompatibilityNotice } from './use-compatibility-notice';
import WooImage from './woo-image';
interface CartCheckoutCompatibilityNoticeProps {
blockName: 'cart' | 'checkout' | 'mini-cart';
blockName: 'cart' | 'checkout';
}
export function CartCheckoutCompatibilityNotice( {

View File

@ -19,7 +19,6 @@ import {
goToSiteEditor,
useTheme,
waitForCanvas,
addBlockToFSEArea,
} from '../../utils.js';
const block = {
@ -30,8 +29,6 @@ const block = {
insertButton: "//button//span[text()='Mini Cart']",
insertButtonDisabled:
"//button[@aria-disabled]//span[text()='Mini Cart']",
compatibilityNoticeTitle:
"//h1[contains(text(), 'Compatibility notice')]",
},
};
@ -40,14 +37,6 @@ if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 3 ) {
test.only( `skipping ${ block.name } tests`, () => {} );
}
const removeDismissedCompatibilityNoticesFromLocalStorage = async () => {
await page.evaluate( () => {
window.localStorage.removeItem(
'wc-blocks_dismissed_compatibility_notices'
);
} );
};
const addBlockToWidgetsArea = async () => {
await closeModalIfExists();
await openWidgetsEditorBlockInserter();
@ -58,10 +47,6 @@ const addBlockToWidgetsArea = async () => {
describe( `${ block.name } Block`, () => {
describe( 'in widget editor', () => {
beforeAll( async () => {
await removeDismissedCompatibilityNoticesFromLocalStorage();
} );
beforeEach( async () => {
await openWidgetEditor();
} );
@ -73,28 +58,6 @@ describe( `${ block.name } Block`, () => {
);
} );
it( 'the compatibility notice appears', async () => {
await addBlockToWidgetsArea();
const compatibilityNoticeTitle = await page.$x(
block.selectors.compatibilityNoticeTitle
);
expect( compatibilityNoticeTitle.length ).toBe( 1 );
} );
it( "after the compatibility notice is dismissed, it doesn't appear again", async () => {
await page.evaluate( () => {
window.localStorage.setItem(
'wc-blocks_dismissed_compatibility_notices',
'["mini-cart"]'
);
} );
await addBlockToWidgetsArea();
const compatibilityNoticeTitle = await page.$x(
block.selectors.compatibilityNoticeTitle
);
expect( compatibilityNoticeTitle.length ).toBe( 0 );
} );
it( 'can only be inserted once', async () => {
await addBlockToWidgetsArea();
const miniCartButton = await page.$x(
@ -113,7 +76,6 @@ describe( `${ block.name } Block`, () => {
await goToSiteEditor(
process.env.GUTENBERG_EDITOR_CONTEXT || 'core'
);
await removeDismissedCompatibilityNoticesFromLocalStorage();
await waitForCanvas();
} );
@ -122,28 +84,6 @@ describe( `${ block.name } Block`, () => {
await expect( canvas() ).toMatchElement( block.class );
} );
it( 'the compatibility notice appears', async () => {
await addBlockToFSEArea( block.name );
const compatibilityNoticeTitle = await page.$x(
block.selectors.compatibilityNoticeTitle
);
expect( compatibilityNoticeTitle.length ).toBe( 1 );
} );
it( "after the compatibility notice is dismissed, it doesn't appear again", async () => {
await page.evaluate( () => {
window.localStorage.setItem(
'wc-blocks_dismissed_compatibility_notices',
'["mini-cart"]'
);
} );
await addBlockToFSEArea( block.name );
const compatibilityNoticeTitle = await page.$x(
block.selectors.compatibilityNoticeTitle
);
expect( compatibilityNoticeTitle.length ).toBe( 0 );
} );
it( 'can only be inserted once', async () => {
await insertBlock( block.name );
await searchForFSEBlock( block.name );