Convert block templates tests to parametized tests (#43778)
* Convert block templates tests to parametized tests * Use frontendUtils.addToCart() when possible * Add changefile(s) from automation for the following project(s): woocommerce-blocks --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
6c3f8cb6fb
commit
91d0e16151
|
@ -40,7 +40,7 @@ test.describe( 'Mini-Cart template part', async () => {
|
|||
await editorUtils.saveTemplate();
|
||||
|
||||
await page.goto( testData.permalink );
|
||||
await page.getByLabel( 'Add to cart' ).first().click();
|
||||
await frontendUtils.addToCart();
|
||||
let block = await frontendUtils.getBlockByName(
|
||||
testData.miniCartBlockName
|
||||
);
|
||||
|
|
|
@ -41,7 +41,7 @@ test.describe( 'Mini-Cart template part', async () => {
|
|||
await editorUtils.saveTemplate();
|
||||
|
||||
await page.goto( testData.permalink );
|
||||
await page.getByLabel( 'Add to cart' ).first().click();
|
||||
await frontendUtils.addToCart();
|
||||
let block = await frontendUtils.getBlockByName(
|
||||
testData.miniCartBlockName
|
||||
);
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { test, expect } from '@woocommerce/e2e-playwright-utils';
|
||||
|
||||
const permalink = '/shop';
|
||||
const templateName = 'Product Catalog';
|
||||
const templatePath = 'woocommerce/woocommerce//archive-product';
|
||||
const templateType = 'wp_template';
|
||||
const userText = 'Hello World in the template';
|
||||
|
||||
test.describe( 'Product Catalog template', async () => {
|
||||
test( 'can be modified and reverted', async ( {
|
||||
admin,
|
||||
editorUtils,
|
||||
page,
|
||||
} ) => {
|
||||
// Verify the template can be edited.
|
||||
await admin.visitSiteEditor( {
|
||||
postId: templatePath,
|
||||
postType: templateType,
|
||||
} );
|
||||
await editorUtils.enterEditMode();
|
||||
await editorUtils.closeWelcomeGuideModal();
|
||||
await editorUtils.editor.insertBlock( {
|
||||
name: 'core/paragraph',
|
||||
attributes: { content: userText },
|
||||
} );
|
||||
await editorUtils.saveTemplate();
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userText ).first() ).toBeVisible();
|
||||
|
||||
// Verify the edition can be reverted.
|
||||
await admin.visitAdminPage(
|
||||
'site-editor.php',
|
||||
`path=/${ templateType }/all`
|
||||
);
|
||||
await editorUtils.revertTemplateCustomizations( templateName );
|
||||
await page.goto( permalink );
|
||||
|
||||
await expect( page.getByText( userText ) ).toHaveCount( 0 );
|
||||
} );
|
||||
} );
|
|
@ -1,42 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { test, expect } from '@woocommerce/e2e-playwright-utils';
|
||||
|
||||
const permalink = '/?s=shirt&post_type=product';
|
||||
const templateName = 'Product Search Results';
|
||||
const templatePath = 'woocommerce/woocommerce//product-search-results';
|
||||
const templateType = 'wp_template';
|
||||
const userText = 'Hello World in the template';
|
||||
|
||||
test.describe( 'Product Search Results template', async () => {
|
||||
test( 'can be modified and reverted', async ( {
|
||||
admin,
|
||||
editorUtils,
|
||||
page,
|
||||
} ) => {
|
||||
// Verify the template can be edited.
|
||||
await admin.visitSiteEditor( {
|
||||
postId: templatePath,
|
||||
postType: templateType,
|
||||
} );
|
||||
await editorUtils.enterEditMode();
|
||||
await editorUtils.closeWelcomeGuideModal();
|
||||
await editorUtils.editor.insertBlock( {
|
||||
name: 'core/paragraph',
|
||||
attributes: { content: userText },
|
||||
} );
|
||||
await editorUtils.saveTemplate();
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userText ).first() ).toBeVisible();
|
||||
|
||||
// Verify the edition can be reverted.
|
||||
await admin.visitAdminPage(
|
||||
'site-editor.php',
|
||||
`path=/${ templateType }/all`
|
||||
);
|
||||
await editorUtils.revertTemplateCustomizations( templateName );
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userText ) ).toHaveCount( 0 );
|
||||
} );
|
||||
} );
|
|
@ -1,79 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { test, expect } from '@woocommerce/e2e-playwright-utils';
|
||||
|
||||
const permalink = '/color/blue';
|
||||
const templateName = 'Products by Attribute';
|
||||
const templatePath = 'woocommerce/woocommerce//taxonomy-product_attribute';
|
||||
const templateType = 'wp_template';
|
||||
const userText = 'Hello World in the template';
|
||||
const userTextInCatalogTemplate = 'Hello World in the Product Catalog template';
|
||||
|
||||
test.describe( 'Products by Attribute template', async () => {
|
||||
test( 'can be modified and reverted', async ( {
|
||||
admin,
|
||||
editorUtils,
|
||||
page,
|
||||
} ) => {
|
||||
// Verify the template can be edited.
|
||||
await admin.visitSiteEditor( {
|
||||
postId: templatePath,
|
||||
postType: templateType,
|
||||
} );
|
||||
await editorUtils.enterEditMode();
|
||||
await editorUtils.closeWelcomeGuideModal();
|
||||
await editorUtils.editor.insertBlock( {
|
||||
name: 'core/paragraph',
|
||||
attributes: { content: userText },
|
||||
} );
|
||||
await editorUtils.saveTemplate();
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userText ).first() ).toBeVisible();
|
||||
|
||||
// Verify the edition can be reverted.
|
||||
await admin.visitAdminPage(
|
||||
'site-editor.php',
|
||||
`path=/${ templateType }/all`
|
||||
);
|
||||
await editorUtils.revertTemplateCustomizations( templateName );
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userText ) ).toHaveCount( 0 );
|
||||
} );
|
||||
|
||||
test( 'defaults to the Product Catalog template', async ( {
|
||||
admin,
|
||||
editorUtils,
|
||||
page,
|
||||
} ) => {
|
||||
// Edit Product Catalog template and verify changes are visible.
|
||||
await admin.visitSiteEditor( {
|
||||
postId: 'woocommerce/woocommerce//archive-product',
|
||||
postType: 'wp_template',
|
||||
} );
|
||||
await editorUtils.enterEditMode();
|
||||
await editorUtils.closeWelcomeGuideModal();
|
||||
await editorUtils.editor.insertBlock( {
|
||||
name: 'core/paragraph',
|
||||
attributes: {
|
||||
content: userTextInCatalogTemplate,
|
||||
},
|
||||
} );
|
||||
await editorUtils.saveTemplate();
|
||||
await page.goto( permalink );
|
||||
await expect(
|
||||
page.getByText( userTextInCatalogTemplate ).first()
|
||||
).toBeVisible();
|
||||
|
||||
// Verify the edition can be reverted.
|
||||
await admin.visitAdminPage(
|
||||
'site-editor.php',
|
||||
`path=/wp_template/all`
|
||||
);
|
||||
await editorUtils.revertTemplateCustomizations( 'Product Catalog' );
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userTextInCatalogTemplate ) ).toHaveCount(
|
||||
0
|
||||
);
|
||||
} );
|
||||
} );
|
|
@ -1,79 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { test, expect } from '@woocommerce/e2e-playwright-utils';
|
||||
|
||||
const permalink = '/product-category/clothing';
|
||||
const templateName = 'Products by Category';
|
||||
const templatePath = 'woocommerce/woocommerce//taxonomy-product_cat';
|
||||
const templateType = 'wp_template';
|
||||
const userText = 'Hello World in the template';
|
||||
const userTextInCatalogTemplate = 'Hello World in the Product Catalog template';
|
||||
|
||||
test.describe( 'Products by Category template', async () => {
|
||||
test( 'can be modified and reverted', async ( {
|
||||
admin,
|
||||
editorUtils,
|
||||
page,
|
||||
} ) => {
|
||||
// Verify the template can be edited.
|
||||
await admin.visitSiteEditor( {
|
||||
postId: templatePath,
|
||||
postType: templateType,
|
||||
} );
|
||||
await editorUtils.enterEditMode();
|
||||
await editorUtils.closeWelcomeGuideModal();
|
||||
await editorUtils.editor.insertBlock( {
|
||||
name: 'core/paragraph',
|
||||
attributes: { content: userText },
|
||||
} );
|
||||
await editorUtils.saveTemplate();
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userText ).first() ).toBeVisible();
|
||||
|
||||
// Verify the edition can be reverted.
|
||||
await admin.visitAdminPage(
|
||||
'site-editor.php',
|
||||
`path=/${ templateType }/all`
|
||||
);
|
||||
await editorUtils.revertTemplateCustomizations( templateName );
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userText ) ).toHaveCount( 0 );
|
||||
} );
|
||||
|
||||
test( 'defaults to the Product Catalog template', async ( {
|
||||
admin,
|
||||
editorUtils,
|
||||
page,
|
||||
} ) => {
|
||||
// Edit Product Catalog template and verify changes are visible.
|
||||
await admin.visitSiteEditor( {
|
||||
postId: 'woocommerce/woocommerce//archive-product',
|
||||
postType: 'wp_template',
|
||||
} );
|
||||
await editorUtils.enterEditMode();
|
||||
await editorUtils.closeWelcomeGuideModal();
|
||||
await editorUtils.editor.insertBlock( {
|
||||
name: 'core/paragraph',
|
||||
attributes: {
|
||||
content: userTextInCatalogTemplate,
|
||||
},
|
||||
} );
|
||||
await editorUtils.saveTemplate();
|
||||
await page.goto( permalink );
|
||||
await expect(
|
||||
page.getByText( userTextInCatalogTemplate ).first()
|
||||
).toBeVisible();
|
||||
|
||||
// Verify the edition can be reverted.
|
||||
await admin.visitAdminPage(
|
||||
'site-editor.php',
|
||||
`path=/wp_template/all`
|
||||
);
|
||||
await editorUtils.revertTemplateCustomizations( 'Product Catalog' );
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userTextInCatalogTemplate ) ).toHaveCount(
|
||||
0
|
||||
);
|
||||
} );
|
||||
} );
|
|
@ -1,79 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { test, expect } from '@woocommerce/e2e-playwright-utils';
|
||||
|
||||
const permalink = '/product-tag/recommended/';
|
||||
const templateName = 'Products by Tag';
|
||||
const templatePath = 'woocommerce/woocommerce//taxonomy-product_tag';
|
||||
const templateType = 'wp_template';
|
||||
const userText = 'Hello World in the template';
|
||||
const userTextInCatalogTemplate = 'Hello World in the Product Catalog template';
|
||||
|
||||
test.describe( 'Products by Tag template', async () => {
|
||||
test( 'can be modified and reverted', async ( {
|
||||
admin,
|
||||
editorUtils,
|
||||
page,
|
||||
} ) => {
|
||||
// Verify the template can be edited.
|
||||
await admin.visitSiteEditor( {
|
||||
postId: templatePath,
|
||||
postType: templateType,
|
||||
} );
|
||||
await editorUtils.enterEditMode();
|
||||
await editorUtils.closeWelcomeGuideModal();
|
||||
await editorUtils.editor.insertBlock( {
|
||||
name: 'core/paragraph',
|
||||
attributes: { content: userText },
|
||||
} );
|
||||
await editorUtils.saveTemplate();
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userText ).first() ).toBeVisible();
|
||||
|
||||
// Verify the edition can be reverted.
|
||||
await admin.visitAdminPage(
|
||||
'site-editor.php',
|
||||
`path=/${ templateType }/all`
|
||||
);
|
||||
await editorUtils.revertTemplateCustomizations( templateName );
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userText ) ).toHaveCount( 0 );
|
||||
} );
|
||||
|
||||
test( 'defaults to the Product Catalog template', async ( {
|
||||
admin,
|
||||
editorUtils,
|
||||
page,
|
||||
} ) => {
|
||||
// Edit Product Catalog template and verify changes are visible.
|
||||
await admin.visitSiteEditor( {
|
||||
postId: 'woocommerce/woocommerce//archive-product',
|
||||
postType: 'wp_template',
|
||||
} );
|
||||
await editorUtils.enterEditMode();
|
||||
await editorUtils.closeWelcomeGuideModal();
|
||||
await editorUtils.editor.insertBlock( {
|
||||
name: 'core/paragraph',
|
||||
attributes: {
|
||||
content: userTextInCatalogTemplate,
|
||||
},
|
||||
} );
|
||||
await editorUtils.saveTemplate();
|
||||
await page.goto( permalink );
|
||||
await expect(
|
||||
page.getByText( userTextInCatalogTemplate ).first()
|
||||
).toBeVisible();
|
||||
|
||||
// Verify the edition can be reverted.
|
||||
await admin.visitAdminPage(
|
||||
'site-editor.php',
|
||||
`path=/wp_template/all`
|
||||
);
|
||||
await editorUtils.revertTemplateCustomizations( 'Product Catalog' );
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userTextInCatalogTemplate ) ).toHaveCount(
|
||||
0
|
||||
);
|
||||
} );
|
||||
} );
|
|
@ -1,42 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { test, expect } from '@woocommerce/e2e-playwright-utils';
|
||||
|
||||
const permalink = '/product/hoodie';
|
||||
const templateName = 'Single Product';
|
||||
const templatePath = 'woocommerce/woocommerce//single-product';
|
||||
const templateType = 'wp_template';
|
||||
const userText = 'Hello World in the template';
|
||||
|
||||
test.describe( 'Single Product template', async () => {
|
||||
test( 'can be modified and reverted', async ( {
|
||||
admin,
|
||||
editorUtils,
|
||||
page,
|
||||
} ) => {
|
||||
// Verify the template can be edited.
|
||||
await admin.visitSiteEditor( {
|
||||
postId: templatePath,
|
||||
postType: templateType,
|
||||
} );
|
||||
await editorUtils.enterEditMode();
|
||||
await editorUtils.closeWelcomeGuideModal();
|
||||
await editorUtils.editor.insertBlock( {
|
||||
name: 'core/paragraph',
|
||||
attributes: { content: userText },
|
||||
} );
|
||||
await editorUtils.saveTemplate();
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userText ).first() ).toBeVisible();
|
||||
|
||||
// Verify the edition can be reverted.
|
||||
await admin.visitAdminPage(
|
||||
'site-editor.php',
|
||||
`path=/${ templateType }/all`
|
||||
);
|
||||
await editorUtils.revertTemplateCustomizations( templateName );
|
||||
await page.goto( permalink );
|
||||
await expect( page.getByText( userText ) ).toHaveCount( 0 );
|
||||
} );
|
||||
} );
|
|
@ -0,0 +1,133 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { test, expect } from '@woocommerce/e2e-playwright-utils';
|
||||
|
||||
const templateUserCustomizationTests = [
|
||||
{
|
||||
permalink: '/shop',
|
||||
templateName: 'Product Catalog',
|
||||
templatePath: 'woocommerce/woocommerce//archive-product',
|
||||
templateType: 'wp_template',
|
||||
},
|
||||
{
|
||||
permalink: '/?s=shirt&post_type=product',
|
||||
templateName: 'Product Search Results',
|
||||
templatePath: 'woocommerce/woocommerce//product-search-results',
|
||||
templateType: 'wp_template',
|
||||
},
|
||||
{
|
||||
permalink: '/color/blue',
|
||||
templateName: 'Products by Attribute',
|
||||
templatePath: 'woocommerce/woocommerce//taxonomy-product_attribute',
|
||||
templateType: 'wp_template',
|
||||
defaultTemplate: {
|
||||
templateName: 'Product Catalog',
|
||||
templatePath: 'woocommerce/woocommerce//archive-product',
|
||||
},
|
||||
},
|
||||
{
|
||||
permalink: '/product-category/clothing',
|
||||
templateName: 'Products by Category',
|
||||
templatePath: 'woocommerce/woocommerce//taxonomy-product_cat',
|
||||
templateType: 'wp_template',
|
||||
defaultTemplate: {
|
||||
templateName: 'Product Catalog',
|
||||
templatePath: 'woocommerce/woocommerce//archive-product',
|
||||
},
|
||||
},
|
||||
{
|
||||
permalink: '/product-tag/recommended/',
|
||||
templateName: 'Products by Tag',
|
||||
templatePath: 'woocommerce/woocommerce//taxonomy-product_tag',
|
||||
templateType: 'wp_template',
|
||||
defaultTemplate: {
|
||||
templateName: 'Product Catalog',
|
||||
templatePath: 'woocommerce/woocommerce//archive-product',
|
||||
},
|
||||
},
|
||||
{
|
||||
permalink: '/product/hoodie',
|
||||
templateName: 'Single Product',
|
||||
templatePath: 'woocommerce/woocommerce//single-product',
|
||||
templateType: 'wp_template',
|
||||
},
|
||||
];
|
||||
const userText = 'Hello World in the template';
|
||||
const defaultTemplateUserText = 'Hello World in the default template';
|
||||
|
||||
templateUserCustomizationTests.forEach( ( testData ) => {
|
||||
test.describe( `${ testData.templateName } template`, async () => {
|
||||
test( 'can be modified and reverted', async ( {
|
||||
admin,
|
||||
editorUtils,
|
||||
page,
|
||||
} ) => {
|
||||
// Verify the template can be edited.
|
||||
await admin.visitSiteEditor( {
|
||||
postId: testData.templatePath,
|
||||
postType: testData.templateType,
|
||||
} );
|
||||
await editorUtils.enterEditMode();
|
||||
await editorUtils.closeWelcomeGuideModal();
|
||||
await editorUtils.editor.insertBlock( {
|
||||
name: 'core/paragraph',
|
||||
attributes: { content: userText },
|
||||
} );
|
||||
await editorUtils.saveTemplate();
|
||||
await page.goto( testData.permalink );
|
||||
await expect( page.getByText( userText ).first() ).toBeVisible();
|
||||
|
||||
// Verify the edition can be reverted.
|
||||
await admin.visitAdminPage(
|
||||
'site-editor.php',
|
||||
`path=/${ testData.templateType }/all`
|
||||
);
|
||||
await editorUtils.revertTemplateCustomizations(
|
||||
testData.templateName
|
||||
);
|
||||
await page.goto( testData.permalink );
|
||||
await expect( page.getByText( userText ) ).toHaveCount( 0 );
|
||||
} );
|
||||
|
||||
if ( testData.defaultTemplate ) {
|
||||
test( `defaults to the ${ testData.defaultTemplate.templateName } template`, async ( {
|
||||
admin,
|
||||
editorUtils,
|
||||
page,
|
||||
} ) => {
|
||||
// Edit default template and verify changes are visible.
|
||||
await admin.visitSiteEditor( {
|
||||
postId: testData.defaultTemplate.templatePath,
|
||||
postType: testData.templateType,
|
||||
} );
|
||||
await editorUtils.enterEditMode();
|
||||
await editorUtils.closeWelcomeGuideModal();
|
||||
await editorUtils.editor.insertBlock( {
|
||||
name: 'core/paragraph',
|
||||
attributes: {
|
||||
content: defaultTemplateUserText,
|
||||
},
|
||||
} );
|
||||
await editorUtils.saveTemplate();
|
||||
await page.goto( testData.permalink );
|
||||
await expect(
|
||||
page.getByText( defaultTemplateUserText ).first()
|
||||
).toBeVisible();
|
||||
|
||||
// Verify the edition can be reverted.
|
||||
await admin.visitAdminPage(
|
||||
'site-editor.php',
|
||||
`path=/${ testData.templateType }/all`
|
||||
);
|
||||
await editorUtils.revertTemplateCustomizations(
|
||||
testData.defaultTemplate.templateName
|
||||
);
|
||||
await page.goto( testData.permalink );
|
||||
await expect(
|
||||
page.getByText( defaultTemplateUserText )
|
||||
).toHaveCount( 0 );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: update
|
||||
Comment: Convert block templates tests to parametized tests
|
||||
|
Loading…
Reference in New Issue