diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/frontend/pages | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) | |
download | gitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/frontend/pages')
4 files changed, 52 insertions, 81 deletions
diff --git a/spec/frontend/pages/labels/components/promote_label_modal_spec.js b/spec/frontend/pages/labels/components/promote_label_modal_spec.js index 1fa12cf1365..f969808d78b 100644 --- a/spec/frontend/pages/labels/components/promote_label_modal_spec.js +++ b/spec/frontend/pages/labels/components/promote_label_modal_spec.js @@ -32,10 +32,9 @@ describe('Promote label modal', () => { }); it('contains a label span with the color', () => { - const labelFromTitle = vm.$el.querySelector('.modal-header .label.color-label'); - - expect(labelFromTitle.style.backgroundColor).not.toBe(null); - expect(labelFromTitle.textContent).toContain(vm.labelTitle); + expect(vm.labelColor).not.toBe(null); + expect(vm.labelColor).toBe(labelMockData.labelColor); + expect(vm.labelTitle).toBe(labelMockData.labelTitle); }); }); diff --git a/spec/frontend/pages/projects/pipeline_schedules/shared/components/pipeline_schedule_callout_spec.js b/spec/frontend/pages/projects/pipeline_schedules/shared/components/pipeline_schedule_callout_spec.js index 5da998d9d2d..cfe54016410 100644 --- a/spec/frontend/pages/projects/pipeline_schedules/shared/components/pipeline_schedule_callout_spec.js +++ b/spec/frontend/pages/projects/pipeline_schedules/shared/components/pipeline_schedule_callout_spec.js @@ -1,109 +1,98 @@ -import Vue from 'vue'; +import { shallowMount } from '@vue/test-utils'; +import { GlButton } from '@gitlab/ui'; import Cookies from 'js-cookie'; import PipelineSchedulesCallout from '~/pages/projects/pipeline_schedules/shared/components/pipeline_schedules_callout.vue'; -const PipelineSchedulesCalloutComponent = Vue.extend(PipelineSchedulesCallout); const cookieKey = 'pipeline_schedules_callout_dismissed'; const docsUrl = 'help/ci/scheduled_pipelines'; -const imageUrl = 'pages/projects/pipeline_schedules/shared/icons/intro_illustration.svg'; +const illustrationUrl = 'pages/projects/pipeline_schedules/shared/icons/intro_illustration.svg'; describe('Pipeline Schedule Callout', () => { - let calloutComponent; + let wrapper; - beforeEach(() => { - setFixtures(` - <div id='pipeline-schedules-callout' data-docs-url=${docsUrl} data-image-url=${imageUrl}></div> - `); - }); - - describe('independent of cookies', () => { - beforeEach(() => { - calloutComponent = new PipelineSchedulesCalloutComponent().$mount(); - }); - - it('the component can be initialized', () => { - expect(calloutComponent).toBeDefined(); + const createComponent = () => { + wrapper = shallowMount(PipelineSchedulesCallout, { + provide: { + docsUrl, + illustrationUrl, + }, }); + }; - it('correctly sets docsUrl', () => { - expect(calloutComponent.docsUrl).toContain(docsUrl); - }); - - it('correctly sets imageUrl', () => { - expect(calloutComponent.imageUrl).toContain(imageUrl); - }); - }); + const findInnerContentOfCallout = () => wrapper.find('[data-testid="innerContent"]'); + const findDismissCalloutBtn = () => wrapper.find(GlButton); describe(`when ${cookieKey} cookie is set`, () => { - beforeEach(() => { + beforeEach(async () => { Cookies.set(cookieKey, true); - calloutComponent = new PipelineSchedulesCalloutComponent().$mount(); + createComponent(); + + await wrapper.vm.$nextTick(); }); - it('correctly sets calloutDismissed to true', () => { - expect(calloutComponent.calloutDismissed).toBe(true); + afterEach(() => { + wrapper.destroy(); }); it('does not render the callout', () => { - expect(calloutComponent.$el.childNodes.length).toBe(0); + expect(findInnerContentOfCallout().exists()).toBe(false); }); }); describe('when cookie is not set', () => { beforeEach(() => { Cookies.remove(cookieKey); - calloutComponent = new PipelineSchedulesCalloutComponent().$mount(); + createComponent(); }); - it('correctly sets calloutDismissed to false', () => { - expect(calloutComponent.calloutDismissed).toBe(false); + afterEach(() => { + wrapper.destroy(); }); it('renders the callout container', () => { - expect(calloutComponent.$el.querySelector('.bordered-box')).not.toBeNull(); - }); - - it('renders the callout img', () => { - expect(calloutComponent.$el.outerHTML).toContain('<img'); + expect(findInnerContentOfCallout().exists()).toBe(true); }); it('renders the callout title', () => { - expect(calloutComponent.$el.outerHTML).toContain('Scheduling Pipelines'); + expect(wrapper.find('h4').text()).toBe('Scheduling Pipelines'); }); it('renders the callout text', () => { - expect(calloutComponent.$el.outerHTML).toContain('runs pipelines in the future'); + expect(wrapper.find('p').text()).toContain('runs pipelines in the future'); }); it('renders the documentation url', () => { - expect(calloutComponent.$el.outerHTML).toContain(docsUrl); + expect(wrapper.find('a').attributes('href')).toBe(docsUrl); }); - it('updates calloutDismissed when close button is clicked', done => { - calloutComponent.$el.querySelector('#dismiss-callout-btn').click(); + describe('methods', () => { + it('#dismissCallout sets calloutDismissed to true', async () => { + expect(wrapper.vm.calloutDismissed).toBe(false); + + findDismissCalloutBtn().vm.$emit('click'); + + await wrapper.vm.$nextTick(); - Vue.nextTick(() => { - expect(calloutComponent.calloutDismissed).toBe(true); - done(); + expect(findInnerContentOfCallout().exists()).toBe(false); }); - }); - it('#dismissCallout updates calloutDismissed', done => { - calloutComponent.dismissCallout(); + it('sets cookie on dismiss', () => { + const setCookiesSpy = jest.spyOn(Cookies, 'set'); + + findDismissCalloutBtn().vm.$emit('click'); - Vue.nextTick(() => { - expect(calloutComponent.calloutDismissed).toBe(true); - done(); + expect(setCookiesSpy).toHaveBeenCalledWith('pipeline_schedules_callout_dismissed', true, { + expires: 365, + }); }); }); - it('is hidden when close button is clicked', done => { - calloutComponent.$el.querySelector('#dismiss-callout-btn').click(); + it('is hidden when close button is clicked', async () => { + findDismissCalloutBtn().vm.$emit('click'); - Vue.nextTick(() => { - expect(calloutComponent.$el.childNodes.length).toBe(0); - done(); - }); + await wrapper.vm.$nextTick(); + + expect(findInnerContentOfCallout().exists()).toBe(false); }); }); }); diff --git a/spec/frontend/pages/search/show/highlight_blob_search_result_spec.js b/spec/frontend/pages/search/show/highlight_blob_search_result_spec.js deleted file mode 100644 index 4083a65df75..00000000000 --- a/spec/frontend/pages/search/show/highlight_blob_search_result_spec.js +++ /dev/null @@ -1,15 +0,0 @@ -import setHighlightClass from '~/pages/search/show/highlight_blob_search_result'; - -const fixture = 'search/blob_search_result.html'; - -describe('pages/search/show/highlight_blob_search_result', () => { - preloadFixtures(fixture); - - beforeEach(() => loadFixtures(fixture)); - - it('highlights lines with search term occurrence', () => { - setHighlightClass(); - - expect(document.querySelectorAll('.blob-result .hll').length).toBe(11); - }); -}); diff --git a/spec/frontend/pages/sessions/new/preserve_url_fragment_spec.js b/spec/frontend/pages/sessions/new/preserve_url_fragment_spec.js index 0d9af0cb856..4b50342bf84 100644 --- a/spec/frontend/pages/sessions/new/preserve_url_fragment_spec.js +++ b/spec/frontend/pages/sessions/new/preserve_url_fragment_spec.js @@ -14,18 +14,16 @@ describe('preserve_url_fragment', () => { loadFixtures('sessions/new.html'); }); - it('adds the url fragment to all login and sign up form actions', () => { + it('adds the url fragment to the login form actions', () => { preserveUrlFragment('#L65'); expect($('#new_user').attr('action')).toBe('http://test.host/users/sign_in#L65'); - expect($('#new_new_user').attr('action')).toBe('http://test.host/users#L65'); }); - it('does not add an empty url fragment to login and sign up form actions', () => { + it('does not add an empty url fragment to the login form actions', () => { preserveUrlFragment(); expect($('#new_user').attr('action')).toBe('http://test.host/users/sign_in'); - expect($('#new_new_user').attr('action')).toBe('http://test.host/users'); }); it('does not add an empty query parameter to OmniAuth login buttons', () => { |