Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-29 15:08:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-29 15:08:49 +0300
commit9bf40d9fdc79fb09f67ac2b571467908758777ad (patch)
treed4f9eb07b6d4e37d79de2f8e4036fdf0bbe3d7a9 /spec/frontend/content_editor
parent946b1e2fe93357d596f37d3978cf682b8b837925 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/content_editor')
-rw-r--r--spec/frontend/content_editor/extensions/heading_spec.js54
-rw-r--r--spec/frontend/content_editor/markdown_processing_spec_helper.js10
-rw-r--r--spec/frontend/content_editor/services/track_input_rules_and_shortcuts_spec.js2
3 files changed, 65 insertions, 1 deletions
diff --git a/spec/frontend/content_editor/extensions/heading_spec.js b/spec/frontend/content_editor/extensions/heading_spec.js
new file mode 100644
index 00000000000..2fa25e03cdc
--- /dev/null
+++ b/spec/frontend/content_editor/extensions/heading_spec.js
@@ -0,0 +1,54 @@
+import Heading from '~/content_editor/extensions/heading';
+import { createTestEditor, createDocBuilder, triggerNodeInputRule } from '../test_utils';
+
+describe('content_editor/extensions/heading', () => {
+ let tiptapEditor;
+ let doc;
+ let p;
+ let heading;
+
+ beforeEach(() => {
+ tiptapEditor = createTestEditor({ extensions: [Heading] });
+ ({
+ builders: { doc, p, heading },
+ } = createDocBuilder({
+ tiptapEditor,
+ names: {
+ heading: { nodeType: Heading.name },
+ },
+ }));
+ });
+
+ describe('when typing a valid heading input rule', () => {
+ it.each`
+ level | inputRuleText
+ ${1} | ${'# '}
+ ${2} | ${'## '}
+ ${3} | ${'### '}
+ ${4} | ${'#### '}
+ ${5} | ${'##### '}
+ ${6} | ${'###### '}
+ `('inserts a heading node for $inputRuleText', ({ level, inputRuleText }) => {
+ const expectedDoc = doc(heading({ level }));
+
+ triggerNodeInputRule({ tiptapEditor, inputRuleText });
+
+ expect(tiptapEditor.getJSON()).toEqual(expectedDoc.toJSON());
+ });
+ });
+
+ describe('when typing a invalid heading input rule', () => {
+ it.each`
+ inputRuleText
+ ${'#hi'}
+ ${'#\n'}
+ `('does not insert a heading node for $inputRuleText', ({ inputRuleText }) => {
+ const expectedDoc = doc(p());
+
+ triggerNodeInputRule({ tiptapEditor, inputRuleText });
+
+ // no change to the document
+ expect(tiptapEditor.getJSON()).toEqual(expectedDoc.toJSON());
+ });
+ });
+});
diff --git a/spec/frontend/content_editor/markdown_processing_spec_helper.js b/spec/frontend/content_editor/markdown_processing_spec_helper.js
index 228d009e42c..38d384df235 100644
--- a/spec/frontend/content_editor/markdown_processing_spec_helper.js
+++ b/spec/frontend/content_editor/markdown_processing_spec_helper.js
@@ -1,7 +1,10 @@
import fs from 'fs';
import jsYaml from 'js-yaml';
import { memoize } from 'lodash';
+import MockAdapter from 'axios-mock-adapter';
+import axios from 'axios';
import { createContentEditor } from '~/content_editor';
+import httpStatus from '~/lib/utils/http_status';
const getFocusedMarkdownExamples = memoize(
() => process.env.FOCUSED_MARKDOWN_EXAMPLES?.split(',') || [],
@@ -42,6 +45,11 @@ const loadMarkdownApiExamples = (markdownYamlPath) => {
};
const testSerializesHtmlToMarkdownForElement = async ({ markdown, html }) => {
+ const mock = new MockAdapter(axios);
+
+ // Ignore any API requests from the suggestions plugin
+ mock.onGet().reply(httpStatus.OK, []);
+
const contentEditor = createContentEditor({
// Overwrite renderMarkdown to always return this specific html
renderMarkdown: () => html,
@@ -55,6 +63,8 @@ const testSerializesHtmlToMarkdownForElement = async ({ markdown, html }) => {
// Assert that the markdown we ended up with after sending it through all the ContentEditor
// plumbing matches the original markdown from the YAML.
expect(serializedContent.trim()).toBe(markdown.trim());
+
+ mock.restore();
};
// describeMarkdownProcesssing
diff --git a/spec/frontend/content_editor/services/track_input_rules_and_shortcuts_spec.js b/spec/frontend/content_editor/services/track_input_rules_and_shortcuts_spec.js
index 459780cc7cf..8c1a3831a74 100644
--- a/spec/frontend/content_editor/services/track_input_rules_and_shortcuts_spec.js
+++ b/spec/frontend/content_editor/services/track_input_rules_and_shortcuts_spec.js
@@ -44,7 +44,7 @@ describe('content_editor/services/track_input_rules_and_shortcuts', () => {
describe('when creating a heading using an keyboard shortcut', () => {
it('sends a tracking event indicating that a heading was created using an input rule', async () => {
- const shortcuts = Heading.config.addKeyboardShortcuts.call(Heading);
+ const shortcuts = Heading.parent.config.addKeyboardShortcuts.call(Heading);
const [firstShortcut] = Object.keys(shortcuts);
const nodeName = Heading.name;