import '../utils/dismiss-local-backup'; describe('Markdown widget', () => { describe('quote block', () => { before(() => { Cypress.config('defaultCommandTimeout', 4000); cy.task('setupBackend', { backend: 'test' }); cy.loginAndNewPost(); }); beforeEach(() => { cy.clearMarkdownEditorContent(); }); after(() => { cy.task('teardownBackend', { backend: 'test' }); }); describe('toggle quote', () => { it('toggles empty quote block on and off in empty editor', () => { cy.clickQuoteButton() .confirmMarkdownEditorContent(`

`) .clickQuoteButton() .confirmMarkdownEditorContent(`

`); }); it('toggles empty quote block on and off for current block', () => { cy.focused() .type('foo') .clickQuoteButton() .confirmMarkdownEditorContent(`

foo

`) .clickQuoteButton() .confirmMarkdownEditorContent(`

foo

`); }); it('toggles entire quote block without expanded selection', () => { cy.clickQuoteButton() .type('foo') .enter() .type('bar') .clickQuoteButton() .confirmMarkdownEditorContent(`

foo

bar

`); }); it('toggles entire quote block with complex content', () => { cy.clickQuoteButton() .clickUnorderedListButton() .clickHeadingOneButton() .type('foo') .enter({ times: 3 }) .clickQuoteButton() .confirmMarkdownEditorContent(`

`); }); it('toggles empty quote block on and off for selected blocks', () => { cy.focused() .type('foo') .enter() .type('bar') .setSelection('foo', 'bar') .clickQuoteButton() .confirmMarkdownEditorContent(`

foo

bar

`) .clickQuoteButton() .confirmMarkdownEditorContent(`

foo

bar

`) .clickQuoteButton() .confirmMarkdownEditorContent(`

foo

bar

`); }); it('toggles empty quote block on and off for partially selected blocks', () => { cy.focused() .type('foo') .enter() .type('bar') .setSelection('oo', 'ba') .clickQuoteButton() .confirmMarkdownEditorContent(`

foo

bar

`) .clickQuoteButton() .confirmMarkdownEditorContent(`

foo

bar

`) .clickQuoteButton() .confirmMarkdownEditorContent(`

foo

bar

`); }); it('toggles quote block on and off for multiple selected list items', () => { cy.focused() .clickUnorderedListButton() .type('foo') .enter({ times: 2 }) .type('bar') .setSelection('foo', 'bar') .clickQuoteButton() .confirmMarkdownEditorContent(`
`) .clickQuoteButton() .confirmMarkdownEditorContent(` `) .setCursorAfter('bar') .enter({ times: 2 }) .type('baz') .setSelection('bar', 'baz') .clickQuoteButton() .confirmMarkdownEditorContent(`
`) }); it('creates new quote block if parent is not a quote, can deeply nest', () => { cy.clickQuoteButton() .clickUnorderedListButton() .clickQuoteButton() .clickUnorderedListButton() .clickQuoteButton() .clickUnorderedListButton() .clickQuoteButton() .type('foo') .enter({ times: 10 }) .type('bar') .confirmMarkdownEditorContent(`

bar

`) .backspace({ times: 12 }) }); }); describe('backspace inside quote', () => { it('joins two paragraphs', () => { cy.clickQuoteButton() .type('foo') .enter() .type('bar') .setCursorBefore('bar') .backspace() .confirmMarkdownEditorContent(`

foobar

`); }); it('joins quote with previous quote', () => { cy.clickQuoteButton() .type('foo') .enter({ times: 2 }) .clickQuoteButton() .type('bar') .confirmMarkdownEditorContent(`

foo

bar

`) .setCursorBefore('bar') .backspace() .confirmMarkdownEditorContent(`

foo

bar

`); }); it('removes first block from quote when focused at first block at start', () => { cy.clickQuoteButton() .type('foo') .enter() .type('bar') .setCursorBefore('foo') .backspace() .confirmMarkdownEditorContent(`

foo

bar

`) }); }); describe('enter inside quote', () => { it('creates new block inside quote', () => { cy.clickQuoteButton() .type('foo') .enter() .confirmMarkdownEditorContent(`

foo

`) .type('bar') .setCursorAfter('ba') .enter() .confirmMarkdownEditorContent(`

foo

ba

r

`); }); it('creates new block after quote from empty last block', () => { cy.clickQuoteButton() .type('foo') .enter() .enter() .confirmMarkdownEditorContent(`

foo

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