diff options
Diffstat (limited to 'spec/frontend')
6 files changed, 93 insertions, 26 deletions
diff --git a/spec/frontend/logs/components/environment_logs_spec.js b/spec/frontend/logs/components/environment_logs_spec.js index c638b4c05f9..162aeb1cc56 100644 --- a/spec/frontend/logs/components/environment_logs_spec.js +++ b/spec/frontend/logs/components/environment_logs_spec.js @@ -300,9 +300,10 @@ describe('EnvironmentLogs', () => { const items = findPodsDropdown().findAll(GlDropdownItem); expect(findPodsDropdown().props('text')).toBe(mockPodName); - expect(items.length).toBe(mockPods.length); + expect(items.length).toBe(mockPods.length + 1); + expect(items.at(0).text()).toBe('All pods'); mockPods.forEach((pod, i) => { - const item = items.at(i); + const item = items.at(i + 1); expect(item.text()).toBe(pod); }); }); @@ -345,7 +346,7 @@ describe('EnvironmentLogs', () => { expect(dispatch).not.toHaveBeenCalledWith(`${module}/showPodLogs`, expect.anything()); - items.at(index).vm.$emit('click'); + items.at(index + 1).vm.$emit('click'); expect(dispatch).toHaveBeenCalledWith(`${module}/showPodLogs`, mockPods[index]); }); diff --git a/spec/frontend/logs/mock_data.js b/spec/frontend/logs/mock_data.js index 1a84d6edd12..537582cff5a 100644 --- a/spec/frontend/logs/mock_data.js +++ b/spec/frontend/logs/mock_data.js @@ -32,15 +32,93 @@ export const mockPods = [ ]; export const mockLogsResult = [ - { timestamp: '2019-12-13T13:43:18.2760123Z', message: 'Log 1' }, - { timestamp: '2019-12-13T13:43:18.2760123Z', message: 'Log 2' }, - { timestamp: '2019-12-13T13:43:26.8420123Z', message: 'Log 3' }, + { + timestamp: '2019-12-13T13:43:18.2760123Z', + message: '10.36.0.1 - - [16/Oct/2019:06:29:48 UTC] "GET / HTTP/1.1" 200 13', + pod: 'foo', + }, + { + timestamp: '2019-12-13T13:43:18.2760123Z', + message: '- -> /', + pod: 'bar', + }, + { + timestamp: '2019-12-13T13:43:26.8420123Z', + message: '10.36.0.1 - - [16/Oct/2019:06:29:57 UTC] "GET / HTTP/1.1" 200 13', + pod: 'foo', + }, + { + timestamp: '2019-12-13T13:43:26.8420123Z', + message: '- -> /', + pod: 'bar', + }, + { + timestamp: '2019-12-13T13:43:28.3710123Z', + message: '10.36.0.1 - - [16/Oct/2019:06:29:58 UTC] "GET / HTTP/1.1" 200 13', + pod: 'foo', + }, + { + timestamp: '2019-12-13T13:43:28.3710123Z', + message: '- -> /', + pod: 'bar', + }, + { + timestamp: '2019-12-13T13:43:36.8860123Z', + message: '10.36.0.1 - - [16/Oct/2019:06:30:07 UTC] "GET / HTTP/1.1" 200 13', + pod: 'foo', + }, + { + timestamp: '2019-12-13T13:43:36.8860123Z', + message: '- -> /', + pod: 'bar', + }, + { + timestamp: '2019-12-13T13:43:38.4000123Z', + message: '10.36.0.1 - - [16/Oct/2019:06:30:08 UTC] "GET / HTTP/1.1" 200 13', + pod: 'foo', + }, + { + timestamp: '2019-12-13T13:43:38.4000123Z', + message: '- -> /', + pod: 'bar', + }, + { + timestamp: '2019-12-13T13:43:46.8420123Z', + message: '10.36.0.1 - - [16/Oct/2019:06:30:17 UTC] "GET / HTTP/1.1" 200 13', + pod: 'foo', + }, + { + timestamp: '2019-12-13T13:43:46.8430123Z', + message: '- -> /', + pod: 'bar', + }, + { + timestamp: '2019-12-13T13:43:48.3240123Z', + message: '10.36.0.1 - - [16/Oct/2019:06:30:18 UTC] "GET / HTTP/1.1" 200 13', + pod: 'foo', + }, + { + timestamp: '2019-12-13T13:43:48.3250123Z', + message: '- -> /', + pod: 'bar', + }, ]; export const mockTrace = [ - 'Dec 13 13:43:18.276Z | Log 1', - 'Dec 13 13:43:18.276Z | Log 2', - 'Dec 13 13:43:26.842Z | Log 3', + 'Dec 13 13:43:18.276Z | foo | 10.36.0.1 - - [16/Oct/2019:06:29:48 UTC] "GET / HTTP/1.1" 200 13', + 'Dec 13 13:43:18.276Z | bar | - -> /', + 'Dec 13 13:43:26.842Z | foo | 10.36.0.1 - - [16/Oct/2019:06:29:57 UTC] "GET / HTTP/1.1" 200 13', + 'Dec 13 13:43:26.842Z | bar | - -> /', + 'Dec 13 13:43:28.371Z | foo | 10.36.0.1 - - [16/Oct/2019:06:29:58 UTC] "GET / HTTP/1.1" 200 13', + 'Dec 13 13:43:28.371Z | bar | - -> /', + 'Dec 13 13:43:36.886Z | foo | 10.36.0.1 - - [16/Oct/2019:06:30:07 UTC] "GET / HTTP/1.1" 200 13', + 'Dec 13 13:43:36.886Z | bar | - -> /', + 'Dec 13 13:43:38.400Z | foo | 10.36.0.1 - - [16/Oct/2019:06:30:08 UTC] "GET / HTTP/1.1" 200 13', + 'Dec 13 13:43:38.400Z | bar | - -> /', + 'Dec 13 13:43:46.842Z | foo | 10.36.0.1 - - [16/Oct/2019:06:30:17 UTC] "GET / HTTP/1.1" 200 13', + 'Dec 13 13:43:46.843Z | bar | - -> /', + 'Dec 13 13:43:48.324Z | foo | 10.36.0.1 - - [16/Oct/2019:06:30:18 UTC] "GET / HTTP/1.1" 200 13', + 'Dec 13 13:43:48.325Z | bar | - -> /', ]; export const mockResponse = { diff --git a/spec/frontend/logs/stores/actions_spec.js b/spec/frontend/logs/stores/actions_spec.js index 1512797e1bc..1754931bcaf 100644 --- a/spec/frontend/logs/stores/actions_spec.js +++ b/spec/frontend/logs/stores/actions_spec.js @@ -13,7 +13,7 @@ import { fetchMoreLogsPrepend, } from '~/logs/stores/actions'; -import { defaultTimeRange } from '~/monitoring/constants'; +import { defaultTimeRange } from '~/vue_shared/constants'; import axios from '~/lib/utils/axios_utils'; import flash from '~/flash'; @@ -172,14 +172,13 @@ describe('Logs Store actions', () => { describe('fetchLogs', () => { beforeEach(() => { expectedMutations = [ - { type: types.REQUEST_PODS_DATA }, { type: types.REQUEST_LOGS_DATA }, - { type: types.SET_CURRENT_POD_NAME, payload: mockPodName }, - { type: types.RECEIVE_PODS_DATA_SUCCESS, payload: mockPods }, { type: types.RECEIVE_LOGS_DATA_SUCCESS, payload: { logs: mockLogsResult, cursor: mockNextCursor }, }, + { type: types.SET_CURRENT_POD_NAME, payload: mockPodName }, + { type: types.RECEIVE_PODS_DATA_SUCCESS, payload: mockPods }, ]; expectedActions = []; @@ -364,7 +363,6 @@ describe('Logs Store actions', () => { null, state, [ - { type: types.REQUEST_PODS_DATA }, { type: types.REQUEST_LOGS_DATA }, { type: types.RECEIVE_PODS_DATA_ERROR }, { type: types.RECEIVE_LOGS_DATA_ERROR }, diff --git a/spec/frontend/logs/stores/mutations_spec.js b/spec/frontend/logs/stores/mutations_spec.js index eae838a31d4..37db355af09 100644 --- a/spec/frontend/logs/stores/mutations_spec.js +++ b/spec/frontend/logs/stores/mutations_spec.js @@ -223,17 +223,6 @@ describe('Logs Store Mutations', () => { }); }); - describe('REQUEST_PODS_DATA', () => { - it('receives pods data', () => { - mutations[types.REQUEST_PODS_DATA](state); - - expect(state.pods).toEqual( - expect.objectContaining({ - options: [], - }), - ); - }); - }); describe('RECEIVE_PODS_DATA_SUCCESS', () => { it('receives pods data success', () => { mutations[types.RECEIVE_PODS_DATA_SUCCESS](state, mockPods); diff --git a/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap b/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap index 77f7f2e0609..e37043e5d4d 100644 --- a/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap +++ b/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap @@ -78,6 +78,7 @@ exports[`Dashboard template matches the default snapshot 1`] = ` label-size="sm" > <date-time-picker-stub + customenabled="true" options="[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]" value="[object Object]" /> diff --git a/spec/frontend/monitoring/components/dashboard_url_time_spec.js b/spec/frontend/monitoring/components/dashboard_url_time_spec.js index 161c64dd74b..bf5a11a536e 100644 --- a/spec/frontend/monitoring/components/dashboard_url_time_spec.js +++ b/spec/frontend/monitoring/components/dashboard_url_time_spec.js @@ -7,7 +7,7 @@ import { mockProjectDir } from '../mock_data'; import Dashboard from '~/monitoring/components/dashboard.vue'; import { createStore } from '~/monitoring/stores'; -import { defaultTimeRange } from '~/monitoring/constants'; +import { defaultTimeRange } from '~/vue_shared/constants'; import { propsData } from '../init_utils'; jest.mock('~/flash'); |