Skip to content

Commit

Permalink
migrate row block css grid e2e tests to playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
tschortsch committed Nov 19, 2023
1 parent 7145fcd commit d6063ef
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 88 deletions.
34 changes: 0 additions & 34 deletions cypress/e2e/row/row-bootstrap-v4.cy.js

This file was deleted.

54 changes: 0 additions & 54 deletions cypress/e2e/row/row-css-grid.cy.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:wp-bootstrap-blocks/row {"cssGridGutters":"2rem"} -->
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":6} /-->

<!-- wp:wp-bootstrap-blocks/column {"sizeMd":6} /-->
<!-- /wp:wp-bootstrap-blocks/row -->
35 changes: 35 additions & 0 deletions playwright/e2e/row/row-bootstrap-v4.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Row Block - Bootstrap 4', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activatePlugin(
'wp-bootstrap-blocks-test-bootstrap-v4'
);
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.deactivatePlugin(
'wp-bootstrap-blocks-test-bootstrap-v4'
);
} );

test.beforeEach( async ( { admin, editor, page } ) => {
await admin.createNewPost();
await editor.insertBlock( {
name: 'wp-bootstrap-blocks/row',
} );
await editor.openDocumentSettingsSidebar();
} );

test( 'Bootstrap 5 options are not displayed if run with Bootstrap 4', async ( {
page,
} ) => {
// Horizontal Gutters options should not exist
await expect(
page.getByLabel( 'Horizontal Gutters' )
).not.toBeVisible();

// Vertical Gutters options should not exist
await expect( page.getByLabel( 'Vertical Gutters' ) ).not.toBeVisible();
} );
} );
59 changes: 59 additions & 0 deletions playwright/e2e/row/row-css-grid.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Row Block - CSS Grid', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activatePlugin(
'wp-bootstrap-blocks-test-css-grid'
);
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.deactivatePlugin(
'wp-bootstrap-blocks-test-css-grid'
);
} );

test.beforeEach( async ( { admin, editor, page } ) => {
await admin.createNewPost();
await editor.insertBlock( {
name: 'wp-bootstrap-blocks/row',
} );
await editor.openDocumentSettingsSidebar();
} );

test( 'CSS Grid options are shown', async ( { page } ) => {
// Gutters options should exist
await expect(
page.getByLabel( 'Gutters', { exact: true } )
).toBeVisible();
} );

test( 'Change gutter size', async ( { page, editor } ) => {
// Change gutters
await page
.getByLabel( 'Gutters', { exact: true } )
.selectOption( '2rem' );

expect( await editor.getEditedPostContent() ).toMatchSnapshot(
'change-gutter-size.txt'
);
} );

test( 'Hide gutter options when no gutters is checked', async ( {
page,
editor,
} ) => {
// Enable no gutters option
await page
.getByRole( 'region', {
name: 'Editor settings',
} )
.getByLabel( 'No Gutters' )
.click();

// Gutters options should exist
await expect(
page.getByLabel( 'Gutters', { exact: true } )
).not.toBeVisible();
} );
} );

0 comments on commit d6063ef

Please sign in to comment.