Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e tests to verify specific theme templates have priority over user-modified Product Catalog template #43750

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,30 @@ const templateUserCustomizationTests = [
templateName: 'Products by Attribute',
templatePath: `${ BLOCK_THEME_WITH_TEMPLATES_SLUG }//taxonomy-product_attribute`,
templateType: 'wp_template',
defaultTemplate: {
templateName: 'Product Catalog',
templatePath: 'woocommerce/woocommerce//archive-product',
},
},
{
permalink: '/product-category/clothing',
templateName: 'Products by Category',
templatePath: `${ BLOCK_THEME_WITH_TEMPLATES_SLUG }//taxonomy-product_cat`,
templateType: 'wp_template',
defaultTemplate: {
templateName: 'Product Catalog',
templatePath: 'woocommerce/woocommerce//archive-product',
},
},
{
permalink: '/product-tag/recommended/',
templateName: 'Products by Tag',
templatePath: `${ BLOCK_THEME_WITH_TEMPLATES_SLUG }//taxonomy-product_tag`,
templateType: 'wp_template',
defaultTemplate: {
templateName: 'Product Catalog',
templatePath: 'woocommerce/woocommerce//archive-product',
},
},
{
permalink: '/product/hoodie',
Expand All @@ -43,6 +55,7 @@ const templateUserCustomizationTests = [
},
];
const userText = 'Hello World in the template';
const defaultTemplateUserText = 'Hello World in the default template';

templateUserCustomizationTests.forEach( ( testData ) => {
test.describe( `${ testData.templateName } template`, async () => {
Expand Down Expand Up @@ -87,5 +100,41 @@ templateUserCustomizationTests.forEach( ( testData ) => {
).toBeVisible();
await expect( page.getByText( userText ) ).toHaveCount( 0 );
} );

if ( testData.defaultTemplate ) {
test( `theme template has priority over user-modified ${ testData.defaultTemplate.templateName } template`, async ( {
admin,
editorUtils,
page,
} ) => {
// Edit default template and verify changes are not visible, as the theme template has priority.
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 )
).toHaveCount( 0 );

// Revert the edit.
await admin.visitAdminPage(
'site-editor.php',
`path=/${ testData.templateType }/all`
);
await editorUtils.revertTemplateCustomizations(
testData.defaultTemplate.templateName
);
} );
}
} );
} );
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev
Comment: Add e2e tests to verify specific theme templates have priority over user-modified Product Catalog template