* 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:
Luigi Teschio 2022-12-06 15:40:05 +01:00 committed by GitHub
parent 7758ee05fe
commit 58f3217690
2 changed files with 80 additions and 127 deletions

View File

@ -2,9 +2,8 @@
/** /**
* External dependencies * External dependencies
*/ */
import path from 'path';
import { setup as setupPuppeteer } from 'jest-environment-puppeteer'; import { setup as setupPuppeteer } from 'jest-environment-puppeteer';
const { truncateSync, existsSync, unlinkSync } = require( 'fs' ); const { truncateSync, existsSync } = require( 'fs' );
/** /**
* Internal dependencies * Internal dependencies
*/ */
@ -24,22 +23,8 @@ import {
disableAttributeLookup, disableAttributeLookup,
} from '../fixtures/fixture-loaders'; } from '../fixtures/fixture-loaders';
import { PERFORMANCE_REPORT_FILENAME } from '../../utils/constants'; import { PERFORMANCE_REPORT_FILENAME } from '../../utils/constants';
import { GUTENBERG_EDITOR_CONTEXT } from '../utils';
module.exports = async ( globalConfig ) => { 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. // we need to load puppeteer global setup here.
await setupPuppeteer( globalConfig ); await setupPuppeteer( globalConfig );

View File

@ -24,7 +24,6 @@ import {
getAllTemplates, getAllTemplates,
goToTemplateEditor, goToTemplateEditor,
goToTemplatesList, goToTemplatesList,
GUTENBERG_EDITOR_CONTEXT,
saveTemplate, saveTemplate,
useTheme, useTheme,
} from '../../utils'; } from '../../utils';
@ -131,21 +130,6 @@ const CUSTOMIZED_STRING = 'My awesome customization';
const WOOCOMMERCE_ID = 'woocommerce/woocommerce'; const WOOCOMMERCE_ID = 'woocommerce/woocommerce';
const WOOCOMMERCE_PARSED_ID = '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', () => { describe.skip( 'Store Editing Templates', () => {
useTheme( 'emptytheme' ); useTheme( 'emptytheme' );
@ -175,26 +159,23 @@ describe.skip( 'Store Editing Templates', () => {
} }
} ); } );
runOnlyWhenGutenbergIsDisabled( () => it( 'should contain the "WooCommerce Single Product Block" classic template', async () => {
it( 'should contain the "WooCommerce Single Product Block" classic template', async () => { await goToTemplateEditor( {
await goToTemplateEditor( { postId: 'woocommerce/woocommerce//single-product',
postId: 'woocommerce/woocommerce//single-product', } );
} );
const [ classicBlock ] = await filterCurrentBlocks( const [ classicBlock ] = await filterCurrentBlocks(
( block ) => ( block ) => block.name === BLOCK_DATA[ 'single-product' ].name
block.name === BLOCK_DATA[ 'single-product' ].name );
);
// Comparing only the `template` property currently // Comparing only the `template` property currently
// because the other properties seem to be slightly unreliable. // because the other properties seem to be slightly unreliable.
// Investigation pending. // Investigation pending.
expect( classicBlock.attributes.template ).toBe( expect( classicBlock.attributes.template ).toBe(
BLOCK_DATA[ 'single-product' ].attributes.template BLOCK_DATA[ 'single-product' ].attributes.template
); );
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot(); expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
} ) } );
);
it( 'should show the action menu if the template has been customized by the user', async () => { it( 'should show the action menu if the template has been customized by the user', async () => {
const EXPECTED_TEMPLATE = { const EXPECTED_TEMPLATE = {
@ -276,23 +257,20 @@ describe.skip( 'Store Editing Templates', () => {
} }
} ); } );
runOnlyWhenGutenbergIsDisabled( () => it( 'should contain the "WooCommerce Product Grid Block" classic template', async () => {
it( 'should contain the "WooCommerce Product Grid Block" classic template', async () => { await goToTemplateEditor( {
await goToTemplateEditor( { postId: 'woocommerce/woocommerce//archive-product',
postId: 'woocommerce/woocommerce//archive-product', } );
} );
const [ classicBlock ] = await filterCurrentBlocks( const [ classicBlock ] = await filterCurrentBlocks(
( block ) => ( block ) => block.name === BLOCK_DATA[ 'archive-product' ].name
block.name === BLOCK_DATA[ 'archive-product' ].name );
);
expect( classicBlock.attributes.template ).toBe( expect( classicBlock.attributes.template ).toBe(
BLOCK_DATA[ 'archive-product' ].attributes.template BLOCK_DATA[ 'archive-product' ].attributes.template
); );
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot(); expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
} ) } );
);
it( 'should show the action menu if the template has been customized by the user', async () => { it( 'should show the action menu if the template has been customized by the user', async () => {
const EXPECTED_TEMPLATE = { const EXPECTED_TEMPLATE = {
@ -371,23 +349,21 @@ describe.skip( 'Store Editing Templates', () => {
} }
} ); } );
runOnlyWhenGutenbergIsDisabled( () => it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => {
it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => { await goToTemplateEditor( {
await goToTemplateEditor( { postId: 'woocommerce/woocommerce//taxonomy-product_cat',
postId: 'woocommerce/woocommerce//taxonomy-product_cat', } );
} );
const [ classicBlock ] = await filterCurrentBlocks( const [ classicBlock ] = await filterCurrentBlocks(
( block ) => ( block ) =>
block.name === BLOCK_DATA[ 'taxonomy-product_cat' ].name block.name === BLOCK_DATA[ 'taxonomy-product_cat' ].name
); );
expect( classicBlock.attributes.template ).toBe( expect( classicBlock.attributes.template ).toBe(
BLOCK_DATA[ 'taxonomy-product_cat' ].attributes.template BLOCK_DATA[ 'taxonomy-product_cat' ].attributes.template
); );
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot(); expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
} ) } );
);
it( 'should show the action menu if the template has been customized by the user', async () => { it( 'should show the action menu if the template has been customized by the user', async () => {
const EXPECTED_TEMPLATE = { const EXPECTED_TEMPLATE = {
@ -466,23 +442,21 @@ describe.skip( 'Store Editing Templates', () => {
} }
} ); } );
runOnlyWhenGutenbergIsDisabled( () => it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => {
it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => { await goToTemplateEditor( {
await goToTemplateEditor( { postId: 'woocommerce/woocommerce//taxonomy-product_tag',
postId: 'woocommerce/woocommerce//taxonomy-product_tag', } );
} );
const [ classicBlock ] = await filterCurrentBlocks( const [ classicBlock ] = await filterCurrentBlocks(
( block ) => ( block ) =>
block.name === BLOCK_DATA[ 'taxonomy-product_tag' ].name block.name === BLOCK_DATA[ 'taxonomy-product_tag' ].name
); );
expect( classicBlock.attributes.template ).toBe( expect( classicBlock.attributes.template ).toBe(
BLOCK_DATA[ 'taxonomy-product_tag' ].attributes.template BLOCK_DATA[ 'taxonomy-product_tag' ].attributes.template
); );
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot(); expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
} ) } );
);
it( 'should show the action menu if the template has been customized by the user', async () => { it( 'should show the action menu if the template has been customized by the user', async () => {
const EXPECTED_TEMPLATE = { const EXPECTED_TEMPLATE = {
@ -561,25 +535,22 @@ describe.skip( 'Store Editing Templates', () => {
} }
} ); } );
runOnlyWhenGutenbergIsDisabled( () => it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => {
it( 'should contain the "WooCommerce Product Taxonomy Block" classic template', async () => { await goToTemplateEditor( {
await goToTemplateEditor( { postId: 'woocommerce/woocommerce//taxonomy-product_attribute',
postId: 'woocommerce/woocommerce//taxonomy-product_attribute', } );
} );
const [ classicBlock ] = await filterCurrentBlocks( const [ classicBlock ] = await filterCurrentBlocks(
( block ) => ( block ) =>
block.name === block.name ===
BLOCK_DATA[ 'taxonomy-product_attribute' ].name BLOCK_DATA[ 'taxonomy-product_attribute' ].name
); );
expect( classicBlock.attributes.template ).toBe( expect( classicBlock.attributes.template ).toBe(
BLOCK_DATA[ 'taxonomy-product_attribute' ].attributes BLOCK_DATA[ 'taxonomy-product_attribute' ].attributes.template
.template );
); expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot(); } );
} )
);
it( 'should show the action menu if the template has been customized by the user', async () => { it( 'should show the action menu if the template has been customized by the user', async () => {
const EXPECTED_TEMPLATE = { const EXPECTED_TEMPLATE = {
@ -660,23 +631,20 @@ describe.skip( 'Store Editing Templates', () => {
} }
} ); } );
runOnlyWhenGutenbergIsDisabled( () => it( 'should contain the "WooCommerce Product Grid Block" classic template', async () => {
it( 'should contain the "WooCommerce Product Grid Block" classic template', async () => { await goToTemplateEditor( {
await goToTemplateEditor( { postId: 'woocommerce/woocommerce//product-search-results',
postId: 'woocommerce/woocommerce//product-search-results', } );
} );
const [ classicBlock ] = await filterCurrentBlocks( const [ classicBlock ] = await filterCurrentBlocks(
( block ) => ( block ) => block.name === BLOCK_DATA[ 'archive-product' ].name
block.name === BLOCK_DATA[ 'archive-product' ].name );
);
expect( classicBlock.attributes.template ).toBe( expect( classicBlock.attributes.template ).toBe(
BLOCK_DATA[ 'product-search-results' ].attributes.template BLOCK_DATA[ 'product-search-results' ].attributes.template
); );
expect( await getCurrentSiteEditorContent() ).toMatchSnapshot(); expect( await getCurrentSiteEditorContent() ).toMatchSnapshot();
} ) } );
);
it( 'should show the action menu if the template has been customized by the user', async () => { it( 'should show the action menu if the template has been customized by the user', async () => {
const EXPECTED_TEMPLATE = { const EXPECTED_TEMPLATE = {