Commit 976bd89d authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '267503-use-mock-apollo-client-for-testing-in-requirement_root_spec-js' into 'master'

Use mock apollo client in requirement_root_spec.js

See merge request gitlab-org/gitlab!56730
parents ccd12b43 27464ebd
......@@ -725,6 +725,7 @@ export default {
@drawer-close="handleNewRequirementCancel"
/>
<requirement-edit-form
data-testid="edit-form"
:drawer-open="showRequirementViewDrawer"
:requirement="editedRequirement"
:enable-requirement-edit="enableRequirementEdit"
......
......@@ -174,3 +174,136 @@ export const mockStatusToken = {
token: StatusToken,
operators: [{ value: '=', description: 'is', default: 'true' }],
};
/*
Mock data used for testing with mock apollo client
*/
export const mockInitialRequirementCounts = {
ARCHIVED: 0,
OPENED: 1,
ALL: 1,
};
export const mockProjectRequirementCounts = {
data: {
project: {
requirementStatesCount: {
opened: mockInitialRequirementCounts.OPENED,
archived: mockInitialRequirementCounts.ARCHIVED,
__typename: 'RequirementStatesCount',
},
__typename: 'Project',
},
},
};
const mockUser = {
...mockAuthor,
id: 'gid://gitlab/User/1',
__typename: 'User',
};
export const mockTestReportConnectionPassed = {
nodes: [mockTestReport],
__typename: 'TestReportConnection',
};
export const mockTestReportConnectionFailed = {
nodes: [mockTestReportFailed],
__typename: 'TestReportConnection',
};
export const mockEmptyTestReportConnection = {
nodes: [],
__typename: 'TestReportConnection',
};
const projectRequirementBase = {
__typename: 'Requirement',
iid: '1',
title: 'Requirement 1',
titleHtml: 'Requirement 1',
description: '',
descriptionHtml: '',
createdAt: '2021-03-15T05:24:32Z',
updatedAt: '2021-03-15T05:24:32Z',
state: 'OPENED',
userPermissions: {
updateRequirement: true,
adminRequirement: true,
__typename: 'RequirementPermissions',
},
author: {
...mockUser,
},
};
export const mockProjectRequirementFailed = {
...projectRequirementBase,
lastTestReportState: 'FAILED',
lastTestReportManuallyCreated: true,
testReports: {
...mockTestReportConnectionFailed,
},
};
export const mockProjectRequirementPassed = {
...projectRequirementBase,
lastTestReportState: 'PASSED',
lastTestReportManuallyCreated: true,
testReports: {
...mockTestReportConnectionPassed,
},
};
export const mockUpdateRequirementTitle = {
data: {
updateRequirement: {
clientMutationId: null,
errors: [],
requirement: {
...mockProjectRequirementPassed,
title: 'edited title',
},
__typename: 'UpdateRequirementPayload',
},
},
};
export const mockUpdateRequirementToFailed = {
data: {
updateRequirement: {
clientMutationId: null,
errors: [],
requirement: {
...mockProjectRequirementFailed,
},
__typename: 'UpdateRequirementPayload',
},
},
};
const mockRequirementConnection = {
nodes: [],
pageInfo: {
__typename: 'PageInfo',
hasNextPage: false,
hasPreviousPage: false,
startCursor: 'eyJpZCI6',
endCursor: 'eyJpZCI6I',
},
__typename: 'RequirementConnection',
};
export const mockProjectRequirements = {
data: {
project: {
requirements: {
...mockRequirementConnection,
nodes: [{ ...mockProjectRequirementPassed }],
},
__typename: 'Project',
},
},
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment