diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-24 12:09:32 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-24 12:09:32 +0000 |
commit | a46b489e175708cc64fc5198f458f927558f11ba (patch) | |
tree | 96bb3be8fa37d729d1417b4e91df0bf718039911 /spec/frontend | |
parent | bd818d0618b0c1316c23f47f9ae41449e5d41fa8 (diff) | |
download | gitlab-ce-a46b489e175708cc64fc5198f458f927558f11ba.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
4 files changed, 87 insertions, 10 deletions
diff --git a/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js b/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js index 7ebaf0c3f2a..f02a261f323 100644 --- a/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js +++ b/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js @@ -44,13 +44,13 @@ describe('error tracking settings form', () => { const pageText = wrapper.text(); expect(pageText).toContain( - "If you self-host Sentry, enter the full URL of your Sentry instance. If you're using Sentry's hosted solution, enter https://sentry.io", + "If you self-host Sentry, enter your Sentry instance's full URL. If you use Sentry's hosted solution, enter https://sentry.io", ); expect(pageText).toContain( - "After adding your Auth Token, use the 'Connect' button to load projects", + 'After adding your Auth Token, select the Connect button to load projects.', ); - expect(pageText).not.toContain('Connection has failed. Re-check Auth Token and try again'); + expect(pageText).not.toContain('Connection failed. Check Auth Token and try again.'); expect(wrapper.findAll(GlFormInput).at(0).attributes('placeholder')).toContain( 'https://mysentryserver.com', ); @@ -80,9 +80,7 @@ describe('error tracking settings form', () => { }); it('does not show an error', () => { - expect(wrapper.text()).not.toContain( - 'Connection has failed. Re-check Auth Token and try again', - ); + expect(wrapper.text()).not.toContain('Connection failed. Check Auth Token and try again.'); }); }); @@ -96,7 +94,7 @@ describe('error tracking settings form', () => { }); it('shows an error', () => { - expect(wrapper.text()).toContain('Connection has failed. Re-check Auth Token and try again'); + expect(wrapper.text()).toContain('Connection failed. Check Auth Token and try again.'); }); }); }); diff --git a/spec/frontend/error_tracking_settings/store/getters_spec.js b/spec/frontend/error_tracking_settings/store/getters_spec.js index b135fdee40b..4bb8d38e294 100644 --- a/spec/frontend/error_tracking_settings/store/getters_spec.js +++ b/spec/frontend/error_tracking_settings/store/getters_spec.js @@ -78,7 +78,7 @@ describe('Error Tracking Settings - Getters', () => { describe('projectSelectionLabel', () => { it('should show the correct message when the token is empty', () => { expect(getters.projectSelectionLabel(state)).toEqual( - 'To enable project selection, enter a valid Auth Token', + 'To enable project selection, enter a valid Auth Token.', ); }); @@ -86,7 +86,7 @@ describe('Error Tracking Settings - Getters', () => { state.token = 'test-token'; expect(getters.projectSelectionLabel(state)).toEqual( - "Click 'Connect' to re-establish the connection to Sentry and activate the dropdown.", + 'Click Connect to reestablish the connection to Sentry and activate the dropdown.', ); }); }); diff --git a/spec/frontend/mr_notes/stores/actions_spec.js b/spec/frontend/mr_notes/stores/actions_spec.js index dbceedface1..c6578453d85 100644 --- a/spec/frontend/mr_notes/stores/actions_spec.js +++ b/spec/frontend/mr_notes/stores/actions_spec.js @@ -1,5 +1,9 @@ +import MockAdapter from 'axios-mock-adapter'; + import testAction from 'helpers/vuex_action_helper'; -import { setEndpoints } from '~/mr_notes/stores/actions'; +import axios from '~/lib/utils/axios_utils'; + +import { setEndpoints, setMrMetadata, fetchMrMetadata } from '~/mr_notes/stores/actions'; import mutationTypes from '~/mr_notes/stores/mutation_types'; describe('MR Notes Mutator Actions', () => { @@ -22,4 +26,67 @@ describe('MR Notes Mutator Actions', () => { ); }); }); + + describe('setMrMetadata', () => { + it('should trigger the SET_MR_METADATA state mutation', async () => { + const mrMetadata = { propA: 'a', propB: 'b' }; + + await testAction( + setMrMetadata, + mrMetadata, + {}, + [ + { + type: mutationTypes.SET_MR_METADATA, + payload: mrMetadata, + }, + ], + [], + ); + }); + }); + + describe('fetchMrMetadata', () => { + const mrMetadata = { meta: true, data: 'foo' }; + const state = { + endpoints: { + metadata: 'metadata', + }, + }; + let mock; + + beforeEach(() => { + mock = new MockAdapter(axios); + + mock.onGet(state.endpoints.metadata).reply(200, mrMetadata); + }); + + afterEach(() => { + mock.restore(); + }); + + it('should fetch the data from the API', async () => { + await fetchMrMetadata({ state, dispatch: () => {} }); + + await axios.waitForAll(); + + expect(mock.history.get).toHaveLength(1); + expect(mock.history.get[0].url).toBe(state.endpoints.metadata); + }); + + it('should set the fetched data into state', () => { + return testAction( + fetchMrMetadata, + {}, + state, + [], + [ + { + type: 'setMrMetadata', + payload: mrMetadata, + }, + ], + ); + }); + }); }); diff --git a/spec/frontend/mr_notes/stores/mutations_spec.js b/spec/frontend/mr_notes/stores/mutations_spec.js index 422db3d5a38..35b8a2e4be2 100644 --- a/spec/frontend/mr_notes/stores/mutations_spec.js +++ b/spec/frontend/mr_notes/stores/mutations_spec.js @@ -12,4 +12,16 @@ describe('MR Notes Mutations', () => { expect(state.endpoints).toEqual(endpoints); }); }); + + describe(mutationTypes.SET_MR_METADATA, () => { + it('store the provided MR Metadata in the state', () => { + const state = {}; + const metadata = { propA: 'A', propB: 'B' }; + + mutations[mutationTypes.SET_MR_METADATA](state, metadata); + + expect(state.mrMetadata.propA).toBe('A'); + expect(state.mrMetadata.propB).toBe('B'); + }); + }); }); |