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-13 18:12:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-13 18:12:17 +0300
commit4597f7fe473d9fa622510f8967620006d4bda64e (patch)
treedafe547a51e57112ad92258f4bf992c014591a88 /spec/frontend_integration/content_editor
parent37a739daec0d7021b2af6ad03c60d37ac3461d88 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend_integration/content_editor')
-rw-r--r--spec/frontend_integration/content_editor/content_editor_integration_spec.js46
1 files changed, 43 insertions, 3 deletions
diff --git a/spec/frontend_integration/content_editor/content_editor_integration_spec.js b/spec/frontend_integration/content_editor/content_editor_integration_spec.js
index 7781a463fd6..c0c6b5e5dc8 100644
--- a/spec/frontend_integration/content_editor/content_editor_integration_spec.js
+++ b/spec/frontend_integration/content_editor/content_editor_integration_spec.js
@@ -27,6 +27,10 @@ describe('content_editor', () => {
await nextTick();
};
+ const mockRenderMarkdownResponse = (response) => {
+ renderMarkdown.mockImplementation((markdown) => (markdown ? response : null));
+ };
+
beforeEach(() => {
renderMarkdown = jest.fn();
});
@@ -34,7 +38,7 @@ describe('content_editor', () => {
describe('when loading initial content', () => {
describe('when the initial content is empty', () => {
it('still hides the loading indicator', async () => {
- renderMarkdown.mockResolvedValue('');
+ mockRenderMarkdownResponse('');
buildWrapper();
@@ -47,9 +51,11 @@ describe('content_editor', () => {
describe('when the initial content is not empty', () => {
const initialContent = '<p><strong>bold text</strong></p>';
beforeEach(async () => {
- renderMarkdown.mockResolvedValue(initialContent);
+ mockRenderMarkdownResponse(initialContent);
- buildWrapper();
+ buildWrapper({
+ markdown: '**bold text**',
+ });
await waitUntilContentIsLoaded();
});
@@ -129,4 +135,38 @@ This reference tag is a mix of letters and numbers [^footnote].
expect(wrapper.findByTestId('table-of-contents').text()).toContain('Heading 1');
expect(wrapper.findByTestId('table-of-contents').text()).toContain('Heading 2');
});
+
+ describe('when pasting content', () => {
+ const buildClipboardData = (data = {}) => ({
+ clipboardData: {
+ getData(mimeType) {
+ return data[mimeType];
+ },
+ types: Object.keys(data),
+ },
+ });
+
+ describe('when the clipboard does not contain text/html data', () => {
+ it('processes the clipboard content as markdown', async () => {
+ const processedMarkdown = '<strong>bold text</strong>';
+
+ buildWrapper();
+
+ await waitUntilContentIsLoaded();
+
+ mockRenderMarkdownResponse(processedMarkdown);
+
+ wrapper.find('[contenteditable]').trigger(
+ 'paste',
+ buildClipboardData({
+ 'text/plain': '**bold text**',
+ }),
+ );
+
+ await waitUntilContentIsLoaded();
+
+ expect(wrapper.find('[contenteditable]').html()).toContain(processedMarkdown);
+ });
+ });
+ });
});