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(`
`) .clickQuoteButton() .confirmMarkdownEditorContent(`foo
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(``) .clickQuoteButton() .confirmMarkdownEditorContent(`foo
bar
foo
bar
`) .clickQuoteButton() .confirmMarkdownEditorContent(``); }); 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
foo
bar
`) .clickQuoteButton() .confirmMarkdownEditorContent(``); }); 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(`foo
bar
`) .clickQuoteButton() .confirmMarkdownEditorContent(`
foo
bar
foo
bar
foo
`) }); 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
baz
`) .backspace({ times: 12 }) }); }); describe('backspace inside quote', () => { it('joins two paragraphs', () => { cy.clickQuoteButton() .type('foo') .enter() .type('bar') .setCursorBefore('bar') .backspace() .confirmMarkdownEditorContent(`
foo
bar
`); }); it('joins quote with previous quote', () => { cy.clickQuoteButton() .type('foo') .enter({ times: 2 }) .clickQuoteButton() .type('bar') .confirmMarkdownEditorContent(`foobar
foo
`) .setCursorBefore('bar') .backspace() .confirmMarkdownEditorContent(`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
foo
`) }); }); describe('enter inside quote', () => { it('creates new block inside quote', () => { cy.clickQuoteButton() .type('foo') .enter() .confirmMarkdownEditorContent(`bar
`) .type('bar') .setCursorAfter('ba') .enter() .confirmMarkdownEditorContent(`foo
`); }); it('creates new block after quote from empty last block', () => { cy.clickQuoteButton() .type('foo') .enter() .enter() .confirmMarkdownEditorContent(`foo
ba
r
`) }); }); }); });foo