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-12-27 21:09:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-27 21:09:45 +0300
commit84f003a4cbf0d57afdaae8cc4f28af549b34ff33 (patch)
tree057e9740a8f96d8b6c7b19ebaba6ce1c074db045 /spec/frontend/content_editor
parenteedc7b50be0121effa4ea03862c045cf6114c944 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/content_editor')
-rw-r--r--spec/frontend/content_editor/markdown_processing_spec.js16
-rw-r--r--spec/frontend/content_editor/markdown_processing_spec_helper.js92
2 files changed, 0 insertions, 108 deletions
diff --git a/spec/frontend/content_editor/markdown_processing_spec.js b/spec/frontend/content_editor/markdown_processing_spec.js
deleted file mode 100644
index 3930f47289a..00000000000
--- a/spec/frontend/content_editor/markdown_processing_spec.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import path from 'path';
-import { describeMarkdownProcessing } from 'jest/content_editor/markdown_processing_spec_helper';
-
-jest.mock('~/emoji');
-
-const markdownYamlPath = path.join(
- __dirname,
- '..',
- '..',
- 'fixtures',
- 'markdown',
- 'markdown_golden_master_examples.yml',
-);
-
-// See spec/fixtures/markdown/markdown_golden_master_examples.yml for documentation on how this spec works.
-describeMarkdownProcessing('CE markdown processing in ContentEditor', markdownYamlPath);
diff --git a/spec/frontend/content_editor/markdown_processing_spec_helper.js b/spec/frontend/content_editor/markdown_processing_spec_helper.js
deleted file mode 100644
index 6f10f294fb0..00000000000
--- a/spec/frontend/content_editor/markdown_processing_spec_helper.js
+++ /dev/null
@@ -1,92 +0,0 @@
-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(',') || [],
-);
-
-const includeExample = ({ name }) => {
- const focusedMarkdownExamples = getFocusedMarkdownExamples();
- if (!focusedMarkdownExamples.length) {
- return true;
- }
- return focusedMarkdownExamples.includes(name);
-};
-
-const getPendingReason = (pendingStringOrObject) => {
- if (!pendingStringOrObject) {
- return null;
- }
- if (typeof pendingStringOrObject === 'string') {
- return pendingStringOrObject;
- }
- if (pendingStringOrObject.frontend) {
- return pendingStringOrObject.frontend;
- }
-
- return null;
-};
-
-const loadMarkdownApiExamples = (markdownYamlPath) => {
- const apiMarkdownYamlText = fs.readFileSync(markdownYamlPath);
- const apiMarkdownExampleObjects = jsYaml.safeLoad(apiMarkdownYamlText);
-
- return apiMarkdownExampleObjects
- .filter(includeExample)
- .map(({ name, pending, markdown, html }) => [
- name,
- { pendingReason: getPendingReason(pending), markdown, html },
- ]);
-};
-
-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,
- });
-
- await contentEditor.setSerializedContent(markdown);
-
- // This serializes the ContentEditor document, which was based on the HTML, to markdown
- const serializedContent = contentEditor.getSerializedContent();
-
- // 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
-//
-// This is used to dynamically generate examples (for both CE and EE) to ensure
-// we generate same markdown that was provided to Markdown API.
-//
-// eslint-disable-next-line jest/no-export
-export const describeMarkdownProcessing = (description, markdownYamlPath) => {
- const examples = loadMarkdownApiExamples(markdownYamlPath);
-
- describe(description, () => {
- describe.each(examples)('%s', (name, { pendingReason, ...example }) => {
- const exampleName = 'correctly serializes HTML to markdown';
- if (pendingReason) {
- it.todo(`${exampleName}: ${pendingReason}`);
- return;
- }
-
- it(`${exampleName}`, async () => {
- await testSerializesHtmlToMarkdownForElement(example);
- });
- });
- });
-};