From 14f27102b696672f02b5d1b2ab45688b711f4024 Mon Sep 17 00:00:00 2001 From: Simon Knox Date: Tue, 11 Jun 2019 14:15:08 +1000 Subject: Add Join meeting button to Issues with Zoom links Detect links containing zoom.us followed by j, s, or my Add link below Issue title that links to Zoom meeting --- .../issue_show/components/pinned_links_spec.js | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 spec/frontend/issue_show/components/pinned_links_spec.js (limited to 'spec/frontend') diff --git a/spec/frontend/issue_show/components/pinned_links_spec.js b/spec/frontend/issue_show/components/pinned_links_spec.js new file mode 100644 index 00000000000..50041667a61 --- /dev/null +++ b/spec/frontend/issue_show/components/pinned_links_spec.js @@ -0,0 +1,91 @@ +import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { GlLink } from '@gitlab/ui'; +import PinnedLinks from '~/issue_show/components/pinned_links.vue'; + +const localVue = createLocalVue(); + +const plainZoomUrl = 'https://zoom.us/j/123456789'; +const vanityZoomUrl = 'https://gitlab.zoom.us/j/123456789'; +const startZoomUrl = 'https://zoom.us/s/123456789'; +const personalZoomUrl = 'https://zoom.us/my/hunter-zoloman'; +const randomUrl = 'https://zoom.us.com'; + +describe('PinnedLinks', () => { + let wrapper; + + const link = { + get text() { + return wrapper.find(GlLink).text(); + }, + get href() { + return wrapper.find(GlLink).attributes('href'); + }, + }; + + const createComponent = props => { + wrapper = shallowMount(localVue.extend(PinnedLinks), { + localVue, + sync: false, + propsData: { + descriptionHtml: '', + ...props, + }, + }); + }; + + it('displays Zoom link', () => { + createComponent({ + descriptionHtml: `Zoom`, + }); + + expect(link.text).toBe('Join Zoom meeting'); + }); + + it('detects plain Zoom link', () => { + createComponent({ + descriptionHtml: `Zoom`, + }); + + expect(link.href).toBe(plainZoomUrl); + }); + + it('detects vanity Zoom link', () => { + createComponent({ + descriptionHtml: `Zoom`, + }); + + expect(link.href).toBe(vanityZoomUrl); + }); + + it('detects Zoom start meeting link', () => { + createComponent({ + descriptionHtml: `Zoom`, + }); + + expect(link.href).toBe(startZoomUrl); + }); + + it('detects personal Zoom room link', () => { + createComponent({ + descriptionHtml: `Zoom`, + }); + + expect(link.href).toBe(personalZoomUrl); + }); + + it('only renders final Zoom link in description', () => { + createComponent({ + descriptionHtml: `ZoomZoom`, + }); + + expect(link.href).toBe(vanityZoomUrl); + }); + + it('does not render for other links', () => { + createComponent({ + descriptionHtml: `Some other link`, + }); + + expect(wrapper.find(GlLink).exists()).toBe(false); + }); +}); -- cgit v1.2.3