.github
.storybook
__mocks__
cypress
fixtures
integration
common
editorial_workflow_migration_spec_github_backend_rest.js
editorial_workflow_spec_bitbucket_backend.js
editorial_workflow_spec_git-gateway_github_backend.js
editorial_workflow_spec_git-gateway_gitlab_backend.js
editorial_workflow_spec_github_backend_graphql.js
editorial_workflow_spec_github_backend_graphql_open_authoring.js
editorial_workflow_spec_github_backend_rest.js
editorial_workflow_spec_github_backend_rest_open_authoring.js
editorial_workflow_spec_gitlab_backend.js
editorial_workflow_spec_proxy_git_backend.js
editorial_workflow_spec_test_backend.js
field_validations_spec.js
i18n_editorial_workflow_spec_test_backend.js
i18n_simple_workflow_spec_proxy_fs_backend.js
markdown_widget_backspace_spec.js
markdown_widget_code_block_spec.js
markdown_widget_enter_spec.js
markdown_widget_hotkeys_spec.js
markdown_widget_link_spec.js
markdown_widget_list_spec.js
markdown_widget_marks_spec.js
markdown_widget_quote_spec.js
media_library_spec_bitbucket_backend.js
media_library_spec_bitbucket_backend_large_media.js
media_library_spec_git-gateway_github_backend_large_media.js
media_library_spec_git-gateway_gitlab_backend_large_media.js
media_library_spec_github_backend_graphql.js
media_library_spec_github_backend_rest.js
media_library_spec_gitlab_backend.js
media_library_spec_proxy_git_backend.js
media_library_spec_test_backend.js
search_suggestion_spec.js
simple_workflow_spec_bitbucket_backend.js
simple_workflow_spec_git-gateway_github_backend.js
simple_workflow_spec_git-gateway_gitlab_backend.js
simple_workflow_spec_github_backend_graphql.js
simple_workflow_spec_github_backend_rest.js
simple_workflow_spec_gitlab_backend.js
simple_workflow_spec_proxy_fs_backend.js
simple_workflow_spec_proxy_git_backend.js
simple_workflow_spec_test_backend.js
view_filters_spec.js
view_groups_spec.js
plugins
snapshots
support
utils
Readme.md
run.mjs
dev-test
functions
img
packages
scripts
website
.all-contributorsrc
.editorconfig
.eslintrc.js
.gitattributes
.gitignore
.nvmrc
.prettierignore
.prettierrc
.stylelintrc
.vale.ini
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
babel.config.js
cms.png
commitlint.config.js
cypress.json
jest.config.js
lerna.json
netlify.toml
package.json
renovate.json
setupTestFramework.js
tsconfig.json
yarn.lock
104 lines
3.1 KiB
JavaScript
104 lines
3.1 KiB
JavaScript
import '../utils/dismiss-local-backup';
|
|
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}';
|
|
const replaceMod = (str) => str.replace(/mod\+/g, modifierKey).replace(/shift\+/g, '{shift}');
|
|
|
|
describe('Markdown widget', () => {
|
|
describe('hot keys', () => {
|
|
before(() => {
|
|
Cypress.config('defaultCommandTimeout', 4000);
|
|
cy.task('setupBackend', { backend: 'test' });
|
|
cy.loginAndNewPost();
|
|
|
|
});
|
|
|
|
beforeEach(() => {
|
|
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(`
|
|
<p>
|
|
<strong>foo</strong>
|
|
</p>
|
|
`)
|
|
.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(`
|
|
<p>
|
|
<em>foo</em>
|
|
</p>
|
|
`)
|
|
.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(`
|
|
<p>
|
|
<s>foo</s>
|
|
</p>
|
|
`).type(replaceMod(HOT_KEY_MAP['strikethrough']));
|
|
});
|
|
});
|
|
|
|
describe('code', () => {
|
|
it('pressing mod+shift+c displays a code block around the text', () => {
|
|
cy.get('@selection')
|
|
.type(replaceMod(HOT_KEY_MAP['code']))
|
|
.confirmMarkdownEditorContent(`
|
|
<p>
|
|
<code>foo</code>
|
|
</p>
|
|
`).type(replaceMod(HOT_KEY_MAP['code']));
|
|
});
|
|
});
|
|
|
|
describe('link', () => {
|
|
before(() => {
|
|
cy.window().then((win) => {
|
|
cy.stub(win, 'prompt').returns('https://google.com');
|
|
});
|
|
});
|
|
it('pressing mod+k transforms the text to a link', () => {
|
|
cy.get('@selection')
|
|
.type(replaceMod(HOT_KEY_MAP['link']))
|
|
.confirmMarkdownEditorContent('<p><a>foo</a></p>')
|
|
.type(replaceMod(HOT_KEY_MAP['link']));
|
|
});
|
|
});
|
|
|
|
describe('headings', () => {
|
|
for (let i = 1; i <= 6; i++) {
|
|
it(`pressing mod+${i} transforms the text to a heading`, () => {
|
|
cy.get('@selection')
|
|
.type(replaceMod(HOT_KEY_MAP[`heading-${headingNumberToWord[i]}`]))
|
|
.confirmMarkdownEditorContent(`<h${i}>foo</h${i}>`)
|
|
.type(replaceMod(HOT_KEY_MAP[`heading-${headingNumberToWord[i]}`]))
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|