|
| 1 | +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); |
| 2 | + |
| 3 | +test.describe( 'Row Block Filters - CSS Grid', () => { |
| 4 | + test.beforeAll( async ( { requestUtils } ) => { |
| 5 | + await requestUtils.activatePlugin( |
| 6 | + 'wp-bootstrap-blocks-test-css-grid' |
| 7 | + ); |
| 8 | + await requestUtils.activatePlugin( |
| 9 | + 'wp-bootstrap-blocks-test-row-filters' |
| 10 | + ); |
| 11 | + } ); |
| 12 | + |
| 13 | + test.afterAll( async ( { requestUtils } ) => { |
| 14 | + await requestUtils.deactivatePlugin( |
| 15 | + 'wp-bootstrap-blocks-test-css-grid' |
| 16 | + ); |
| 17 | + await requestUtils.deactivatePlugin( |
| 18 | + 'wp-bootstrap-blocks-test-row-filters' |
| 19 | + ); |
| 20 | + } ); |
| 21 | + |
| 22 | + test.beforeEach( async ( { admin, editor, page } ) => { |
| 23 | + await admin.createNewPost(); |
| 24 | + await editor.insertBlock( { |
| 25 | + name: 'wp-bootstrap-blocks/row', |
| 26 | + } ); |
| 27 | + await editor.openDocumentSettingsSidebar(); |
| 28 | + } ); |
| 29 | + |
| 30 | + test( 'wpBootstrapBlocks.row.cssGridGuttersOptions adds gutters option', async ( { |
| 31 | + page, |
| 32 | + editor, |
| 33 | + } ) => { |
| 34 | + // Disable No Gutters option to make Gutter options visible |
| 35 | + await page |
| 36 | + .getByRole( 'region', { |
| 37 | + name: 'Editor settings', |
| 38 | + } ) |
| 39 | + .getByLabel( 'No Gutters' ) |
| 40 | + .click(); |
| 41 | + |
| 42 | + // Custom gutters option should be applied |
| 43 | + await page |
| 44 | + .getByRole( 'region', { |
| 45 | + name: 'Editor settings', |
| 46 | + } ) |
| 47 | + .getByLabel( 'Gutters', { exact: true } ) |
| 48 | + .selectOption( '10rem' ); |
| 49 | + |
| 50 | + expect( await editor.getEditedPostContent() ).toMatchSnapshot( |
| 51 | + 'wpBootstrapBlocks.row.cssGridGuttersOptions-adds-gutters-option.txt' |
| 52 | + ); |
| 53 | + } ); |
| 54 | + |
| 55 | + test( 'wp_bootstrap_blocks_row_default_attributes override default attributes with CSS grid', async ( { |
| 56 | + page, |
| 57 | + editor, |
| 58 | + } ) => { |
| 59 | + // Disable No Gutters option to make Gutter options visible |
| 60 | + await page |
| 61 | + .getByRole( 'region', { |
| 62 | + name: 'Editor settings', |
| 63 | + } ) |
| 64 | + .getByLabel( 'No Gutters' ) |
| 65 | + .click(); |
| 66 | + |
| 67 | + await expect( |
| 68 | + await page |
| 69 | + .getByRole( 'region', { |
| 70 | + name: 'Editor settings', |
| 71 | + } ) |
| 72 | + .getByLabel( 'Gutters', { exact: true } ) |
| 73 | + .inputValue() |
| 74 | + ).toBe( '1rem' ); |
| 75 | + |
| 76 | + // Check if attributes are set correctly |
| 77 | + expect( await editor.getEditedPostContent() ).toMatchSnapshot( |
| 78 | + 'wp_bootstrap_blocks_row_default_attributes-override-default-attributes-with-CSS-grid.txt' |
| 79 | + ); |
| 80 | + } ); |
| 81 | +} ); |
0 commit comments