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: 2 }) // First Enter creates new list item. Second Enter turns that list item into a default block. .clickQuoteButton() // Unwrap the quote block. .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() .type('bar') .setSelection('foo', 'bar') .clickQuoteButton() .confirmMarkdownEditorContent(`
`) .clickQuoteButton() .confirmMarkdownEditorContent(` `) .setCursorAfter('bar') .enter() .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') // Content should contains 4
tags and 3