|
1 | 1 | import Header from '@editorjs/header'; |
| 2 | +import NestedEditor, { NESTED_EDITOR_ID } from '../../support/utils/nestedEditorInstance'; |
2 | 3 |
|
3 | 4 | describe('Inline Toolbar', () => { |
4 | 5 | it('should appear aligned with left coord of selection rect', () => { |
@@ -164,4 +165,56 @@ describe('Inline Toolbar', () => { |
164 | 165 | }); |
165 | 166 | }); |
166 | 167 | }); |
| 168 | + |
| 169 | + describe('Nested Editor instance inline toolbar', () => { |
| 170 | + it('should not close inline toolbar of the nested Editor instance when clicking within that toolbar', () => { |
| 171 | + cy.createEditor({ |
| 172 | + tools: { |
| 173 | + nestedEditor: { |
| 174 | + class: NestedEditor, |
| 175 | + }, |
| 176 | + }, |
| 177 | + data: { |
| 178 | + blocks: [ |
| 179 | + { |
| 180 | + type: 'paragraph', |
| 181 | + data: { |
| 182 | + text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', |
| 183 | + }, |
| 184 | + }, |
| 185 | + { |
| 186 | + type: 'nestedEditor', |
| 187 | + data: { |
| 188 | + text: 'Nunc pellentesque, tortor nec luctus venenatis', |
| 189 | + }, |
| 190 | + }, |
| 191 | + ], |
| 192 | + }, |
| 193 | + }); |
| 194 | + |
| 195 | + cy.get(`[data-cy=${NESTED_EDITOR_ID}]`) |
| 196 | + .find('.ce-paragraph') |
| 197 | + .selectText('tortor nec luctus'); |
| 198 | + |
| 199 | + cy.get(`[data-cy=${NESTED_EDITOR_ID}]`) |
| 200 | + .find('[data-item-name=link]') |
| 201 | + .click(); |
| 202 | + |
| 203 | + // `wait()` function below is required. without it the test will always pass |
| 204 | + // because cypress types the text in the field without delay, while we need some delay (just like user) |
| 205 | + // to test the actual case that nested editor inline toolbar is still visible and not closed |
| 206 | + |
| 207 | + cy.get(`[data-cy=${NESTED_EDITOR_ID}]`) |
| 208 | + .find('.ce-inline-tool-input') |
| 209 | + .click() |
| 210 | + .wait(100) |
| 211 | + .type('https://editorjs.io'); |
| 212 | + |
| 213 | + cy.get(`[data-cy=${NESTED_EDITOR_ID}]`) |
| 214 | + .find('.ce-popover__container') |
| 215 | + .then(($toolbar) => { |
| 216 | + expect($toolbar).to.be.visible; |
| 217 | + }); |
| 218 | + }); |
| 219 | + }); |
167 | 220 | }); |
0 commit comments