import { HOT_KEY_MAP } from '../../utils/constants'; const headingNumberToWord = ['', 'one', 'two', 'three', 'four', 'five', 'six']; const isMac = Cypress.platform === 'darwin'; const modifierKey = isMac ? '{meta}' : '{ctrl}'; // eslint-disable-next-line func-style const replaceMod = str => str.replace(/mod\+/g, modifierKey).replace(/shift\+/g, '{shift}'); describe('Markdown widget hotkeys', () => { describe('hot keys', () => { before(() => { Cypress.config('defaultCommandTimeout', 4000); cy.task('setupBackend', { backend: 'test' }); }); beforeEach(() => { cy.loginAndNewPost(); cy.clearMarkdownEditorContent(); cy.focused().type('foo').setSelection('foo').as('selection'); }); after(() => { cy.task('teardownBackend', { backend: 'test' }); }); describe('bold', () => { it('pressing mod+b bolds the text', () => { cy.get('@selection') .type(replaceMod(HOT_KEY_MAP['bold'])) .confirmMarkdownEditorContent( `
foo
`, ) .type(replaceMod(HOT_KEY_MAP['bold'])); }); }); describe('italic', () => { it('pressing mod+i italicizes the text', () => { cy.get('@selection') .type(replaceMod(HOT_KEY_MAP['italic'])) .confirmMarkdownEditorContent( `foo
`, ) .type(replaceMod(HOT_KEY_MAP['italic'])); }); }); describe('strikethrough', () => { it('pressing mod+shift+s displays a strike through the text', () => { cy.get('@selection') .type(replaceMod(HOT_KEY_MAP['strikethrough'])) .confirmMarkdownEditorContent( `
foo
foo