-
Notifications
You must be signed in to change notification settings - Fork 10.7k
/
create-cart-block.spec.js
72 lines (63 loc) · 2.15 KB
/
create-cart-block.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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();
} );
} );