diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-08 09:09:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-08 09:09:40 +0300 |
commit | 79ddf163588de2d9a7f1cc27262dc1a14503f619 (patch) | |
tree | ee215c70dee12468f6b919e07cce22ef827074d1 /spec/frontend | |
parent | ae69a88c2a11f1c3c008b3ffd3c5622cbd64dde4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/monitoring/store/actions_spec.js | 24 | ||||
-rw-r--r-- | spec/frontend/monitoring/store/mutations_spec.js | 14 | ||||
-rw-r--r-- | spec/frontend/monitoring/utils_spec.js | 37 | ||||
-rw-r--r-- | spec/frontend/notes/components/comment_form_spec.js | 31 | ||||
-rw-r--r-- | spec/frontend/notes/components/note_header_spec.js | 12 | ||||
-rw-r--r-- | spec/frontend/sidebar/assignees_realtime_spec.js | 4 |
6 files changed, 121 insertions, 1 deletions
diff --git a/spec/frontend/monitoring/store/actions_spec.js b/spec/frontend/monitoring/store/actions_spec.js index fd8fb4c6418..d9794c34b3b 100644 --- a/spec/frontend/monitoring/store/actions_spec.js +++ b/spec/frontend/monitoring/store/actions_spec.js @@ -25,6 +25,7 @@ import { clearExpandedPanel, setGettingStartedEmptyState, duplicateSystemDashboard, + setVariables, } from '~/monitoring/stores/actions'; import { gqClient, @@ -392,6 +393,29 @@ describe('Monitoring store actions', () => { ); }); }); + + describe('setVariables', () => { + let mockedState; + beforeEach(() => { + mockedState = storeState(); + }); + it('should commit SET_PROM_QUERY_VARIABLES mutation', done => { + testAction( + setVariables, + { pod: 'POD' }, + mockedState, + [ + { + type: types.SET_PROM_QUERY_VARIABLES, + payload: { pod: 'POD' }, + }, + ], + [], + done, + ); + }); + }); + describe('fetchDashboard', () => { let dispatch; let state; diff --git a/spec/frontend/monitoring/store/mutations_spec.js b/spec/frontend/monitoring/store/mutations_spec.js index ab3debb798d..dd0deef486f 100644 --- a/spec/frontend/monitoring/store/mutations_spec.js +++ b/spec/frontend/monitoring/store/mutations_spec.js @@ -364,4 +364,18 @@ describe('Monitoring mutations', () => { expect(stateCopy.expandedPanel.panel).toEqual(null); }); }); + + describe('SET_PROM_QUERY_VARIABLES', () => { + it('stores an empty variables array when no custom variables are given', () => { + mutations[types.SET_PROM_QUERY_VARIABLES](stateCopy, {}); + + expect(stateCopy.promVariables).toEqual([]); + }); + + it('stores variables in the key key_value format in the array', () => { + mutations[types.SET_PROM_QUERY_VARIABLES](stateCopy, { pod: 'POD', stage: 'main ops' }); + + expect(stateCopy.promVariables).toEqual(['pod', 'POD', 'stage', 'main%20ops']); + }); + }); }); diff --git a/spec/frontend/monitoring/utils_spec.js b/spec/frontend/monitoring/utils_spec.js index b7e34853552..21597033e0a 100644 --- a/spec/frontend/monitoring/utils_spec.js +++ b/spec/frontend/monitoring/utils_spec.js @@ -169,6 +169,43 @@ describe('monitoring/utils', () => { }); }); + describe('promCustomVariablesFromUrl', () => { + const { promCustomVariablesFromUrl } = monitoringUtils; + + beforeEach(() => { + jest.spyOn(urlUtils, 'queryToObject'); + }); + + afterEach(() => { + urlUtils.queryToObject.mockRestore(); + }); + + it('returns an object with only the custom variables', () => { + urlUtils.queryToObject.mockReturnValueOnce({ + dashboard: '.gitlab/dashboards/custom_dashboard.yml', + y_label: 'memory usage', + group: 'kubernetes', + title: 'Kubernetes memory total', + start: '2020-05-06', + end: '2020-05-07', + duration_seconds: '86400', + direction: 'left', + anchor: 'top', + pod: 'POD', + }); + + expect(promCustomVariablesFromUrl()).toEqual(expect.objectContaining({ pod: 'POD' })); + }); + + it('returns an empty object when no custom variables are present', () => { + urlUtils.queryToObject.mockReturnValueOnce({ + dashboard: '.gitlab/dashboards/custom_dashboard.yml', + }); + + expect(promCustomVariablesFromUrl()).toStrictEqual({}); + }); + }); + describe('removeTimeRangeParams', () => { const { removeTimeRangeParams } = monitoringUtils; diff --git a/spec/frontend/notes/components/comment_form_spec.js b/spec/frontend/notes/components/comment_form_spec.js index a2c7f0b3767..e695fd8238d 100644 --- a/spec/frontend/notes/components/comment_form_spec.js +++ b/spec/frontend/notes/components/comment_form_spec.js @@ -24,6 +24,7 @@ describe('issue_comment_form component', () => { let store; let wrapper; let axiosMock; + let features = {}; const setupStore = (userData, noteableData) => { store.dispatch('setUserData', userData); @@ -37,12 +38,16 @@ describe('issue_comment_form component', () => { noteableType, }, store, + provide: { + glFeatures: features, + }, }); }; beforeEach(() => { axiosMock = new MockAdapter(axios); store = createStore(); + features = {}; }); afterEach(() => { @@ -298,6 +303,32 @@ describe('issue_comment_form component', () => { }); }); }); + + describe('when note can be confidential', () => { + it('appends confidential status to note payload when saving', () => { + jest.spyOn(wrapper.vm, 'saveNote').mockReturnValue(new Promise(() => {})); + + wrapper.vm.note = 'confidential note'; + + return wrapper.vm.$nextTick().then(() => { + wrapper.find('.js-comment-submit-button').trigger('click'); + + const [providedData] = wrapper.vm.saveNote.mock.calls[0]; + + expect(providedData.data.note.confidential).toBe(false); + }); + }); + + it('should render confidential toggle as false', () => { + features = { confidentialNotes: true }; + mountComponent(); + + const input = wrapper.find('.js-confidential-note-toggle .form-check-input'); + + expect(input.exists()).toBe(true); + expect(input.attributes('checked')).toBeFalsy(); + }); + }); }); describe('issue is confidential', () => { diff --git a/spec/frontend/notes/components/note_header_spec.js b/spec/frontend/notes/components/note_header_spec.js index 8cb78720c7e..19400e61b9c 100644 --- a/spec/frontend/notes/components/note_header_spec.js +++ b/spec/frontend/notes/components/note_header_spec.js @@ -19,6 +19,7 @@ describe('NoteHeader component', () => { const findActionText = () => wrapper.find({ ref: 'actionText' }); const findTimestampLink = () => wrapper.find({ ref: 'noteTimestampLink' }); const findTimestamp = () => wrapper.find({ ref: 'noteTimestamp' }); + const findConfidentialIndicator = () => wrapper.find({ ref: 'confidentialIndicator' }); const findSpinner = () => wrapper.find({ ref: 'spinner' }); const author = { @@ -246,4 +247,15 @@ describe('NoteHeader component', () => { }); }); }); + + describe('with confidentiality indicator', () => { + it.each` + status | condition + ${true} | ${'shows'} + ${false} | ${'hides'} + `('$condition icon indicator when isConfidential is $status', ({ status }) => { + createComponent({ isConfidential: status }); + expect(findConfidentialIndicator().exists()).toBe(status); + }); + }); }); diff --git a/spec/frontend/sidebar/assignees_realtime_spec.js b/spec/frontend/sidebar/assignees_realtime_spec.js index d6a6ca18fe8..1c62c52dc67 100644 --- a/spec/frontend/sidebar/assignees_realtime_spec.js +++ b/spec/frontend/sidebar/assignees_realtime_spec.js @@ -6,7 +6,9 @@ import Mock from './mock_data'; import query from '~/issuable_sidebar/queries/issue_sidebar.query.graphql'; jest.mock('@rails/actioncable', () => { - const mockConsumer = { subscriptions: { create: jest.fn() } }; + const mockConsumer = { + subscriptions: { create: jest.fn().mockReturnValue({ unsubscribe: jest.fn() }) }, + }; return { createConsumer: jest.fn().mockReturnValue(mockConsumer), }; |