diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-09 21:07:34 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-09 21:07:34 +0000 |
commit | 6bed1b9c9cc989a19fb2caab5ad61bbfc811f25d (patch) | |
tree | 0d19af042fb956493c89875b13b979bde861a13e /spec/frontend | |
parent | 20f6a17ba2d2d5f056bda38dfe85e2a7b2a82d0b (diff) | |
download | gitlab-ce-6bed1b9c9cc989a19fb2caab5ad61bbfc811f25d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
3 files changed, 146 insertions, 159 deletions
diff --git a/spec/frontend/vue_shared/components/sidebar/labels_select_widget/labels_select_root_spec.js b/spec/frontend/vue_shared/components/sidebar/labels_select_widget/labels_select_root_spec.js index b58c44645d6..74ddd07d041 100644 --- a/spec/frontend/vue_shared/components/sidebar/labels_select_widget/labels_select_root_spec.js +++ b/spec/frontend/vue_shared/components/sidebar/labels_select_widget/labels_select_root_spec.js @@ -49,7 +49,6 @@ describe('LabelsSelectRoot', () => { issuableType = IssuableType.Issue, queryHandler = successfulQueryHandler, mutationHandler = successfulMutationHandler, - isRealtimeEnabled = false, } = {}) => { const mockApollo = createMockApollo([ [issueLabelsQuery, queryHandler], @@ -74,9 +73,6 @@ describe('LabelsSelectRoot', () => { allowLabelEdit: true, allowLabelCreate: true, labelsManagePath: 'test', - glFeatures: { - realtimeLabels: isRealtimeEnabled, - }, }, }); }; @@ -204,17 +200,10 @@ describe('LabelsSelectRoot', () => { }); }); - it('does not emit `updateSelectedLabels` event when the subscription is triggered and FF is disabled', async () => { + it('emits `updateSelectedLabels` event when the subscription is triggered', async () => { createComponent(); await waitForPromises(); - expect(wrapper.emitted('updateSelectedLabels')).toBeUndefined(); - }); - - it('emits `updateSelectedLabels` event when the subscription is triggered and FF is enabled', async () => { - createComponent({ isRealtimeEnabled: true }); - await waitForPromises(); - expect(wrapper.emitted('updateSelectedLabels')).toEqual([ [ { diff --git a/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js b/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js index f55d3156581..e1c6020686c 100644 --- a/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js +++ b/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js @@ -543,24 +543,6 @@ describe('IssuableItem', () => { }); }); - describe('when issuable was created within the past 24 hours', () => { - it('renders issuable card with a recently-created style', () => { - wrapper = createComponent({ - issuable: { ...mockIssuable, createdAt: '2020-12-10T12:34:56' }, - }); - - expect(wrapper.classes()).toContain('today'); - }); - }); - - describe('when issuable was created earlier than the past 24 hours', () => { - it('renders issuable card without a recently-created style', () => { - wrapper = createComponent({ issuable: { ...mockIssuable, createdAt: '2020-12-09' } }); - - expect(wrapper.classes()).not.toContain('today'); - }); - }); - describe('scoped labels', () => { describe.each` description | labelPosition | hasScopedLabelsFeature | scoped diff --git a/spec/frontend/work_items/components/work_item_description_spec.js b/spec/frontend/work_items/components/work_item_description_spec.js index 60889870750..c79b049442d 100644 --- a/spec/frontend/work_items/components/work_item_description_spec.js +++ b/spec/frontend/work_items/components/work_item_description_spec.js @@ -8,6 +8,7 @@ import EditedAt from '~/issues/show/components/edited.vue'; import { updateDraft } from '~/lib/utils/autosave'; import { confirmAction } from '~/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal'; import MarkdownField from '~/vue_shared/components/markdown/field.vue'; +import MarkdownEditor from '~/vue_shared/components/markdown/markdown_editor.vue'; import WorkItemDescription from '~/work_items/components/work_item_description.vue'; import WorkItemDescriptionRendered from '~/work_items/components/work_item_description_rendered.vue'; import { TRACKING_CATEGORY_SHOW } from '~/work_items/constants'; @@ -37,12 +38,19 @@ describe('WorkItemDescription', () => { const subscriptionHandler = jest.fn().mockResolvedValue(workItemDescriptionSubscriptionResponse); const workItemByIidResponseHandler = jest.fn().mockResolvedValue(projectWorkItemResponse); let workItemResponseHandler; + let workItemsMvc2; const findMarkdownField = () => wrapper.findComponent(MarkdownField); + const findMarkdownEditor = () => wrapper.findComponent(MarkdownEditor); const findRenderedDescription = () => wrapper.findComponent(WorkItemDescriptionRendered); const findEditedAt = () => wrapper.findComponent(EditedAt); - const editDescription = (newText) => wrapper.find('textarea').setValue(newText); + const editDescription = (newText) => { + if (workItemsMvc2) { + return findMarkdownEditor().vm.$emit('input', newText); + } + return wrapper.find('textarea').setValue(newText); + }; const clickCancel = () => wrapper.find('[data-testid="cancel"]').vm.$emit('click'); const clickSave = () => wrapper.find('[data-testid="save-description"]').vm.$emit('click', {}); @@ -72,6 +80,11 @@ describe('WorkItemDescription', () => { }, fetchByIid, }, + provide: { + glFeatures: { + workItemsMvc2, + }, + }, stubs: { MarkdownField, }, @@ -90,175 +103,178 @@ describe('WorkItemDescription', () => { wrapper.destroy(); }); - it('has a subscription', async () => { - createComponent(); + describe.each([true, false])( + 'editing description with workItemsMvc2 %workItemsMvc2Enabled', + (workItemsMvc2Enabled) => { + beforeEach(() => { + beforeEach(() => { + workItemsMvc2 = workItemsMvc2Enabled; + }); + }); - await waitForPromises(); + describe('editing description', () => { + it('shows edited by text', async () => { + const lastEditedAt = '2022-09-21T06:18:42Z'; + const lastEditedBy = { + name: 'Administrator', + webPath: '/root', + }; - expect(subscriptionHandler).toHaveBeenCalledWith({ - issuableId: workItemQueryResponse.data.workItem.id, - }); - }); + await createComponent({ + workItemResponse: workItemResponseFactory({ + lastEditedAt, + lastEditedBy, + }), + }); - describe('editing description', () => { - it('shows edited by text', async () => { - const lastEditedAt = '2022-09-21T06:18:42Z'; - const lastEditedBy = { - name: 'Administrator', - webPath: '/root', - }; - - await createComponent({ - workItemResponse: workItemResponseFactory({ - lastEditedAt, - lastEditedBy, - }), - }); + expect(findEditedAt().props()).toEqual({ + updatedAt: lastEditedAt, + updatedByName: lastEditedBy.name, + updatedByPath: lastEditedBy.webPath, + }); + }); - expect(findEditedAt().props()).toEqual({ - updatedAt: lastEditedAt, - updatedByName: lastEditedBy.name, - updatedByPath: lastEditedBy.webPath, - }); - }); + it('does not show edited by text', async () => { + await createComponent(); - it('does not show edited by text', async () => { - await createComponent(); + expect(findEditedAt().exists()).toBe(false); + }); - expect(findEditedAt().exists()).toBe(false); - }); + it('cancels when clicking cancel', async () => { + await createComponent({ + isEditing: true, + }); - it('cancels when clicking cancel', async () => { - await createComponent({ - isEditing: true, - }); + clickCancel(); - clickCancel(); + await nextTick(); - await nextTick(); + expect(confirmAction).not.toHaveBeenCalled(); + expect(findMarkdownField().exists()).toBe(false); + }); - expect(confirmAction).not.toHaveBeenCalled(); - expect(findMarkdownField().exists()).toBe(false); - }); + it('prompts for confirmation when clicking cancel after changes', async () => { + await createComponent({ + isEditing: true, + }); - it('prompts for confirmation when clicking cancel after changes', async () => { - await createComponent({ - isEditing: true, - }); + editDescription('updated desc'); - editDescription('updated desc'); + clickCancel(); - clickCancel(); + await nextTick(); - await nextTick(); + expect(confirmAction).toHaveBeenCalled(); + }); - expect(confirmAction).toHaveBeenCalled(); - }); + it('calls update widgets mutation', async () => { + const updatedDesc = 'updated desc'; - it('calls update widgets mutation', async () => { - await createComponent({ - isEditing: true, - }); + await createComponent({ + isEditing: true, + }); - editDescription('updated desc'); + editDescription(updatedDesc); - clickSave(); + clickSave(); - await waitForPromises(); + await waitForPromises(); - expect(mutationSuccessHandler).toHaveBeenCalledWith({ - input: { - id: workItemId, - descriptionWidget: { - description: 'updated desc', - }, - }, - }); - }); + expect(mutationSuccessHandler).toHaveBeenCalledWith({ + input: { + id: workItemId, + descriptionWidget: { + description: updatedDesc, + }, + }, + }); + }); - it('tracks editing description', async () => { - await createComponent({ - isEditing: true, - markdownPreviewPath: '/preview', - }); - const trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn); + it('tracks editing description', async () => { + await createComponent({ + isEditing: true, + markdownPreviewPath: '/preview', + }); + const trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn); - clickSave(); + clickSave(); - await waitForPromises(); + await waitForPromises(); - expect(trackingSpy).toHaveBeenCalledWith(TRACKING_CATEGORY_SHOW, 'updated_description', { - category: TRACKING_CATEGORY_SHOW, - label: 'item_description', - property: 'type_Task', - }); - }); + expect(trackingSpy).toHaveBeenCalledWith(TRACKING_CATEGORY_SHOW, 'updated_description', { + category: TRACKING_CATEGORY_SHOW, + label: 'item_description', + property: 'type_Task', + }); + }); - it('emits error when mutation returns error', async () => { - const error = 'eror'; + it('emits error when mutation returns error', async () => { + const error = 'eror'; - await createComponent({ - isEditing: true, - mutationHandler: jest.fn().mockResolvedValue({ - data: { - workItemUpdate: { - workItem: {}, - errors: [error], - }, - }, - }), - }); + await createComponent({ + isEditing: true, + mutationHandler: jest.fn().mockResolvedValue({ + data: { + workItemUpdate: { + workItem: {}, + errors: [error], + }, + }, + }), + }); - editDescription('updated desc'); + editDescription('updated desc'); - clickSave(); + clickSave(); - await waitForPromises(); + await waitForPromises(); - expect(wrapper.emitted('error')).toEqual([[error]]); - }); + expect(wrapper.emitted('error')).toEqual([[error]]); + }); - it('emits error when mutation fails', async () => { - const error = 'eror'; + it('emits error when mutation fails', async () => { + const error = 'eror'; - await createComponent({ - isEditing: true, - mutationHandler: jest.fn().mockRejectedValue(new Error(error)), - }); + await createComponent({ + isEditing: true, + mutationHandler: jest.fn().mockRejectedValue(new Error(error)), + }); - editDescription('updated desc'); + editDescription('updated desc'); - clickSave(); + clickSave(); - await waitForPromises(); + await waitForPromises(); - expect(wrapper.emitted('error')).toEqual([[error]]); - }); + expect(wrapper.emitted('error')).toEqual([[error]]); + }); - it('autosaves description', async () => { - await createComponent({ - isEditing: true, - }); + it('autosaves description', async () => { + await createComponent({ + isEditing: true, + }); - editDescription('updated desc'); + editDescription('updated desc'); - expect(updateDraft).toHaveBeenCalled(); - }); - }); + expect(updateDraft).toHaveBeenCalled(); + }); + }); - it('calls the global ID work item query when `fetchByIid` prop is false', async () => { - createComponent({ fetchByIid: false }); - await waitForPromises(); + it('calls the global ID work item query when `fetchByIid` prop is false', async () => { + createComponent({ fetchByIid: false }); + await waitForPromises(); - expect(workItemResponseHandler).toHaveBeenCalled(); - expect(workItemByIidResponseHandler).not.toHaveBeenCalled(); - }); + expect(workItemResponseHandler).toHaveBeenCalled(); + expect(workItemByIidResponseHandler).not.toHaveBeenCalled(); + }); - it('calls the IID work item query when when `fetchByIid` prop is true', async () => { - createComponent({ fetchByIid: true }); - await waitForPromises(); + it('calls the IID work item query when when `fetchByIid` prop is true', async () => { + createComponent({ fetchByIid: true }); + await waitForPromises(); - expect(workItemResponseHandler).not.toHaveBeenCalled(); - expect(workItemByIidResponseHandler).toHaveBeenCalled(); - }); + expect(workItemResponseHandler).not.toHaveBeenCalled(); + expect(workItemByIidResponseHandler).toHaveBeenCalled(); + }); + }, + ); }); |