Add E2E tests to cover Publish dropdown options (#46658)

* Add e2e tests for publish options

* Add changelog

* Create different tests for options

* Update plugins/woocommerce/tests/e2e-pw/tests/merchant/products/block-editor/product-edit-block-editor.spec.js

Co-authored-by: louwie17 <lourensschep@gmail.com>

---------

Co-authored-by: louwie17 <lourensschep@gmail.com>
This commit is contained in:
Fernando Marichal 2024-04-19 10:46:32 -03:00 committed by GitHub
parent 46d87d427a
commit d21b03588a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: dev
Add E2E tests to cover Publish dropdown options #46658

View File

@ -80,3 +80,84 @@ test( 'can update the general information of a product', async ( {
.toHaveText( updatedProduct.description );
} );
} );
test.describe( 'Publish dropdown options', () => {
test( 'can schedule a product publication', async ( { page, product } ) => {
await page.goto( `wp-admin/post.php?post=${ product.id }&action=edit` );
await page
.locator( '.woocommerce-product-header__actions' )
.first()
.locator( 'button[aria-label="More options"]' )
.click();
await page.getByText( 'Schedule publish' ).click();
await expect(
page.getByRole( 'heading', { name: 'Schedule product' } )
).toBeVisible();
await page
.locator( '.woocommerce-schedule-publish-modal' )
.locator( 'button[aria-label="View next month"]' )
.click();
await page
.locator( '.woocommerce-schedule-publish-modal' )
.getByText( '14' )
.click();
await page.getByRole( 'button', { name: 'Schedule' } ).click();
await expect(
page.getByLabel( 'Dismiss this notice' ).first()
).toContainText( 'Product scheduled for' );
} );
test( 'can duplicate a product', async ( { page, product } ) => {
await page.goto( `wp-admin/post.php?post=${ product.id }&action=edit` );
await page
.locator( '.woocommerce-product-header__actions' )
.first()
.locator( 'button[aria-label="More options"]' )
.click();
await page.getByText( 'Copy to a new draft' ).click();
await expect(
page.getByLabel( 'Dismiss this notice' ).first()
).toContainText( 'Product successfully duplicated' );
await expect(
page.getByRole( 'heading', { name: `${ product.name } (Copy)` } )
).toBeVisible();
await expect(
page
.locator( '.woocommerce-product-header__visibility-tags' )
.getByText( 'Draft' )
.first()
).toBeVisible();
await page
.locator( '.woocommerce-product-header__actions' )
.first()
.locator( 'button[aria-label="More options"]' )
.click();
await page.getByText( 'Move to trash' ).click();
} );
test( 'can delete a product', async ( { page, product } ) => {
await page.goto( `wp-admin/post.php?post=${ product.id }&action=edit` );
await page
.locator( '.woocommerce-product-header__actions' )
.first()
.locator( 'button[aria-label="More options"]' )
.click();
await page.getByText( 'Move to trash' ).click();
await expect(
page.getByRole( 'heading', { name: 'Products' } ).first()
).toBeVisible();
} );
} );