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/work_item_created_updated_spec.js')
-rw-r--r--spec/frontend/work_items/components/work_item_created_updated_spec.js64
1 files changed, 57 insertions, 7 deletions
diff --git a/spec/frontend/work_items/components/work_item_created_updated_spec.js b/spec/frontend/work_items/components/work_item_created_updated_spec.js
index f77c5481906..3f14615e173 100644
--- a/spec/frontend/work_items/components/work_item_created_updated_spec.js
+++ b/spec/frontend/work_items/components/work_item_created_updated_spec.js
@@ -7,12 +7,18 @@ import waitForPromises from 'helpers/wait_for_promises';
import WorkItemCreatedUpdated from '~/work_items/components/work_item_created_updated.vue';
import ConfidentialityBadge from '~/vue_shared/components/confidentiality_badge.vue';
import WorkItemTypeIcon from '~/work_items/components/work_item_type_icon.vue';
+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 { workItemByIidResponseFactory, mockAssignees } from '../mock_data';
+import {
+ groupWorkItemByIidResponseFactory,
+ mockAssignees,
+ workItemByIidResponseFactory,
+} from '../mock_data';
describe('WorkItemCreatedUpdated component', () => {
let wrapper;
let successHandler;
+ let groupSuccessHandler;
Vue.use(VueApollo);
@@ -30,21 +36,31 @@ describe('WorkItemCreatedUpdated component', () => {
updatedAt,
confidential = false,
updateInProgress = false,
+ isGroup = false,
} = {}) => {
- const workItemQueryResponse = workItemByIidResponseFactory({
+ const workItemQueryResponse = workItemByIidResponseFactory({ author, updatedAt, confidential });
+ const groupWorkItemQueryResponse = groupWorkItemByIidResponseFactory({
author,
updatedAt,
confidential,
});
successHandler = jest.fn().mockResolvedValue(workItemQueryResponse);
+ groupSuccessHandler = jest.fn().mockResolvedValue(groupWorkItemQueryResponse);
wrapper = shallowMount(WorkItemCreatedUpdated, {
- apolloProvider: createMockApollo([[workItemByIidQuery, successHandler]]),
+ apolloProvider: createMockApollo([
+ [workItemByIidQuery, successHandler],
+ [groupWorkItemByIidQuery, groupSuccessHandler],
+ ]),
provide: {
+ isGroup,
+ },
+ propsData: {
fullPath: '/some/project',
+ workItemIid,
+ updateInProgress,
},
- propsData: { workItemIid, updateInProgress },
stubs: {
GlAvatarLink,
GlSprintf,
@@ -54,10 +70,44 @@ describe('WorkItemCreatedUpdated component', () => {
await waitForPromises();
};
- it('skips the work item query when workItemIid is not defined', async () => {
- await createComponent({ workItemIid: null });
+ describe('when project context', () => {
+ it('calls the project work item query', async () => {
+ await createComponent();
+
+ expect(successHandler).toHaveBeenCalled();
+ });
+
+ it('skips calling the group work item query', async () => {
+ await createComponent();
+
+ expect(groupSuccessHandler).not.toHaveBeenCalled();
+ });
+
+ it('skips calling the project work item query when workItemIid is not defined', async () => {
+ await createComponent({ workItemIid: null });
+
+ expect(successHandler).not.toHaveBeenCalled();
+ });
+ });
+
+ describe('when group context', () => {
+ it('skips calling the project work item query', async () => {
+ await createComponent({ isGroup: true });
+
+ expect(successHandler).not.toHaveBeenCalled();
+ });
+
+ it('calls the group work item query', async () => {
+ await createComponent({ isGroup: true });
- expect(successHandler).not.toHaveBeenCalled();
+ expect(groupSuccessHandler).toHaveBeenCalled();
+ });
+
+ it('skips calling the group work item query when workItemIid is not defined', async () => {
+ await createComponent({ isGroup: true, workItemIid: null });
+
+ expect(groupSuccessHandler).not.toHaveBeenCalled();
+ });
});
it('shows work item type metadata with type and icon', async () => {