From 48aff82709769b098321c738f3444b9bdaa694c6 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 21 Oct 2020 07:08:36 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-5-stable-ee --- .../jobs/components/job_container_item_spec.js | 2 +- spec/frontend/jobs/components/log/line_spec.js | 65 +++++++++++++++++----- 2 files changed, 53 insertions(+), 14 deletions(-) (limited to 'spec/frontend/jobs/components') diff --git a/spec/frontend/jobs/components/job_container_item_spec.js b/spec/frontend/jobs/components/job_container_item_spec.js index 9019504d22d..41b399fa32b 100644 --- a/spec/frontend/jobs/components/job_container_item_spec.js +++ b/spec/frontend/jobs/components/job_container_item_spec.js @@ -90,7 +90,7 @@ describe('JobContainerItem', () => { Vue.nextTick() .then(() => { - expect(vm.$el.querySelector('.js-job-link').getAttribute('data-original-title')).toEqual( + expect(vm.$el.querySelector('.js-job-link').getAttribute('title')).toEqual( 'delayed job - delayed manual action (00:22:17)', ); }) diff --git a/spec/frontend/jobs/components/log/line_spec.js b/spec/frontend/jobs/components/log/line_spec.js index c2412a807c3..1a30921fece 100644 --- a/spec/frontend/jobs/components/log/line_spec.js +++ b/spec/frontend/jobs/components/log/line_spec.js @@ -2,21 +2,25 @@ import { shallowMount } from '@vue/test-utils'; import Line from '~/jobs/components/log/line.vue'; import LineNumber from '~/jobs/components/log/line_number.vue'; +const httpUrl = 'http://example.com'; +const httpsUrl = 'https://example.com'; + +const mockProps = ({ text = 'Running with gitlab-runner 12.1.0 (de7731dd)' } = {}) => ({ + line: { + content: [ + { + text, + style: 'term-fg-l-green', + }, + ], + lineNumber: 0, + }, + path: '/jashkenas/underscore/-/jobs/335', +}); + describe('Job Log Line', () => { let wrapper; - - const data = { - line: { - content: [ - { - text: 'Running with gitlab-runner 12.1.0 (de7731dd)', - style: 'term-fg-l-green', - }, - ], - lineNumber: 0, - }, - path: '/jashkenas/underscore/-/jobs/335', - }; + let data; const createComponent = (props = {}) => { wrapper = shallowMount(Line, { @@ -27,6 +31,7 @@ describe('Job Log Line', () => { }; beforeEach(() => { + data = mockProps(); createComponent(data); }); @@ -45,4 +50,38 @@ describe('Job Log Line', () => { it('renders the provided style as a class attribute', () => { expect(wrapper.find('span').classes()).toContain(data.line.content[0].style); }); + + describe('when the line contains a link', () => { + const findLink = () => wrapper.find('span a'); + + it('renders an http link', () => { + createComponent(mockProps({ text: httpUrl })); + + expect(findLink().text()).toBe(httpUrl); + expect(findLink().attributes().href).toEqual(httpUrl); + }); + + it('renders an https link', () => { + createComponent(mockProps({ text: httpsUrl })); + + expect(findLink().text()).toBe(httpsUrl); + expect(findLink().attributes().href).toEqual(httpsUrl); + }); + + it('renders a link with rel nofollow and noopener', () => { + createComponent(mockProps({ text: httpsUrl })); + + expect(findLink().attributes().rel).toBe('nofollow noopener'); + }); + + test.each` + type | text + ${'ftp'} | ${'ftp://example.com/file'} + ${'email'} | ${'email@example.com'} + ${'no scheme'} | ${'example.com/page'} + `('does not render a $type link', ({ text }) => { + createComponent(mockProps({ text })); + expect(findLink().exists()).toBe(false); + }); + }); }); -- cgit v1.2.3