|
| 1 | +describe('Enter key behavior on focused blocks', () => { |
| 2 | + const addBlockAndPressEnter = ({ |
| 3 | + chooserClass, |
| 4 | + label, |
| 5 | + chooserSection = 'mostUsed', |
| 6 | + selectedSelectors, |
| 7 | + }) => { |
| 8 | + // Open block chooser and pick the block |
| 9 | + cy.get('.button .block-add-button').click({ force: true }); |
| 10 | + |
| 11 | + cy.get(`.blocks-chooser .${chooserSection} .button.${chooserClass}`) |
| 12 | + .contains(label) |
| 13 | + .click({ force: true }); |
| 14 | + |
| 15 | + cy.wait(500); |
| 16 | + // press enter |
| 17 | + cy.focused().type('{enter}'); |
| 18 | + // Now we can see two slate editor |
| 19 | + cy.get('.block-editor-slate').should('have.length', 2); |
| 20 | + }; |
| 21 | + |
| 22 | + beforeEach(() => { |
| 23 | + cy.intercept('GET', `/**/*?expand*`).as('content'); |
| 24 | + cy.intercept('GET', '/**/Document').as('schema'); |
| 25 | + |
| 26 | + cy.autologin(); |
| 27 | + cy.createContent({ |
| 28 | + contentType: 'Document', |
| 29 | + contentId: 'my-page', |
| 30 | + contentTitle: 'My Page', |
| 31 | + }); |
| 32 | + |
| 33 | + cy.visit('/my-page'); |
| 34 | + cy.wait('@content'); |
| 35 | + |
| 36 | + cy.navigate('/my-page/edit'); |
| 37 | + cy.wait('@schema'); |
| 38 | + }); |
| 39 | + |
| 40 | + it('Pressing Enter on a focused Button block opens Slate editor or block chooser', () => { |
| 41 | + addBlockAndPressEnter({ |
| 42 | + chooserClass: 'button', |
| 43 | + label: 'Button', |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + it('Pressing Enter on a focused Heading block opens Slate editor or block chooser', () => { |
| 48 | + addBlockAndPressEnter({ |
| 49 | + chooserClass: 'heading', |
| 50 | + label: 'Heading', |
| 51 | + }); |
| 52 | + }); |
| 53 | + |
| 54 | + it('Pressing Enter on a focused Image block opens Slate editor or block chooser', () => { |
| 55 | + addBlockAndPressEnter({ |
| 56 | + chooserClass: 'image', |
| 57 | + label: 'Image', |
| 58 | + }); |
| 59 | + }); |
| 60 | + |
| 61 | + it('Pressing Enter on a focused Grid block opens Slate editor or block chooser', () => { |
| 62 | + addBlockAndPressEnter({ |
| 63 | + chooserClass: 'gridBlock', |
| 64 | + label: 'Grid', |
| 65 | + }); |
| 66 | + }); |
| 67 | + |
| 68 | + it('Pressing Enter on a focused Social Media block opens Slate editor or block chooser', () => { |
| 69 | + addBlockAndPressEnter({ |
| 70 | + chooserClass: 'followUsBlock', |
| 71 | + label: 'Follow Us Block', |
| 72 | + chooserSection: 'common', |
| 73 | + }); |
| 74 | + }); |
| 75 | + |
| 76 | + it('Pressing Enter on a focused Calendar block opens Slate editor or block chooser', () => { |
| 77 | + addBlockAndPressEnter({ |
| 78 | + chooserClass: 'eventCalendar', |
| 79 | + label: 'Calendar', |
| 80 | + chooserSection: 'common', |
| 81 | + }); |
| 82 | + }); |
| 83 | + |
| 84 | + it('Pressing Enter on a focused Listing block opens Slate editor or block chooser', () => { |
| 85 | + addBlockAndPressEnter({ |
| 86 | + chooserClass: 'listing', |
| 87 | + label: 'Listing', |
| 88 | + }); |
| 89 | + }); |
| 90 | + |
| 91 | + it('Pressing Enter on a focused Maps block opens Slate editor or block chooser', () => { |
| 92 | + addBlockAndPressEnter({ |
| 93 | + chooserClass: 'maps', |
| 94 | + label: 'Maps', |
| 95 | + chooserSection: 'common', |
| 96 | + }); |
| 97 | + }); |
| 98 | + |
| 99 | + it('Pressing Enter on a focused Search block opens Slate editor or block chooser', () => { |
| 100 | + addBlockAndPressEnter({ |
| 101 | + chooserClass: 'search', |
| 102 | + label: 'Search', |
| 103 | + chooserSection: 'common', |
| 104 | + }); |
| 105 | + }); |
| 106 | + |
| 107 | + it('Pressing Enter on a focused Separator block opens Slate editor or block chooser', () => { |
| 108 | + addBlockAndPressEnter({ |
| 109 | + chooserClass: 'separator', |
| 110 | + label: 'Separator', |
| 111 | + }); |
| 112 | + }); |
| 113 | + |
| 114 | + it('Pressing Enter on a focused Teaser block opens Slate editor or block chooser', () => { |
| 115 | + addBlockAndPressEnter({ |
| 116 | + chooserClass: 'teaser', |
| 117 | + label: 'Teaser', |
| 118 | + }); |
| 119 | + }); |
| 120 | + |
| 121 | + it('Pressing Enter on a focused Table of Contents block opens Slate editor or block chooser', () => { |
| 122 | + addBlockAndPressEnter({ |
| 123 | + chooserClass: 'toc', |
| 124 | + label: 'Table of Contents', |
| 125 | + chooserSection: 'common', |
| 126 | + }); |
| 127 | + }); |
| 128 | + |
| 129 | + it('Pressing Enter on a focused Carousel block opens Slate editor or block chooser', () => { |
| 130 | + addBlockAndPressEnter({ |
| 131 | + chooserClass: 'carousel', |
| 132 | + label: 'Carousel', |
| 133 | + }); |
| 134 | + }); |
| 135 | + |
| 136 | + it('Pressing Enter on a focused Logos block opens Slate editor or block chooser', () => { |
| 137 | + addBlockAndPressEnter({ |
| 138 | + chooserClass: 'logos', |
| 139 | + label: 'Logos', |
| 140 | + }); |
| 141 | + }); |
| 142 | + |
| 143 | + it('Pressing Enter on a focused Slider block opens Slate editor or block chooser', () => { |
| 144 | + addBlockAndPressEnter({ |
| 145 | + chooserClass: 'slider', |
| 146 | + label: 'Slider', |
| 147 | + chooserSection: 'common', |
| 148 | + }); |
| 149 | + }); |
| 150 | + |
| 151 | + it('Pressing Enter on a focused Banner block opens Slate editor or block chooser', () => { |
| 152 | + addBlockAndPressEnter({ |
| 153 | + chooserClass: 'banner', |
| 154 | + label: 'Banner', |
| 155 | + chooserSection: 'common', |
| 156 | + }); |
| 157 | + }); |
| 158 | + |
| 159 | + it('Pressing Enter on a focused Description block opens Slate editor or block chooser', () => { |
| 160 | + addBlockAndPressEnter({ |
| 161 | + chooserClass: 'description', |
| 162 | + label: 'Description', |
| 163 | + chooserSection: 'text', |
| 164 | + }); |
| 165 | + }); |
| 166 | + |
| 167 | + it('Pressing Enter on a focused Video block opens Slate editor or block chooser', () => { |
| 168 | + addBlockAndPressEnter({ |
| 169 | + chooserClass: 'video', |
| 170 | + label: 'Video', |
| 171 | + }); |
| 172 | + }); |
| 173 | +}); |
| 174 | + |
0 commit comments