Blocks E2E: Ensure legacy template slugs are supported (#46269)

This commit is contained in:
Bart Kalisz 2024-04-10 10:38:55 +02:00 committed by GitHub
parent 9df545046a
commit b8df34659c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,108 @@
/**
* External dependencies
*/
import { test, expect } from '@woocommerce/e2e-playwright-utils';
import { cli } from '@woocommerce/e2e-utils';
test.describe( 'Legacy templates', async () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.deleteAllTemplates( 'wp_template' );
} );
test.afterEach( async ( { requestUtils } ) => {
await requestUtils.deleteAllTemplates( 'wp_template' );
} );
test( 'woocommerce//* slug is supported', async ( {
admin,
page,
editor,
} ) => {
const template = {
id: 'single-product',
name: 'Single Product',
customText: 'This is a customized template.',
frontendPath: '/product/hoodie/',
};
await test.step( 'Customize existing template to create DB entry', async () => {
await admin.visitSiteEditor( {
postId: `woocommerce/woocommerce//${ template.id }`,
postType: 'wp_template',
canvas: 'edit',
} );
const title = editor.canvas.getByText( 'Title' );
await title.click();
await title.press( 'Enter' );
const emptyBlock = editor.canvas
.getByLabel( 'Empty block' )
.first();
await emptyBlock.fill( template.customText );
await page.keyboard.press( 'Escape' );
await expect(
editor.canvas.getByText( template.customText )
).toBeVisible();
await editor.saveSiteEditorEntities();
} );
await test.step( 'Update created term to legacy format in the DB', async () => {
const cliOutput = await cli(
`npm run wp-env run tests-cli -- \
wp term update wp_theme woocommerce-woocommerce \
--by="slug" \
--name="woocommerce" \
--slug="woocommerce"`
);
expect( cliOutput.stdout ).toContain( 'Success: Term updated.' );
} );
await test.step( 'Verify the template can be edited via a legacy ID ', async () => {
await admin.visitSiteEditor( {
postId: `woocommerce//${ template.id }`,
postType: 'wp_template',
canvas: 'edit',
} );
await expect(
editor.canvas.getByText( template.customText )
).toBeVisible();
} );
await test.step( 'Verify the template is listed in the Site Editor UI', async () => {
await admin.visitSiteEditor( {
path: '/wp_template/all',
} );
await page.getByPlaceholder( 'Search' ).fill( template.name );
await expect(
page.getByRole( 'link', { name: template.name } )
).toBeVisible();
} );
await test.step( 'Verify the template loads correctly in the frontend', async () => {
await page.goto( template.frontendPath );
await expect( page.getByText( template.customText ) ).toBeVisible();
} );
await test.step( 'Revert term update', async () => {
const cliOutput = await cli(
`npm run wp-env run tests-cli -- \
wp term update wp_theme woocommerce \
--by="slug" \
--name="woocommerce/woocommerce" \
--slug="woocommerce-woocommerce"`
);
expect( cliOutput.stdout ).toContain( 'Success: Term updated.' );
} );
} );
} );

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Blocks E2E: Ensure legacy template names are supported