Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new E2E test for merchant transforming classic cart to cart block (…
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
plugins/woocommerce/changelog/e2e-add-merchant-transform-cart-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: dev | ||
|
||
E2E tests: add test for transforming classic cart to cart block |
72 changes: 72 additions & 0 deletions
72
plugins/woocommerce/tests/e2e-pw/tests/merchant/create-cart-block.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const { test, expect } = require( '@playwright/test' ); | ||
const { closeWelcomeModal } = require( '../../utils/editor' ); | ||
|
||
const transformedCartBlockTitle = `Transformed Cart ${ Date.now() }`; | ||
const transformedCartBlockSlug = transformedCartBlockTitle | ||
.replace( / /gi, '-' ) | ||
.toLowerCase(); | ||
|
||
test.describe( 'Transform Classic Cart To Cart Block', () => { | ||
test.use( { storageState: process.env.ADMINSTATE } ); | ||
|
||
test( 'can transform classic cart to cart block', async ( { page } ) => { | ||
// go to create a new page | ||
await page.goto( 'wp-admin/post-new.php?post_type=page' ); | ||
|
||
await closeWelcomeModal( { page } ); | ||
|
||
// fill page title | ||
await page | ||
.getByRole( 'textbox', { name: 'Add title' } ) | ||
.fill( transformedCartBlockTitle ); | ||
|
||
// add classic cart block | ||
await page.getByRole( 'textbox', { name: 'Add title' } ).click(); | ||
await page.getByLabel( 'Add block' ).click(); | ||
await page | ||
.getByPlaceholder( 'Search', { exact: true } ) | ||
.fill( 'classic cart' ); | ||
await page | ||
.getByRole( 'option' ) | ||
.filter( { hasText: 'Classic Cart' } ) | ||
.click(); | ||
|
||
// transform into blocks | ||
await expect( | ||
page.locator( | ||
'.wp-block-woocommerce-classic-shortcode__placeholder-copy' | ||
) | ||
).toBeVisible(); | ||
await page | ||
.getByRole( 'button' ) | ||
.filter( { hasText: 'Transform into blocks' } ) | ||
.click(); | ||
await expect( page.getByLabel( 'Dismiss this notice' ) ).toContainText( | ||
'Classic shortcode transformed to blocks.' | ||
); | ||
|
||
// save and publish the page | ||
await page | ||
.getByRole( 'button', { name: 'Publish', exact: true } ) | ||
.click(); | ||
await page | ||
.getByRole( 'region', { name: 'Editor publish' } ) | ||
.getByRole( 'button', { name: 'Publish', exact: true } ) | ||
.click(); | ||
await expect( | ||
page.getByText( `${ transformedCartBlockTitle } is now live.` ) | ||
).toBeVisible(); | ||
|
||
// go to frontend to verify transformed cart block | ||
await page.goto( transformedCartBlockSlug ); | ||
await expect( | ||
page.getByRole( 'heading', { name: transformedCartBlockTitle } ) | ||
).toBeVisible(); | ||
await expect( | ||
page.getByText( 'Your cart is currently empty!' ) | ||
).toBeVisible(); | ||
await expect( | ||
page.getByRole( 'link', { name: 'Browse store' } ) | ||
).toBeVisible(); | ||
} ); | ||
} ); |