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/error_tracking | |
parent | b570d73ecd31e2ca9cf8c2f1adb056edf2869477 (diff) | |
download | gitlab-ce-88542a5e9613c8442a982e65ad5cf13eb33bc541.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/error_tracking')
3 files changed, 54 insertions, 37 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); - }); - }); -}); |