Commit 345c156e authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch 'ps-remove-refs-to-markdown-processing-examples' into 'master'

Remove refs to markdown_processing_examples in unit tests

See merge request gitlab-org/gitlab!68883
parents beb4a149 0e42502a
...@@ -7,9 +7,17 @@ import Image from '~/content_editor/extensions/image'; ...@@ -7,9 +7,17 @@ import Image from '~/content_editor/extensions/image';
import Link from '~/content_editor/extensions/link'; import Link from '~/content_editor/extensions/link';
import Loading from '~/content_editor/extensions/loading'; import Loading from '~/content_editor/extensions/loading';
import httpStatus from '~/lib/utils/http_status'; import httpStatus from '~/lib/utils/http_status';
import { loadMarkdownApiResult } from '../markdown_processing_examples';
import { createTestEditor, createDocBuilder } from '../test_utils'; import { createTestEditor, createDocBuilder } from '../test_utils';
const PROJECT_WIKI_ATTACHMENT_IMAGE_HTML = `<p data-sourcepos="1:1-1:27" dir="auto">
<a class="no-attachment-icon" href="/group1/project1/-/wikis/test-file.png" target="_blank" rel="noopener noreferrer" data-canonical-src="test-file.png">
<img alt="test-file" class="lazy" data-src="/group1/project1/-/wikis/test-file.png" data-canonical-src="test-file.png">
</a>
</p>`;
const PROJECT_WIKI_ATTACHMENT_LINK_HTML = `<p data-sourcepos="1:1-1:26" dir="auto">
<a href="/group1/project1/-/wikis/test-file.zip" data-canonical-src="test-file.zip">test-file</a>
</p>`;
describe('content_editor/extensions/attachment', () => { describe('content_editor/extensions/attachment', () => {
let tiptapEditor; let tiptapEditor;
let eq; let eq;
...@@ -76,7 +84,7 @@ describe('content_editor/extensions/attachment', () => { ...@@ -76,7 +84,7 @@ describe('content_editor/extensions/attachment', () => {
const base64EncodedFile = 'data:image/png;base64,Zm9v'; const base64EncodedFile = 'data:image/png;base64,Zm9v';
beforeEach(() => { beforeEach(() => {
renderMarkdown.mockResolvedValue(loadMarkdownApiResult('project_wiki_attachment_image')); renderMarkdown.mockResolvedValue(PROJECT_WIKI_ATTACHMENT_IMAGE_HTML);
}); });
describe('when uploading succeeds', () => { describe('when uploading succeeds', () => {
...@@ -151,7 +159,7 @@ describe('content_editor/extensions/attachment', () => { ...@@ -151,7 +159,7 @@ describe('content_editor/extensions/attachment', () => {
}); });
describe('when the file has a zip (or any other attachment) mime type', () => { describe('when the file has a zip (or any other attachment) mime type', () => {
const markdownApiResult = loadMarkdownApiResult('project_wiki_attachment_link'); const markdownApiResult = PROJECT_WIKI_ATTACHMENT_LINK_HTML;
beforeEach(() => { beforeEach(() => {
renderMarkdown.mockResolvedValue(markdownApiResult); renderMarkdown.mockResolvedValue(markdownApiResult);
......
import CodeBlockHighlight from '~/content_editor/extensions/code_block_highlight'; import CodeBlockHighlight from '~/content_editor/extensions/code_block_highlight';
import { loadMarkdownApiResult } from '../markdown_processing_examples';
import { createTestEditor } from '../test_utils'; import { createTestEditor } from '../test_utils';
const CODE_BLOCK_HTML = `<pre class="code highlight js-syntax-highlight language-javascript" lang="javascript" v-pre="true">
<code>
<span id="LC1" class="line" lang="javascript">
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="dl">'</span><span class="s1">hello world</span><span class="dl">'</span><span class="p">)</span>
</span>
</code>
</pre>`;
describe('content_editor/extensions/code_block_highlight', () => { describe('content_editor/extensions/code_block_highlight', () => {
let codeBlockHtmlFixture;
let parsedCodeBlockHtmlFixture; let parsedCodeBlockHtmlFixture;
let tiptapEditor; let tiptapEditor;
...@@ -12,10 +18,9 @@ describe('content_editor/extensions/code_block_highlight', () => { ...@@ -12,10 +18,9 @@ describe('content_editor/extensions/code_block_highlight', () => {
beforeEach(() => { beforeEach(() => {
tiptapEditor = createTestEditor({ extensions: [CodeBlockHighlight] }); tiptapEditor = createTestEditor({ extensions: [CodeBlockHighlight] });
codeBlockHtmlFixture = loadMarkdownApiResult('code_block'); parsedCodeBlockHtmlFixture = parseHTML(CODE_BLOCK_HTML);
parsedCodeBlockHtmlFixture = parseHTML(codeBlockHtmlFixture);
tiptapEditor.commands.setContent(codeBlockHtmlFixture); tiptapEditor.commands.setContent(CODE_BLOCK_HTML);
}); });
it('extracts language and params attributes from Markdown API output', () => { it('extracts language and params attributes from Markdown API output', () => {
......
...@@ -4,9 +4,20 @@ import ListItem from '~/content_editor/extensions/list_item'; ...@@ -4,9 +4,20 @@ import ListItem from '~/content_editor/extensions/list_item';
import Paragraph from '~/content_editor/extensions/paragraph'; import Paragraph from '~/content_editor/extensions/paragraph';
import markdownSerializer from '~/content_editor/services/markdown_serializer'; import markdownSerializer from '~/content_editor/services/markdown_serializer';
import { getMarkdownSource } from '~/content_editor/services/markdown_sourcemap'; import { getMarkdownSource } from '~/content_editor/services/markdown_sourcemap';
import { loadMarkdownApiResult, loadMarkdownApiExample } from '../markdown_processing_examples';
import { createTestEditor, createDocBuilder } from '../test_utils'; import { createTestEditor, createDocBuilder } from '../test_utils';
const BULLET_LIST_MARKDOWN = `+ list item 1
+ list item 2
- embedded list item 3`;
const BULLET_LIST_HTML = `<ul data-sourcepos="1:1-3:24" dir="auto">
<li data-sourcepos="1:1-1:13">list item 1</li>
<li data-sourcepos="2:1-3:24">list item 2
<ul data-sourcepos="3:3-3:24">
<li data-sourcepos="3:3-3:24">embedded list item 3</li>
</ul>
</li>
</ul>`;
const SourcemapExtension = Extension.create({ const SourcemapExtension = Extension.create({
// lets add `source` attribute to every element using `getMarkdownSource` // lets add `source` attribute to every element using `getMarkdownSource`
addGlobalAttributes() { addGlobalAttributes() {
...@@ -44,11 +55,11 @@ const { ...@@ -44,11 +55,11 @@ const {
describe('content_editor/services/markdown_sourcemap', () => { describe('content_editor/services/markdown_sourcemap', () => {
it('gets markdown source for a rendered HTML element', async () => { it('gets markdown source for a rendered HTML element', async () => {
const deserialized = await markdownSerializer({ const deserialized = await markdownSerializer({
render: () => loadMarkdownApiResult('bullet_list_style_3'), render: () => BULLET_LIST_HTML,
serializerConfig: {}, serializerConfig: {},
}).deserialize({ }).deserialize({
schema: tiptapEditor.schema, schema: tiptapEditor.schema,
content: loadMarkdownApiExample('bullet_list_style_3'), content: BULLET_LIST_MARKDOWN,
}); });
const expected = doc( const expected = doc(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment