Skip to content

Commit d6063ef

Browse files
committed
migrate row block css grid e2e tests to playwright
1 parent 7145fcd commit d6063ef

5 files changed

Lines changed: 99 additions & 88 deletions

File tree

cypress/e2e/row/row-bootstrap-v4.cy.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

cypress/e2e/row/row-css-grid.cy.js

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- wp:wp-bootstrap-blocks/row {"cssGridGutters":"2rem"} -->
2+
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":6} /-->
3+
4+
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":6} /-->
5+
<!-- /wp:wp-bootstrap-blocks/row -->
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
2+
3+
test.describe( 'Row Block - Bootstrap 4', () => {
4+
test.beforeAll( async ( { requestUtils } ) => {
5+
await requestUtils.activatePlugin(
6+
'wp-bootstrap-blocks-test-bootstrap-v4'
7+
);
8+
} );
9+
10+
test.afterAll( async ( { requestUtils } ) => {
11+
await requestUtils.deactivatePlugin(
12+
'wp-bootstrap-blocks-test-bootstrap-v4'
13+
);
14+
} );
15+
16+
test.beforeEach( async ( { admin, editor, page } ) => {
17+
await admin.createNewPost();
18+
await editor.insertBlock( {
19+
name: 'wp-bootstrap-blocks/row',
20+
} );
21+
await editor.openDocumentSettingsSidebar();
22+
} );
23+
24+
test( 'Bootstrap 5 options are not displayed if run with Bootstrap 4', async ( {
25+
page,
26+
} ) => {
27+
// Horizontal Gutters options should not exist
28+
await expect(
29+
page.getByLabel( 'Horizontal Gutters' )
30+
).not.toBeVisible();
31+
32+
// Vertical Gutters options should not exist
33+
await expect( page.getByLabel( 'Vertical Gutters' ) ).not.toBeVisible();
34+
} );
35+
} );
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
2+
3+
test.describe( 'Row Block - CSS Grid', () => {
4+
test.beforeAll( async ( { requestUtils } ) => {
5+
await requestUtils.activatePlugin(
6+
'wp-bootstrap-blocks-test-css-grid'
7+
);
8+
} );
9+
10+
test.afterAll( async ( { requestUtils } ) => {
11+
await requestUtils.deactivatePlugin(
12+
'wp-bootstrap-blocks-test-css-grid'
13+
);
14+
} );
15+
16+
test.beforeEach( async ( { admin, editor, page } ) => {
17+
await admin.createNewPost();
18+
await editor.insertBlock( {
19+
name: 'wp-bootstrap-blocks/row',
20+
} );
21+
await editor.openDocumentSettingsSidebar();
22+
} );
23+
24+
test( 'CSS Grid options are shown', async ( { page } ) => {
25+
// Gutters options should exist
26+
await expect(
27+
page.getByLabel( 'Gutters', { exact: true } )
28+
).toBeVisible();
29+
} );
30+
31+
test( 'Change gutter size', async ( { page, editor } ) => {
32+
// Change gutters
33+
await page
34+
.getByLabel( 'Gutters', { exact: true } )
35+
.selectOption( '2rem' );
36+
37+
expect( await editor.getEditedPostContent() ).toMatchSnapshot(
38+
'change-gutter-size.txt'
39+
);
40+
} );
41+
42+
test( 'Hide gutter options when no gutters is checked', async ( {
43+
page,
44+
editor,
45+
} ) => {
46+
// Enable no gutters option
47+
await page
48+
.getByRole( 'region', {
49+
name: 'Editor settings',
50+
} )
51+
.getByLabel( 'No Gutters' )
52+
.click();
53+
54+
// Gutters options should exist
55+
await expect(
56+
page.getByLabel( 'Gutters', { exact: true } )
57+
).not.toBeVisible();
58+
} );
59+
} );

0 commit comments

Comments
 (0)