diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
commit | ee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch) | |
tree | f8479f94a28f66654c6a4f6fb99bad6b4e86a40e /spec/frontend/notes/components/notes_app_spec.js | |
parent | 62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff) |
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'spec/frontend/notes/components/notes_app_spec.js')
-rw-r--r-- | spec/frontend/notes/components/notes_app_spec.js | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/spec/frontend/notes/components/notes_app_spec.js b/spec/frontend/notes/components/notes_app_spec.js index d4cb07d97dc..9051fcab97f 100644 --- a/spec/frontend/notes/components/notes_app_spec.js +++ b/spec/frontend/notes/components/notes_app_spec.js @@ -11,6 +11,7 @@ import axios from '~/lib/utils/axios_utils'; import * as urlUtility from '~/lib/utils/url_utility'; import CommentForm from '~/notes/components/comment_form.vue'; import NotesApp from '~/notes/components/notes_app.vue'; +import NotesActivityHeader from '~/notes/components/notes_activity_header.vue'; import * as constants from '~/notes/constants'; import createStore from '~/notes/stores'; import '~/behaviors/markdown/render_gfm'; @@ -20,11 +21,14 @@ import * as mockData from '../mock_data'; const TYPE_COMMENT_FORM = 'comment-form'; const TYPE_NOTES_LIST = 'notes-list'; +const TEST_NOTES_FILTER_VALUE = 1; const propsData = { noteableData: mockData.noteableDataMock, notesData: mockData.notesDataMock, userData: mockData.userDataMock, + notesFilters: mockData.notesFilters, + notesFilterValue: TEST_NOTES_FILTER_VALUE, }; describe('note_app', () => { @@ -47,7 +51,7 @@ describe('note_app', () => { axiosMock = new AxiosMockAdapter(axios); store = createStore(); - mountComponent = () => { + mountComponent = ({ props = {} } = {}) => { return mount( { components: { @@ -58,7 +62,10 @@ describe('note_app', () => { </div>`, }, { - propsData, + propsData: { + ...propsData, + ...props, + }, store, }, ); @@ -144,6 +151,13 @@ describe('note_app', () => { it('updates discussions badge', () => { expect(document.querySelector('.js-discussions-count').textContent).toEqual('2'); }); + + it('should render notes activity header', () => { + expect(wrapper.findComponent(NotesActivityHeader).props()).toEqual({ + notesFilterValue: TEST_NOTES_FILTER_VALUE, + notesFilters: mockData.notesFilters, + }); + }); }); describe('render with comments disabled', () => { @@ -151,8 +165,15 @@ describe('note_app', () => { setHTMLFixture('<div class="js-discussions-count"></div>'); axiosMock.onAny().reply(mockData.getIndividualNoteResponse); - store.state.commentsDisabled = true; - wrapper = mountComponent(); + wrapper = mountComponent({ + // why: In this integration test, previously we manually set store.state.commentsDisabled + // This stopped working when we added `<discussion-filter>` into the component tree. + // Let's lean into the integration scope and use a prop that "disables comments". + props: { + notesFilterValue: constants.HISTORY_ONLY_FILTER_VALUE, + }, + }); + return waitForPromises(); }); @@ -358,7 +379,7 @@ describe('note_app', () => { it('should listen hashchange event', () => { const notesApp = wrapper.findComponent(NotesApp); const hash = 'some dummy hash'; - jest.spyOn(urlUtility, 'getLocationHash').mockReturnValueOnce(hash); + jest.spyOn(urlUtility, 'getLocationHash').mockReturnValue(hash); const setTargetNoteHash = jest.spyOn(notesApp.vm, 'setTargetNoteHash'); window.dispatchEvent(new Event('hashchange'), hash); |