diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-19 15:06:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-19 15:06:24 +0000 |
commit | 88542a5e9613c8442a982e65ad5cf13eb33bc541 (patch) | |
tree | 11a65d86e623b443b8a2976cc93cff360e2da8a2 /spec/frontend | |
parent | b570d73ecd31e2ca9cf8c2f1adb056edf2869477 (diff) | |
download | gitlab-ce-88542a5e9613c8442a982e65ad5cf13eb33bc541.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
5 files changed, 62 insertions, 55 deletions
diff --git a/spec/frontend/error_tracking/components/error_tracking_list_spec.js b/spec/frontend/error_tracking/components/error_tracking_list_spec.js index 1bbf23cc602..4edc2a647c3 100644 --- a/spec/frontend/error_tracking/components/error_tracking_list_spec.js +++ b/spec/frontend/error_tracking/components/error_tracking_list_spec.js @@ -1,7 +1,14 @@ import { createLocalVue, shallowMount } from '@vue/test-utils'; import Vuex from 'vuex'; import ErrorTrackingList from '~/error_tracking/components/error_tracking_list.vue'; -import { GlButton, GlEmptyState, GlLoadingIcon, GlTable, GlLink } from '@gitlab/ui'; +import { + GlButton, + GlEmptyState, + GlLoadingIcon, + GlTable, + GlLink, + GlSearchBoxByClick, +} from '@gitlab/ui'; const localVue = createLocalVue(); localVue.use(Vuex); @@ -34,8 +41,8 @@ describe('ErrorTrackingList', () => { beforeEach(() => { actions = { - getSentryData: () => {}, - startPolling: () => {}, + getErrorList: () => {}, + startPolling: jest.fn(), restartPolling: jest.fn().mockName('restartPolling'), }; @@ -63,13 +70,13 @@ describe('ErrorTrackingList', () => { describe('loading', () => { beforeEach(() => { + store.state.list.loading = true; mountComponent(); }); it('shows spinner', () => { expect(wrapper.find(GlLoadingIcon).exists()).toBeTruthy(); expect(wrapper.find(GlTable).exists()).toBeFalsy(); - expect(wrapper.find(GlButton).exists()).toBeFalsy(); }); }); @@ -85,6 +92,20 @@ describe('ErrorTrackingList', () => { expect(wrapper.find(GlTable).exists()).toBeTruthy(); expect(wrapper.find(GlButton).exists()).toBeTruthy(); }); + + describe('filtering', () => { + it('shows search box', () => { + expect(wrapper.find(GlSearchBoxByClick).exists()).toBeTruthy(); + }); + + it('makes network request on submit', () => { + expect(actions.startPolling).toHaveBeenCalledTimes(1); + + wrapper.find(GlSearchBoxByClick).vm.$emit('submit'); + + expect(actions.startPolling).toHaveBeenCalledTimes(2); + }); + }); }); describe('no results', () => { diff --git a/spec/frontend/error_tracking/store/list/actions_spec.js b/spec/frontend/error_tracking/store/list/actions_spec.js new file mode 100644 index 00000000000..dba1b31b9f3 --- /dev/null +++ b/spec/frontend/error_tracking/store/list/actions_spec.js @@ -0,0 +1,29 @@ +import axios from '~/lib/utils/axios_utils'; +import MockAdapter from 'axios-mock-adapter'; +import * as actions from '~/error_tracking/store/list/actions'; +import * as types from '~/error_tracking/store/list/mutation_types'; + +describe('error tracking actions', () => { + let mock; + + beforeEach(() => { + mock = new MockAdapter(axios); + }); + + afterEach(() => { + mock.restore(); + }); + + describe('startPolling', () => { + it('commits SET_LOADING', () => { + mock.onGet().reply(200); + const endpoint = '/errors'; + const commit = jest.fn(); + const state = {}; + + actions.startPolling({ commit, state }, endpoint); + + expect(commit).toHaveBeenCalledWith(types.SET_LOADING, true); + }); + }); +}); diff --git a/spec/frontend/error_tracking/store/list/getters_spec.js b/spec/frontend/error_tracking/store/list/getters_spec.js deleted file mode 100644 index 3cd7fa37d44..00000000000 --- a/spec/frontend/error_tracking/store/list/getters_spec.js +++ /dev/null @@ -1,33 +0,0 @@ -import * as getters from '~/error_tracking/store/list/getters'; - -describe('Error Tracking getters', () => { - let state; - - const mockErrors = [ - { title: 'ActiveModel::MissingAttributeError: missing attribute: encrypted_password' }, - { title: 'Grape::Exceptions::MethodNotAllowed: Grape::Exceptions::MethodNotAllowed' }, - { title: 'NoMethodError: undefined method `sanitize_http_headers=' }, - { title: 'NoMethodError: undefined method `pry' }, - ]; - - beforeEach(() => { - state = { - errors: mockErrors, - }; - }); - - describe('search results', () => { - it('should return errors filtered by words in title matching the query', () => { - const filteredErrors = getters.filterErrorsByTitle(state)('NoMethod'); - - expect(filteredErrors).not.toContainEqual(mockErrors[0]); - expect(filteredErrors.length).toBe(2); - }); - - it('should not return results if there is no matching query', () => { - const filteredErrors = getters.filterErrorsByTitle(state)('GitLab'); - - expect(filteredErrors.length).toBe(0); - }); - }); -}); diff --git a/spec/frontend/vue_shared/components/markdown/header_spec.js b/spec/frontend/vue_shared/components/markdown/header_spec.js index 48f2ee86619..1c4247fb5f0 100644 --- a/spec/frontend/vue_shared/components/markdown/header_spec.js +++ b/spec/frontend/vue_shared/components/markdown/header_spec.js @@ -5,7 +5,7 @@ import headerComponent from '~/vue_shared/components/markdown/header.vue'; describe('Markdown field header component', () => { let vm; - beforeEach(done => { + beforeEach(() => { const Component = Vue.extend(headerComponent); vm = new Component({ @@ -13,8 +13,6 @@ describe('Markdown field header component', () => { previewMarkdown: false, }, }).$mount(); - - Vue.nextTick(done); }); it('renders markdown header buttons', () => { @@ -42,13 +40,11 @@ describe('Markdown field header component', () => { expect(vm.$el.querySelector('li:nth-child(1)').classList.contains('active')).toBeTruthy(); }); - it('renders `preview` link as active when previewMarkdown is true', done => { + it('renders `preview` link as active when previewMarkdown is true', () => { vm.previewMarkdown = true; Vue.nextTick(() => { expect(vm.$el.querySelector('li:nth-child(2)').classList.contains('active')).toBeTruthy(); - - done(); }); }); diff --git a/spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js b/spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js index 6716e5cd794..9e0b98ecef9 100644 --- a/spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js +++ b/spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js @@ -64,12 +64,10 @@ describe('Suggestion Diff component', () => { }); describe('when apply suggestion is clicked', () => { - beforeEach(done => { + beforeEach(() => { createComponent(); findApplyButton().vm.$emit('click'); - - wrapper.vm.$nextTick(done); }); it('emits apply', () => { @@ -88,19 +86,15 @@ describe('Suggestion Diff component', () => { expect(wrapper.text()).toContain('Applying suggestion'); }); - it('when callback of apply is called, hides loading', done => { + it('when callback of apply is called, hides loading', () => { const [callback] = wrapper.emitted().apply[0]; callback(); - wrapper.vm - .$nextTick() - .then(() => { - expect(findApplyButton().exists()).toBe(true); - expect(findLoading().exists()).toBe(false); - }) - .then(done) - .catch(done.fail); + return wrapper.vm.$nextTick().then(() => { + expect(findApplyButton().exists()).toBe(true); + expect(findLoading().exists()).toBe(false); + }); }); }); }); |