import '../utils/dismiss-local-backup'; describe('Markdown widget breaks', () => { before(() => { Cypress.config('defaultCommandTimeout', 4000); cy.task('setupBackend', { backend: 'test' }); cy.loginAndNewPost(); }); beforeEach(() => { cy.clearMarkdownEditorContent(); }); after(() => { cy.task('teardownBackend', { backend: 'test' }); }); describe('pressing enter', () => { it('creates new default block from empty block', () => { cy.focused() .enter() .confirmMarkdownEditorContent(`

`); }); it('creates new default block when selection collapsed at end of block', () => { cy.focused() .type('foo') .enter() .confirmMarkdownEditorContent(`

foo

`); }); it('creates new default block when selection collapsed at end of non-default block', () => { cy.clickHeadingOneButton() .type('foo') .enter() .confirmMarkdownEditorContent(`

foo

`); }); it('creates new default block when selection collapsed in empty non-default block', () => { cy.clickHeadingOneButton() .enter() .confirmMarkdownEditorContent(`

`); }); it('splits block into two same-type blocks when collapsed selection at block start', () => { cy.clickHeadingOneButton() .type('foo') .setCursorBefore('foo') .enter() .confirmMarkdownEditorContent(`

foo

`); }); it('splits block into two same-type blocks when collapsed in middle of selection at block start', () => { cy.clickHeadingOneButton() .type('foo') .setCursorBefore('oo') .enter() .confirmMarkdownEditorContent(`

f

oo

`); }); it('deletes selected content and splits to same-type block when selection is expanded', () => { cy.clickHeadingOneButton() .type('foo bar') .setSelection('o b') .enter() .confirmMarkdownEditorContent(`

fo

ar

`); }); }); describe('pressing shift+enter', () => { it('creates line break', () => { cy.focused() .enter({ shift: true }) .confirmMarkdownEditorContent(`


`); }); it('creates consecutive line break', () => { cy.focused() .enter({ shift: true, times: 4 }) .confirmMarkdownEditorContent(`





`); }); }); });