diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/frontend_integration/content_editor/content_editor_integration_spec.js | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/frontend_integration/content_editor/content_editor_integration_spec.js')
-rw-r--r-- | spec/frontend_integration/content_editor/content_editor_integration_spec.js | 63 |
1 files changed, 63 insertions, 0 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 new file mode 100644 index 00000000000..1b45c0d43a3 --- /dev/null +++ b/spec/frontend_integration/content_editor/content_editor_integration_spec.js @@ -0,0 +1,63 @@ +import { nextTick } from 'vue'; +import { mountExtended } from 'helpers/vue_test_utils_helper'; +import { ContentEditor } from '~/content_editor'; + +/** + * This spec exercises some workflows in the Content Editor without mocking + * any component. + * + */ +describe('content_editor', () => { + let wrapper; + let renderMarkdown; + let contentEditorService; + + const buildWrapper = () => { + renderMarkdown = jest.fn(); + wrapper = mountExtended(ContentEditor, { + propsData: { + renderMarkdown, + uploadsPath: '/', + }, + listeners: { + initialized(contentEditor) { + contentEditorService = contentEditor; + }, + }, + }); + }; + + describe('when loading initial content', () => { + describe('when the initial content is empty', () => { + it('still hides the loading indicator', async () => { + buildWrapper(); + + renderMarkdown.mockResolvedValue(''); + + await contentEditorService.setSerializedContent(''); + await nextTick(); + + expect(wrapper.findByTestId('content-editor-loading-indicator').exists()).toBe(false); + }); + }); + + describe('when the initial content is not empty', () => { + const initialContent = '<p><strong>bold text</strong></p>'; + beforeEach(async () => { + buildWrapper(); + + renderMarkdown.mockResolvedValue(initialContent); + + await contentEditorService.setSerializedContent('**bold text**'); + await nextTick(); + }); + it('hides the loading indicator', async () => { + expect(wrapper.findByTestId('content-editor-loading-indicator').exists()).toBe(false); + }); + + it('displays the initial content', async () => { + expect(wrapper.html()).toContain(initialContent); + }); + }); + }); +}); |