diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/frontend/logs | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/frontend/logs')
-rw-r--r-- | spec/frontend/logs/components/environment_logs_spec.js | 2 | ||||
-rw-r--r-- | spec/frontend/logs/components/log_control_buttons_spec.js | 8 | ||||
-rw-r--r-- | spec/frontend/logs/mock_data.js | 15 | ||||
-rw-r--r-- | spec/frontend/logs/stores/actions_spec.js | 27 | ||||
-rw-r--r-- | spec/frontend/logs/stores/mutations_spec.js | 35 |
5 files changed, 83 insertions, 4 deletions
diff --git a/spec/frontend/logs/components/environment_logs_spec.js b/spec/frontend/logs/components/environment_logs_spec.js index 62f3e8a755d..dee62709d81 100644 --- a/spec/frontend/logs/components/environment_logs_spec.js +++ b/spec/frontend/logs/components/environment_logs_spec.js @@ -12,6 +12,7 @@ import { mockTrace, mockEnvironmentsEndpoint, mockDocumentationPath, + mockManagedAppsEndpoint, } from '../mock_data'; jest.mock('~/lib/utils/scroll_utils'); @@ -34,6 +35,7 @@ describe('EnvironmentLogs', () => { environmentName: mockEnvName, environmentsPath: mockEnvironmentsEndpoint, clusterApplicationsDocumentationPath: mockDocumentationPath, + clustersPath: mockManagedAppsEndpoint, }; const updateControlBtnsMock = jest.fn(); diff --git a/spec/frontend/logs/components/log_control_buttons_spec.js b/spec/frontend/logs/components/log_control_buttons_spec.js index 85fc5a040d6..38e568f569f 100644 --- a/spec/frontend/logs/components/log_control_buttons_spec.js +++ b/spec/frontend/logs/components/log_control_buttons_spec.js @@ -1,5 +1,5 @@ import { shallowMount } from '@vue/test-utils'; -import { GlDeprecatedButton } from '@gitlab/ui'; +import { GlButton } from '@gitlab/ui'; import LogControlButtons from '~/logs/components/log_control_buttons.vue'; describe('LogControlButtons', () => { @@ -31,9 +31,9 @@ describe('LogControlButtons', () => { expect(wrapper.isVueInstance()).toBe(true); expect(wrapper.isEmpty()).toBe(false); - expect(findScrollToTop().is(GlDeprecatedButton)).toBe(true); - expect(findScrollToBottom().is(GlDeprecatedButton)).toBe(true); - expect(findRefreshBtn().is(GlDeprecatedButton)).toBe(true); + expect(findScrollToTop().is(GlButton)).toBe(true); + expect(findScrollToBottom().is(GlButton)).toBe(true); + expect(findRefreshBtn().is(GlButton)).toBe(true); }); it('emits a `refresh` event on click on `refresh` button', () => { diff --git a/spec/frontend/logs/mock_data.js b/spec/frontend/logs/mock_data.js index 14c8f7a2ba2..f9b3508e01c 100644 --- a/spec/frontend/logs/mock_data.js +++ b/spec/frontend/logs/mock_data.js @@ -7,6 +7,8 @@ export const mockDocumentationPath = '/documentation.md'; export const mockLogsEndpoint = '/dummy_logs_path.json'; export const mockCursor = 'MOCK_CURSOR'; export const mockNextCursor = 'MOCK_NEXT_CURSOR'; +export const mockManagedAppName = 'kubernetes-cluster-1'; +export const mockManagedAppsEndpoint = `${mockProjectPath}/clusters.json`; const makeMockEnvironment = (id, name, advancedQuerying) => ({ id, @@ -23,6 +25,19 @@ export const mockEnvironments = [ makeMockEnvironment(102, 'review/a-feature', false), ]; +export const mockManagedApps = [ + { + cluster_type: 'project_type', + enabled: true, + environment_scope: '*', + name: 'kubernetes-cluster-1', + provider_type: 'user', + status: 'connected', + path: '/root/autodevops-deploy/-/clusters/15', + gitlab_managed_apps_logs_path: '/root/autodevops-deploy/-/logs?cluster_id=15', + }, +]; + export const mockPodName = 'production-764c58d697-aaaaa'; export const mockPods = [ mockPodName, diff --git a/spec/frontend/logs/stores/actions_spec.js b/spec/frontend/logs/stores/actions_spec.js index e2e3c3d23c6..acd9536a682 100644 --- a/spec/frontend/logs/stores/actions_spec.js +++ b/spec/frontend/logs/stores/actions_spec.js @@ -11,6 +11,7 @@ import { fetchEnvironments, fetchLogs, fetchMoreLogsPrepend, + fetchManagedApps, } from '~/logs/stores/actions'; import { defaultTimeRange } from '~/vue_shared/constants'; @@ -30,6 +31,8 @@ import { mockResponse, mockCursor, mockNextCursor, + mockManagedApps, + mockManagedAppsEndpoint, } from '../mock_data'; import { TOKEN_TYPE_POD_NAME } from '~/logs/constants'; @@ -217,6 +220,30 @@ describe('Logs Store actions', () => { }); }); + describe('fetchManagedApps', () => { + beforeEach(() => { + mock = new MockAdapter(axios); + }); + + it('should commit RECEIVE_MANAGED_APPS_DATA_SUCCESS mutation on succesful fetch', () => { + mock.onGet(mockManagedAppsEndpoint).replyOnce(200, { clusters: mockManagedApps }); + return testAction(fetchManagedApps, mockManagedAppsEndpoint, state, [ + { type: types.RECEIVE_MANAGED_APPS_DATA_SUCCESS, payload: mockManagedApps }, + ]); + }); + + it('should commit RECEIVE_MANAGED_APPS_DATA_ERROR on wrong data', () => { + mock.onGet(mockManagedAppsEndpoint).replyOnce(500); + return testAction( + fetchManagedApps, + mockManagedAppsEndpoint, + state, + [{ type: types.RECEIVE_MANAGED_APPS_DATA_ERROR }], + [], + ); + }); + }); + describe('when the backend responds succesfully', () => { let expectedMutations; let expectedActions; diff --git a/spec/frontend/logs/stores/mutations_spec.js b/spec/frontend/logs/stores/mutations_spec.js index 46561055a4a..137533f02d7 100644 --- a/spec/frontend/logs/stores/mutations_spec.js +++ b/spec/frontend/logs/stores/mutations_spec.js @@ -11,6 +11,8 @@ import { mockSearch, mockCursor, mockNextCursor, + mockManagedApps, + mockManagedAppName, } from '../mock_data'; describe('Logs Store Mutations', () => { @@ -30,6 +32,15 @@ describe('Logs Store Mutations', () => { it('sets the environment', () => { mutations[types.SET_PROJECT_ENVIRONMENT](state, mockEnvName); expect(state.environments.current).toEqual(mockEnvName); + expect(state.managedApps.current).toBe(null); + }); + }); + + describe('SET_MANAGED_APP', () => { + it('sets the managed app', () => { + mutations[types.SET_MANAGED_APP](state, mockManagedAppName); + expect(state.managedApps.current).toBe(mockManagedAppName); + expect(state.environments.current).toBe(null); }); }); @@ -254,4 +265,28 @@ describe('Logs Store Mutations', () => { ); }); }); + + describe('RECEIVE_MANAGED_APPS_DATA_SUCCESS', () => { + it('receives managed apps data success', () => { + expect(state.managedApps.options).toEqual([]); + + mutations[types.RECEIVE_MANAGED_APPS_DATA_SUCCESS](state, mockManagedApps); + + expect(state.managedApps.options).toEqual(mockManagedApps); + expect(state.managedApps.isLoading).toBe(false); + }); + }); + + describe('RECEIVE_MANAGED_APPS_DATA_ERROR', () => { + it('received managed apps data error', () => { + mutations[types.RECEIVE_MANAGED_APPS_DATA_ERROR](state); + + expect(state.managedApps).toEqual({ + options: [], + isLoading: false, + current: null, + fetchError: true, + }); + }); + }); }); |