Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/work_items/components/notes/work_item_add_note_spec.js')
-rw-r--r--spec/frontend/work_items/components/notes/work_item_add_note_spec.js60
1 files changed, 47 insertions, 13 deletions
diff --git a/spec/frontend/work_items/components/notes/work_item_add_note_spec.js b/spec/frontend/work_items/components/notes/work_item_add_note_spec.js
index 826fc2b2230..b2b372d9d0d 100644
--- a/spec/frontend/work_items/components/notes/work_item_add_note_spec.js
+++ b/spec/frontend/work_items/components/notes/work_item_add_note_spec.js
@@ -10,9 +10,11 @@ import WorkItemCommentLocked from '~/work_items/components/notes/work_item_comme
import WorkItemCommentForm from '~/work_items/components/notes/work_item_comment_form.vue';
import createNoteMutation from '~/work_items/graphql/notes/create_work_item_note.mutation.graphql';
import { TRACKING_CATEGORY_SHOW } from '~/work_items/constants';
+import groupWorkItemByIidQuery from '~/work_items/graphql/group_work_item_by_iid.query.graphql';
import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql';
import {
createWorkItemNoteResponse,
+ groupWorkItemByIidResponseFactory,
workItemByIidResponseFactory,
workItemQueryResponse,
} from '../../mock_data';
@@ -29,6 +31,7 @@ describe('Work item add note', () => {
const mutationSuccessHandler = jest.fn().mockResolvedValue(createWorkItemNoteResponse);
let workItemResponseHandler;
+ let groupWorkItemResponseHandler;
const findCommentForm = () => wrapper.findComponent(WorkItemCommentForm);
const findTextarea = () => wrapper.findByTestId('note-reply-textarea');
@@ -40,29 +43,32 @@ describe('Work item add note', () => {
canCreateNote = true,
workItemIid = '1',
workItemResponse = workItemByIidResponseFactory({ canUpdate, canCreateNote }),
+ groupWorkItemResponse = groupWorkItemByIidResponseFactory({ canUpdate, canCreateNote }),
signedIn = true,
isEditing = true,
+ isGroup = false,
workItemType = 'Task',
isInternalThread = false,
} = {}) => {
workItemResponseHandler = jest.fn().mockResolvedValue(workItemResponse);
+ groupWorkItemResponseHandler = jest.fn().mockResolvedValue(groupWorkItemResponse);
if (signedIn) {
window.gon.current_user_id = '1';
window.gon.current_user_avatar_url = 'avatar.png';
}
- const apolloProvider = createMockApollo([
- [workItemByIidQuery, workItemResponseHandler],
- [createNoteMutation, mutationHandler],
- ]);
-
const { id } = workItemQueryResponse.data.workItem;
wrapper = shallowMountExtended(WorkItemAddNote, {
- apolloProvider,
+ apolloProvider: createMockApollo([
+ [workItemByIidQuery, workItemResponseHandler],
+ [groupWorkItemByIidQuery, groupWorkItemResponseHandler],
+ [createNoteMutation, mutationHandler],
+ ]),
provide: {
- fullPath: 'test-project-path',
+ isGroup,
},
propsData: {
+ fullPath: 'test-project-path',
workItemId: id,
workItemIid,
workItemType,
@@ -272,16 +278,44 @@ describe('Work item add note', () => {
});
});
- it('calls the work item query', async () => {
- await createComponent();
+ describe('when project context', () => {
+ it('calls the project work item query', async () => {
+ await createComponent();
+
+ expect(workItemResponseHandler).toHaveBeenCalled();
+ });
+
+ it('skips calling the group work item query', async () => {
+ await createComponent();
+
+ expect(groupWorkItemResponseHandler).not.toHaveBeenCalled();
+ });
+
+ it('skips calling the project work item query when missing workItemIid', async () => {
+ await createComponent({ workItemIid: '', isEditing: false });
- expect(workItemResponseHandler).toHaveBeenCalled();
+ expect(workItemResponseHandler).not.toHaveBeenCalled();
+ });
});
- it('skips calling the work item query when missing workItemIid', async () => {
- await createComponent({ workItemIid: '', isEditing: false });
+ describe('when group context', () => {
+ it('skips calling the project work item query', async () => {
+ await createComponent({ isGroup: true });
+
+ expect(workItemResponseHandler).not.toHaveBeenCalled();
+ });
+
+ it('calls the group work item query', async () => {
+ await createComponent({ isGroup: true });
- expect(workItemResponseHandler).not.toHaveBeenCalled();
+ expect(groupWorkItemResponseHandler).toHaveBeenCalled();
+ });
+
+ it('skips calling the group work item query when missing workItemIid', async () => {
+ await createComponent({ isGroup: true, workItemIid: '', isEditing: false });
+
+ expect(groupWorkItemResponseHandler).not.toHaveBeenCalled();
+ });
});
it('wrapper adds `internal-note` class when internal thread', async () => {