[E2E tests]: Add product description using the block editor (#50232)

* Add product description

* Add changelog

* Add changelog

* Always use same label for ToolbarItem
This commit is contained in:
Fernando Marichal 2024-08-05 08:43:22 -03:00 committed by GitHub
parent 559c91626c
commit 54b29ec50e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 83 additions and 5 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
[E2E tests]: Add aria-expanded and rename ToolbarItem label #50232

View File

@ -142,11 +142,11 @@ export function HeaderToolbar( {
onClick={ toggleInserter } onClick={ toggleInserter }
disabled={ ! isInserterEnabled } disabled={ ! isInserterEnabled }
icon={ plus } icon={ plus }
label={ label={ __(
! isInserterOpened 'Toggle block inserter',
? __( 'Add', 'woocommerce' ) 'woocommerce'
: __( 'Close', 'woocommerce' ) ) }
} aria-expanded={ isInserterOpened }
showTooltip showTooltip
/> />
{ isLargeViewport && ( { isLargeViewport && (

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
[E2E tests]: Add product description using the block editor #50232

View File

@ -2,6 +2,10 @@ const { test } = require( '../../../../fixtures/block-editor-fixtures' );
const { expect } = require( '@playwright/test' ); const { expect } = require( '@playwright/test' );
const { clickOnTab } = require( '../../../../utils/simple-products' ); const { clickOnTab } = require( '../../../../utils/simple-products' );
const {
getInstalledWordPressVersion,
} = require( '../../../../utils/wordpress' );
const { insertBlock } = require( '../../../../utils/editor' );
const NEW_EDITOR_ADD_PRODUCT_URL = const NEW_EDITOR_ADD_PRODUCT_URL =
'wp-admin/admin.php?page=wc-admin&path=%2Fadd-product'; 'wp-admin/admin.php?page=wc-admin&path=%2Fadd-product';
@ -11,6 +15,9 @@ const isTrackingSupposedToBeEnabled = !! process.env.ENABLE_TRACKING;
const productData = { const productData = {
name: `Simple product Name ${ new Date().getTime().toString() }`, name: `Simple product Name ${ new Date().getTime().toString() }`,
summary: 'This is a product summary', summary: 'This is a product summary',
descriptionTitle: 'Product Description title',
descriptionParagraph: 'This is a product description',
descriptionSimple: 'This is a product simple description',
productPrice: '100', productPrice: '100',
salePrice: '90', salePrice: '90',
}; };
@ -44,6 +51,69 @@ test.describe( 'General tab', { tag: '@gutenberg' }, () => {
await page await page
.getByPlaceholder( 'e.g. 12 oz Coffee Mug' ) .getByPlaceholder( 'e.g. 12 oz Coffee Mug' )
.fill( productData.name ); .fill( productData.name );
await page
.locator(
'[data-template-block-id="product-description__content"] > p'
)
.fill( productData.descriptionSimple );
await page.getByText( 'Full editor' ).click();
const wordPressVersion = await getInstalledWordPressVersion();
await insertBlock( page, 'Heading', wordPressVersion );
const editorCanvasLocator = page.frameLocator(
'iframe[name="editor-canvas"]'
);
await editorCanvasLocator
.locator( '[data-title="Heading"]' )
.fill( productData.descriptionTitle );
await editorCanvasLocator
.locator( '[data-title="Heading"]' )
.blur();
await insertBlock( page, 'Paragraph', wordPressVersion );
await editorCanvasLocator
.locator( '[data-title="Paragraph"]' )
.last()
.fill( productData.descriptionParagraph );
await page.getByRole( 'button', { name: 'Done' } ).click();
const previewContainerIframe = page
.locator( '.block-editor-block-preview__container' )
.frameLocator( 'iframe[title="Editor canvas"]' );
const descriptionTitle = previewContainerIframe.locator(
'[data-title="Heading"]'
);
const descriptionInitialParagraph = previewContainerIframe
.locator( '[data-title="Paragraph"]' )
.first();
const descriptionSecondParagraph = previewContainerIframe
.locator( '[data-title="Paragraph"]' )
.last();
await expect( descriptionTitle ).toHaveText(
productData.descriptionTitle
);
await expect( descriptionInitialParagraph ).toHaveText(
productData.descriptionSimple
);
await expect( descriptionSecondParagraph ).toHaveText(
productData.descriptionParagraph
);
await descriptionTitle.click();
await expect(
page.getByText( 'Edit in full editor' )
).toBeVisible();
await page await page
.locator( .locator(
'[data-template-block-id="basic-details"] .components-summary-control' '[data-template-block-id="basic-details"] .components-summary-control'