Skip to content

Commit

Permalink
Add test also when saving the default WooCommerce template
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu committed Feb 6, 2024
1 parent e764212 commit ef5d508
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { CUSTOMIZABLE_WC_TEMPLATES, WC_TEMPLATES_SLUG } from './constants';
CUSTOMIZABLE_WC_TEMPLATES.forEach( ( testData ) => {
const userText = `Hello World in the ${ testData.templateName } template`;
const fallbackTemplateUserText = `Hello World in the fallback ${ testData.templateName } template`;
const templateTypeName =
testData.templateType === 'wp_template' ? 'template' : 'template part';

test.describe( `${ testData.templateName } template`, async () => {
test( 'can be modified and reverted', async ( {
Expand All @@ -31,6 +33,14 @@ CUSTOMIZABLE_WC_TEMPLATES.forEach( ( testData ) => {
attributes: { content: userText },
} );
await editorUtils.saveTemplate();
// Verify template name didn't change.
// See: https://github.com/woocommerce/woocommerce/issues/42221
await expect(
page.getByRole( 'heading', {
name: `Editing ${ templateTypeName }: ${ testData.templateName }`,
} )
).toBeVisible();

await testData.visitPage( { frontendUtils, page } );
await expect( page.getByText( userText ).first() ).toBeVisible();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ CUSTOMIZABLE_WC_TEMPLATES.forEach( ( testData ) => {
}
const userText = `Hello World in the ${ testData.templateName } template`;
const fallbackTemplateUserText = `Hello World in the fallback ${ testData.templateName } template`;
const templateTypeName = testData.templateType === 'wp_template' ? 'template' : 'template part';
const templateTypeName =
testData.templateType === 'wp_template' ? 'template' : 'template part';

test.describe( `${ testData.templateName } template`, async () => {
test( "theme template has priority over WooCommerce's and can be modified", async ( {
Expand All @@ -40,7 +41,7 @@ CUSTOMIZABLE_WC_TEMPLATES.forEach( ( testData ) => {
// See: https://github.com/woocommerce/woocommerce/issues/42221
await expect(
page.getByRole( 'heading', {
name: `Editing ${templateTypeName}: ${ testData.templateName }`,
name: `Editing ${ templateTypeName }: ${ testData.templateName }`,
} )
).toBeVisible();

Expand Down

0 comments on commit ef5d508

Please sign in to comment.