|
| 1 | +/// <reference types="Cypress" /> |
| 2 | +import { testBlockTransform } from '../../support/row/transform-tests'; |
| 3 | +import { getAllBlocks } from 'cypress-wp-test-utils'; |
| 4 | + |
| 5 | +context( 'Row Block Transforms', () => { |
| 6 | + describe( 'Custom template enabled', () => { |
| 7 | + beforeEach( () => { |
| 8 | + cy.loginUser(); |
| 9 | + cy.createNewPost(); |
| 10 | + } ); |
| 11 | + |
| 12 | + it( 'Should be possible to transform 2 blocks to row block', () => { |
| 13 | + cy.insertBlock( 'Heading' ); |
| 14 | + cy.insertBlock( 'Heading' ); |
| 15 | + |
| 16 | + testBlockTransform(); |
| 17 | + cy.postContentMatchesSnapshot(); |
| 18 | + } ); |
| 19 | + |
| 20 | + it( 'Should be possible to transform 3 blocks to row block', () => { |
| 21 | + cy.insertBlock( 'Heading' ); |
| 22 | + cy.insertBlock( 'Heading' ); |
| 23 | + cy.insertBlock( 'Heading' ); |
| 24 | + |
| 25 | + testBlockTransform(); |
| 26 | + cy.postContentMatchesSnapshot(); |
| 27 | + } ); |
| 28 | + |
| 29 | + it( 'Should be possible to transform 4 blocks to row block', () => { |
| 30 | + cy.insertBlock( 'Heading' ); |
| 31 | + cy.insertBlock( 'Heading' ); |
| 32 | + cy.insertBlock( 'Heading' ); |
| 33 | + cy.insertBlock( 'Heading' ); |
| 34 | + |
| 35 | + testBlockTransform(); |
| 36 | + cy.postContentMatchesSnapshot(); |
| 37 | + } ); |
| 38 | + |
| 39 | + it( 'Columns should not be smaller than 3', () => { |
| 40 | + cy.insertBlock( 'Heading' ); |
| 41 | + cy.insertBlock( 'Heading' ); |
| 42 | + cy.insertBlock( 'Heading' ); |
| 43 | + cy.insertBlock( 'Heading' ); |
| 44 | + cy.insertBlock( 'Heading' ); |
| 45 | + |
| 46 | + testBlockTransform(); |
| 47 | + cy.postContentMatchesSnapshot(); |
| 48 | + } ); |
| 49 | + } ); |
| 50 | + |
| 51 | + describe( 'Custom template disabled', () => { |
| 52 | + before( () => { |
| 53 | + cy.loginUser(); |
| 54 | + cy.activatePlugin( 'wp-bootstrap-blocks-test-row-filters' ); |
| 55 | + } ); |
| 56 | + |
| 57 | + after( () => { |
| 58 | + cy.loginUser(); |
| 59 | + cy.deactivatePlugin( 'wp-bootstrap-blocks-test-row-filters' ); |
| 60 | + } ); |
| 61 | + |
| 62 | + beforeEach( () => { |
| 63 | + cy.loginUser(); |
| 64 | + cy.createNewPost(); |
| 65 | + } ); |
| 66 | + |
| 67 | + it( 'Should not be possible to transform blocks if custom template is disabled', () => { |
| 68 | + cy.insertBlock( 'Heading' ); |
| 69 | + cy.insertBlock( 'Heading' ); |
| 70 | + |
| 71 | + return getAllBlocks().then( ( blocks ) => { |
| 72 | + const firstBlockId = blocks[ 0 ].clientId; |
| 73 | + const lastBlockId = blocks[ blocks.length - 1 ].clientId; |
| 74 | + |
| 75 | + return cy |
| 76 | + .window() |
| 77 | + .then( ( window ) => { |
| 78 | + return window.wp.data |
| 79 | + .dispatch( 'core/block-editor' ) |
| 80 | + .multiSelect( firstBlockId, lastBlockId ); |
| 81 | + } ) |
| 82 | + .then( () => { |
| 83 | + // Transform block |
| 84 | + cy.clickBlockToolbarButton( 'Heading' ); |
| 85 | + cy.get( |
| 86 | + '.editor-block-list-item-wp-bootstrap-blocks-row' |
| 87 | + ).should( 'not.exist' ); |
| 88 | + } ); |
| 89 | + } ); |
| 90 | + } ); |
| 91 | + } ); |
| 92 | +} ); |
0 commit comments