Remove workarounds for site-editing-templates tests woocommerce/woocommerce-blocks#7151 (https://github.com/woocommerce/woocommerce-blocks/pull/7568)
* Remove workaround for site-editing-templates tests woocommerce/woocommerce-blocks#7151 remove workaround for site-editing-templates tests * bot: update checkstyle.xml Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
7758ee05fe
commit
58f3217690
|
@ -2,9 +2,8 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import path from 'path';
|
||||
import { setup as setupPuppeteer } from 'jest-environment-puppeteer';
|
||||
const { truncateSync, existsSync, unlinkSync } = require( 'fs' );
|
||||
const { truncateSync, existsSync } = require( 'fs' );
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
@ -24,22 +23,8 @@ import {
|
|||
disableAttributeLookup,
|
||||
} from '../fixtures/fixture-loaders';
|
||||
import { PERFORMANCE_REPORT_FILENAME } from '../../utils/constants';
|
||||
import { GUTENBERG_EDITOR_CONTEXT } from '../utils';
|
||||
|
||||
module.exports = async ( globalConfig ) => {
|
||||
/**
|
||||
* We have to remove snapshots to avoid "obsolete snapshot" errors.
|
||||
*
|
||||
* @todo Remove this logic when WordPress 6.1 is released.
|
||||
*/
|
||||
if ( GUTENBERG_EDITOR_CONTEXT !== 'core' ) {
|
||||
unlinkSync(
|
||||
path.join(
|
||||
__dirname,
|
||||
'../specs/backend/__snapshots__/site-editing-templates.test.js.snap'
|
||||
)
|
||||
);
|
||||
}
|
||||
// we need to load puppeteer global setup here.
|
||||
await setupPuppeteer( globalConfig );
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import {
|
|||
getAllTemplates,
|
||||
goToTemplateEditor,
|
||||
goToTemplatesList,
|
||||
GUTENBERG_EDITOR_CONTEXT,
|
||||
saveTemplate,
|
||||
useTheme,
|
||||
} from '../../utils';
|
||||
|
@ -131,21 +130,6 @@ const CUSTOMIZED_STRING = 'My awesome customization';
|
|||
const WOOCOMMERCE_ID = 'woocommerce/woocommerce';
|
||||
const WOOCOMMERCE_PARSED_ID = 'WooCommerce';
|
||||
|
||||
/**
|
||||
* This is a workaround to avoid the E2E test suite failing when the test site has Gutenberg enabled.
|
||||
* The problem is that the current version of Gutenberg in WordPress Core and the version of the plugin Gutenberg generate different snapshots.
|
||||
* It is not easy having different snapshots for the same test: theoretically, we should have a dedicated snapshot when Gutenberg is enabled and another one when Gutenberg is disabled.
|
||||
* We can remove this workaround when WordPress 6.1 is released.
|
||||
*
|
||||
* @todo Remove runOnlyWhenGutenbergIsDisabled function and relative workarounds when WordPress 6.1 is released.
|
||||
*/
|
||||
|
||||
const runOnlyWhenGutenbergIsDisabled = ( fn ) => {
|
||||
if ( GUTENBERG_EDITOR_CONTEXT === 'core' ) {
|
||||
fn();
|
||||
}
|
||||
};
|
||||
|
||||
describe.skip( 'Store Editing Templates', () => {
|
||||
useTheme( 'emptytheme' );
|
||||
|
||||
|
@ -175,26 +159,23 @@ describe.skip( 'Store Editing Templates', () => {
|
|||
}
|
||||
} );
|
||||
|
||||
runOnlyWhenGutenbergIsDisabled( () =>
|
||||
it( 'should contain the "WooCommerce Single Product Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//single-product',
|
||||
} );
|
||||
it( 'should contain the "WooCommerce Single Product Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//single-product',
|
||||
} );
|
||||
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) =>
|
||||
block.name === BLOCK_DATA[ 'single-product' ].name
|
||||
);
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) => block.name === BLOCK_DATA[ 'single-product' ].name
|
||||
);
|
||||
|
||||
// Comparing only the `template` property currently
|
||||
// because the other properties seem to be slightly unreliable.
|
||||
// Investigation pending.
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'single-product' ].attributes.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} )
|
||||
);
|
||||
// Comparing only the `template` property currently
|
||||
// because the other properties seem to be slightly unreliable.
|
||||
// Investigation pending.
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'single-product' ].attributes.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} );
|
||||
|
||||
it( 'should show the action menu if the template has been customized by the user', async () => {
|
||||
const EXPECTED_TEMPLATE = {
|
||||
|
@ -276,23 +257,20 @@ describe.skip( 'Store Editing Templates', () => {
|
|||
}
|
||||
} );
|
||||
|
||||
runOnlyWhenGutenbergIsDisabled( () =>
|
||||
it( 'should contain the "WooCommerce Product Grid Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//archive-product',
|
||||
} );
|
||||
it( 'should contain the "WooCommerce Product Grid Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//archive-product',
|
||||
} );
|
||||
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) =>
|
||||
block.name === BLOCK_DATA[ 'archive-product' ].name
|
||||
);
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) => block.name === BLOCK_DATA[ 'archive-product' ].name
|
||||
);
|
||||
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'archive-product' ].attributes.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} )
|
||||
);
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'archive-product' ].attributes.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} );
|
||||
|
||||
it( 'should show the action menu if the template has been customized by the user', async () => {
|
||||
const EXPECTED_TEMPLATE = {
|
||||
|
@ -371,23 +349,21 @@ describe.skip( 'Store Editing Templates', () => {
|
|||
}
|
||||
} );
|
||||
|
||||
runOnlyWhenGutenbergIsDisabled( () =>
|
||||
it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//taxonomy-product_cat',
|
||||
} );
|
||||
it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//taxonomy-product_cat',
|
||||
} );
|
||||
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) =>
|
||||
block.name === BLOCK_DATA[ 'taxonomy-product_cat' ].name
|
||||
);
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) =>
|
||||
block.name === BLOCK_DATA[ 'taxonomy-product_cat' ].name
|
||||
);
|
||||
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'taxonomy-product_cat' ].attributes.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} )
|
||||
);
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'taxonomy-product_cat' ].attributes.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} );
|
||||
|
||||
it( 'should show the action menu if the template has been customized by the user', async () => {
|
||||
const EXPECTED_TEMPLATE = {
|
||||
|
@ -466,23 +442,21 @@ describe.skip( 'Store Editing Templates', () => {
|
|||
}
|
||||
} );
|
||||
|
||||
runOnlyWhenGutenbergIsDisabled( () =>
|
||||
it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//taxonomy-product_tag',
|
||||
} );
|
||||
it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//taxonomy-product_tag',
|
||||
} );
|
||||
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) =>
|
||||
block.name === BLOCK_DATA[ 'taxonomy-product_tag' ].name
|
||||
);
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) =>
|
||||
block.name === BLOCK_DATA[ 'taxonomy-product_tag' ].name
|
||||
);
|
||||
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'taxonomy-product_tag' ].attributes.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} )
|
||||
);
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'taxonomy-product_tag' ].attributes.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} );
|
||||
|
||||
it( 'should show the action menu if the template has been customized by the user', async () => {
|
||||
const EXPECTED_TEMPLATE = {
|
||||
|
@ -561,25 +535,22 @@ describe.skip( 'Store Editing Templates', () => {
|
|||
}
|
||||
} );
|
||||
|
||||
runOnlyWhenGutenbergIsDisabled( () =>
|
||||
it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//taxonomy-product_attribute',
|
||||
} );
|
||||
it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//taxonomy-product_attribute',
|
||||
} );
|
||||
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) =>
|
||||
block.name ===
|
||||
BLOCK_DATA[ 'taxonomy-product_attribute' ].name
|
||||
);
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) =>
|
||||
block.name ===
|
||||
BLOCK_DATA[ 'taxonomy-product_attribute' ].name
|
||||
);
|
||||
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'taxonomy-product_attribute' ].attributes
|
||||
.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} )
|
||||
);
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'taxonomy-product_attribute' ].attributes.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} );
|
||||
|
||||
it( 'should show the action menu if the template has been customized by the user', async () => {
|
||||
const EXPECTED_TEMPLATE = {
|
||||
|
@ -660,23 +631,20 @@ describe.skip( 'Store Editing Templates', () => {
|
|||
}
|
||||
} );
|
||||
|
||||
runOnlyWhenGutenbergIsDisabled( () =>
|
||||
it( 'should contain the "WooCommerce Product Grid Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//product-search-results',
|
||||
} );
|
||||
it( 'should contain the "WooCommerce Product Grid Block" classic template', async () => {
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//product-search-results',
|
||||
} );
|
||||
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) =>
|
||||
block.name === BLOCK_DATA[ 'archive-product' ].name
|
||||
);
|
||||
const [ classicBlock ] = await filterCurrentBlocks(
|
||||
( block ) => block.name === BLOCK_DATA[ 'archive-product' ].name
|
||||
);
|
||||
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'product-search-results' ].attributes.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} )
|
||||
);
|
||||
expect( classicBlock.attributes.template ).toBe(
|
||||
BLOCK_DATA[ 'product-search-results' ].attributes.template
|
||||
);
|
||||
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
|
||||
} );
|
||||
|
||||
it( 'should show the action menu if the template has been customized by the user', async () => {
|
||||
const EXPECTED_TEMPLATE = {
|
||||
|
|
Loading…
Reference in New Issue