diff options
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/ci/job_details/components/job_log_controllers_spec.js | 23 | ||||
-rw-r--r-- | spec/frontend/work_items/components/notes/work_item_note_awards_list_spec.js | 37 |
2 files changed, 23 insertions, 37 deletions
diff --git a/spec/frontend/ci/job_details/components/job_log_controllers_spec.js b/spec/frontend/ci/job_details/components/job_log_controllers_spec.js index 84c664aca34..4e1b9fe83da 100644 --- a/spec/frontend/ci/job_details/components/job_log_controllers_spec.js +++ b/spec/frontend/ci/job_details/components/job_log_controllers_spec.js @@ -30,17 +30,12 @@ describe('Job log controllers', () => { jobLog: mockJobLog, }; - const createWrapper = (props, { jobLogJumpToFailures = false } = {}) => { + const createWrapper = (props) => { wrapper = mount(JobLogControllers, { propsData: { ...defaultProps, ...props, }, - provide: { - glFeatures: { - jobLogJumpToFailures, - }, - }, data() { return { searchTerm: '82', @@ -199,14 +194,6 @@ describe('Job log controllers', () => { }); describe('scroll to failure button', () => { - describe('with feature flag disabled', () => { - it('does not display button', () => { - createWrapper(); - - expect(findScrollFailure().exists()).toBe(false); - }); - }); - describe('with red text failures on the page', () => { let firstFailure; let secondFailure; @@ -214,7 +201,7 @@ describe('Job log controllers', () => { beforeEach(() => { jest.spyOn(document, 'querySelectorAll').mockReturnValueOnce(['mock-element']); - createWrapper({}, { jobLogJumpToFailures: true }); + createWrapper(); firstFailure = document.createElement('div'); firstFailure.className = 'term-fg-l-red'; @@ -262,7 +249,7 @@ describe('Job log controllers', () => { beforeEach(() => { jest.spyOn(document, 'querySelectorAll').mockReturnValueOnce([]); - createWrapper({}, { jobLogJumpToFailures: true }); + createWrapper(); }); it('is disabled', () => { @@ -274,7 +261,7 @@ describe('Job log controllers', () => { beforeEach(() => { jest.spyOn(document, 'querySelectorAll').mockReturnValueOnce(['mock-element']); - createWrapper({ isComplete: false }, { jobLogJumpToFailures: true }); + createWrapper(); }); it('is enabled', () => { @@ -286,7 +273,7 @@ describe('Job log controllers', () => { beforeEach(() => { jest.spyOn(commonUtils, 'backOff').mockRejectedValueOnce(); - createWrapper({}, { jobLogJumpToFailures: true }); + createWrapper(); }); it('stays disabled', () => { diff --git a/spec/frontend/work_items/components/notes/work_item_note_awards_list_spec.js b/spec/frontend/work_items/components/notes/work_item_note_awards_list_spec.js index 939dd3e870b..6ce4c09329f 100644 --- a/spec/frontend/work_items/components/notes/work_item_note_awards_list_spec.js +++ b/spec/frontend/work_items/components/notes/work_item_note_awards_list_spec.js @@ -48,6 +48,7 @@ describe('Work Item Note Awards List', () => { const createComponent = ({ isGroup = false, note = firstNote, + query = workItemNotesByIidQuery, addAwardEmojiMutationHandler = addAwardEmojiMutationSuccessHandler, removeAwardEmojiMutationHandler = removeAwardEmojiMutationSuccessHandler, } = {}) => { @@ -57,7 +58,7 @@ describe('Work Item Note Awards List', () => { ]); apolloProvider.clients.defaultClient.writeQuery({ - query: isGroup ? groupWorkItemNotesByIidQuery : workItemNotesByIidQuery, + query, variables: { fullPath, iid: workItemIid }, ...mockWorkItemNotesResponseWithComments, }); @@ -94,10 +95,14 @@ describe('Work Item Note Awards List', () => { expect(findAwardsList().props('canAwardEmoji')).toBe(hasAwardEmojiPermission); }); - it.each([true, false])( + it.each` + isGroup | query + ${true} | ${groupWorkItemNotesByIidQuery} + ${false} | ${workItemNotesByIidQuery} + `( 'adds award if not already awarded in both group and project contexts', - async (isGroup) => { - createComponent({ isGroup }); + async ({ isGroup, query }) => { + createComponent({ isGroup, query }); await waitForPromises(); findAwardsList().vm.$emit('award', EMOJI_THUMBSUP); @@ -110,27 +115,25 @@ describe('Work Item Note Awards List', () => { ); it('emits error if awarding emoji fails', async () => { - createComponent({ - addAwardEmojiMutationHandler: jest.fn().mockRejectedValue('oh no'), - }); - await waitForPromises(); + createComponent({ addAwardEmojiMutationHandler: jest.fn().mockRejectedValue('oh no') }); findAwardsList().vm.$emit('award', EMOJI_THUMBSUP); - await waitForPromises(); expect(wrapper.emitted('error')).toEqual([[__('Failed to add emoji. Please try again')]]); }); - it.each([true, false])( + it.each` + isGroup | query + ${true} | ${groupWorkItemNotesByIidQuery} + ${false} | ${workItemNotesByIidQuery} + `( 'removes award if already awarded in both group and project contexts', - async (isGroup) => { + async ({ isGroup, query }) => { const removeAwardEmojiMutationHandler = removeAwardEmojiMutationSuccessHandler; - - createComponent({ isGroup, removeAwardEmojiMutationHandler }); + createComponent({ isGroup, query, removeAwardEmojiMutationHandler }); findAwardsList().vm.$emit('award', EMOJI_THUMBSDOWN); - await waitForPromises(); expect(removeAwardEmojiMutationHandler).toHaveBeenCalledWith({ @@ -141,13 +144,9 @@ describe('Work Item Note Awards List', () => { ); it('restores award if remove fails', async () => { - createComponent({ - removeAwardEmojiMutationHandler: jest.fn().mockRejectedValue('oh no'), - }); - await waitForPromises(); + createComponent({ removeAwardEmojiMutationHandler: jest.fn().mockRejectedValue('oh no') }); findAwardsList().vm.$emit('award', EMOJI_THUMBSDOWN); - await waitForPromises(); expect(wrapper.emitted('error')).toEqual([[__('Failed to remove emoji. Please try again')]]); |