diff options
Diffstat (limited to 'spec/frontend/content_editor/components/bubble_menus/link_bubble_menu_spec.js')
-rw-r--r-- | spec/frontend/content_editor/components/bubble_menus/link_bubble_menu_spec.js | 63 |
1 files changed, 3 insertions, 60 deletions
diff --git a/spec/frontend/content_editor/components/bubble_menus/link_bubble_menu_spec.js b/spec/frontend/content_editor/components/bubble_menus/link_bubble_menu_spec.js index eb5a3b61591..2a8a1b00692 100644 --- a/spec/frontend/content_editor/components/bubble_menus/link_bubble_menu_spec.js +++ b/spec/frontend/content_editor/components/bubble_menus/link_bubble_menu_spec.js @@ -59,13 +59,13 @@ describe('content_editor/components/bubble_menus/link_bubble_menu', () => { expect(wrapper.findByTestId('remove-link').exists()).toBe(exist); }; - beforeEach(async () => { + beforeEach(() => { buildEditor(); tiptapEditor .chain() .insertContent( - 'Download <a href="/path/to/project/-/wikis/uploads/my_file.pdf" data-canonical-src="uploads/my_file.pdf" title="Click here to download">PDF File</a>', + 'Download <a href="/path/to/project/-/wikis/uploads/my_file.pdf" data-canonical-src="uploads/my_file.pdf">PDF File</a>', ) .setTextSelection(14) // put cursor in the middle of the link .run(); @@ -84,7 +84,6 @@ describe('content_editor/components/bubble_menus/link_bubble_menu', () => { expect.objectContaining({ href: '/path/to/project/-/wikis/uploads/my_file.pdf', 'aria-label': 'uploads/my_file.pdf', - title: 'uploads/my_file.pdf', target: '_blank', }), ); @@ -181,52 +180,17 @@ describe('content_editor/components/bubble_menus/link_bubble_menu', () => { }); }); - describe('for a placeholder link', () => { - beforeEach(async () => { - tiptapEditor - .chain() - .clearContent() - .insertContent('Dummy link') - .selectAll() - .setLink({ href: '' }) - .setTextSelection(4) - .run(); - - await buildWrapperAndDisplayMenu(); - }); - - it('directly opens the edit form for a placeholder link', async () => { - expectLinkButtonsToExist(false); - - expect(wrapper.findComponent(GlForm).exists()).toBe(true); - }); - - it('removes the link on clicking apply (if no change)', async () => { - await wrapper.findComponent(GlForm).vm.$emit('submit', createFakeEvent()); - - expect(tiptapEditor.getHTML()).toBe('<p>Dummy link</p>'); - }); - - it('removes the link on clicking cancel', async () => { - await wrapper.findByTestId('cancel-link').vm.$emit('click'); - - expect(tiptapEditor.getHTML()).toBe('<p>Dummy link</p>'); - }); - }); - describe('edit button', () => { let linkHrefInput; - let linkTitleInput; beforeEach(async () => { await buildWrapperAndDisplayMenu(); await wrapper.findByTestId('edit-link').vm.$emit('click'); linkHrefInput = wrapper.findByTestId('link-href'); - linkTitleInput = wrapper.findByTestId('link-title'); }); - it('hides the link and copy/edit/remove link buttons', async () => { + it('hides the link and copy/edit/remove link buttons', () => { expectLinkButtonsToExist(false); }); @@ -234,7 +198,6 @@ describe('content_editor/components/bubble_menus/link_bubble_menu', () => { expect(wrapper.findComponent(GlForm).exists()).toBe(true); expect(linkHrefInput.element.value).toBe('uploads/my_file.pdf'); - expect(linkTitleInput.element.value).toBe('Click here to download'); }); it('extends selection to select the entire link', () => { @@ -247,26 +210,18 @@ describe('content_editor/components/bubble_menus/link_bubble_menu', () => { describe('after making changes in the form and clicking apply', () => { beforeEach(async () => { linkHrefInput.setValue('https://google.com'); - linkTitleInput.setValue('Search Google'); contentEditor.resolveUrl.mockResolvedValue('https://google.com'); await wrapper.findComponent(GlForm).vm.$emit('submit', createFakeEvent()); }); - it('updates prosemirror doc with new link', async () => { - expect(tiptapEditor.getHTML()).toBe( - '<p>Download <a target="_blank" rel="noopener noreferrer nofollow" href="https://google.com" title="Search Google">PDF File</a></p>', - ); - }); - it('updates the link in the bubble menu', () => { const link = wrapper.findComponent(GlLink); expect(link.attributes()).toEqual( expect.objectContaining({ href: 'https://google.com', 'aria-label': 'https://google.com', - title: 'https://google.com', target: '_blank', }), ); @@ -277,7 +232,6 @@ describe('content_editor/components/bubble_menus/link_bubble_menu', () => { describe('after making changes in the form and clicking cancel', () => { beforeEach(async () => { linkHrefInput.setValue('https://google.com'); - linkTitleInput.setValue('Search Google'); await wrapper.findByTestId('cancel-link').vm.$emit('click'); }); @@ -285,17 +239,6 @@ describe('content_editor/components/bubble_menus/link_bubble_menu', () => { it('hides the form and shows the copy/edit/remove link buttons', () => { expectLinkButtonsToExist(); }); - - it('resets the form with old values of the link from prosemirror', async () => { - // click edit once again to show the form back - await wrapper.findByTestId('edit-link').vm.$emit('click'); - - linkHrefInput = wrapper.findByTestId('link-href'); - linkTitleInput = wrapper.findByTestId('link-title'); - - expect(linkHrefInput.element.value).toBe('uploads/my_file.pdf'); - expect(linkTitleInput.element.value).toBe('Click here to download'); - }); }); }); }); |