debian-mirror-gitlab/spec/frontend/work_items/mock_data.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

562 lines
13 KiB
JavaScript
Raw Normal View History

2022-08-13 15:12:31 +05:30
export const mockAssignees = [
{
__typename: 'UserCore',
id: 'gid://gitlab/User/1',
avatarUrl: '',
webUrl: '',
name: 'John Doe',
username: 'doe_I',
},
{
__typename: 'UserCore',
id: 'gid://gitlab/User/2',
avatarUrl: '',
webUrl: '',
name: 'Marcus Rutherford',
username: 'ruthfull',
},
];
2021-12-11 22:18:48 +05:30
export const workItemQueryResponse = {
2022-06-21 17:19:12 +05:30
data: {
workItem: {
__typename: 'WorkItem',
id: 'gid://gitlab/WorkItem/1',
title: 'Test',
2022-07-16 23:28:13 +05:30
state: 'OPEN',
description: 'description',
2022-06-21 17:19:12 +05:30
workItemType: {
__typename: 'WorkItemType',
id: 'gid://gitlab/WorkItems::Type/5',
name: 'Task',
},
2022-07-16 23:28:13 +05:30
userPermissions: {
deleteWorkItem: false,
updateWorkItem: false,
},
2022-07-23 23:45:48 +05:30
widgets: [
{
__typename: 'WorkItemWidgetDescription',
type: 'DESCRIPTION',
description: 'some **great** text',
descriptionHtml:
'<p data-sourcepos="1:1-1:19" dir="auto">some <strong>great</strong> text</p>',
},
2022-08-13 15:12:31 +05:30
{
__typename: 'WorkItemWidgetAssignees',
type: 'ASSIGNEES',
allowsMultipleAssignees: true,
assignees: {
nodes: mockAssignees,
},
},
{
__typename: 'WorkItemWidgetHierarchy',
type: 'HIERARCHY',
parent: {
id: 'gid://gitlab/Issue/1',
iid: '5',
title: 'Parent title',
},
children: {
edges: [
{
node: {
id: 'gid://gitlab/WorkItem/444',
},
},
],
},
},
2022-07-23 23:45:48 +05:30
],
2021-12-11 22:18:48 +05:30
},
},
};
2022-01-26 12:08:38 +05:30
export const updateWorkItemMutationResponse = {
2022-05-07 20:08:51 +05:30
data: {
workItemUpdate: {
2022-06-21 17:19:12 +05:30
__typename: 'WorkItemUpdatePayload',
2022-05-07 20:08:51 +05:30
workItem: {
2022-06-21 17:19:12 +05:30
__typename: 'WorkItem',
id: 'gid://gitlab/WorkItem/1',
2022-05-07 20:08:51 +05:30
title: 'Updated title',
2022-07-16 23:28:13 +05:30
state: 'OPEN',
description: 'description',
2022-05-07 20:08:51 +05:30
workItemType: {
__typename: 'WorkItemType',
2022-06-21 17:19:12 +05:30
id: 'gid://gitlab/WorkItems::Type/5',
name: 'Task',
2022-05-07 20:08:51 +05:30
},
2022-07-16 23:28:13 +05:30
userPermissions: {
deleteWorkItem: false,
updateWorkItem: false,
},
2022-08-13 15:12:31 +05:30
widgets: [
{
children: {
edges: [
{
node: 'gid://gitlab/WorkItem/444',
},
],
},
},
],
2022-05-07 20:08:51 +05:30
},
2022-01-26 12:08:38 +05:30
},
},
};
2022-04-04 11:22:00 +05:30
2022-08-13 15:12:31 +05:30
export const workItemResponseFactory = ({
canUpdate = false,
allowsMultipleAssignees = true,
assigneesWidgetPresent = true,
parent = null,
} = {}) => ({
2022-07-23 23:45:48 +05:30
data: {
workItem: {
__typename: 'WorkItem',
id: 'gid://gitlab/WorkItem/1',
title: 'Updated title',
state: 'OPEN',
description: 'description',
workItemType: {
__typename: 'WorkItemType',
id: 'gid://gitlab/WorkItems::Type/5',
name: 'Task',
},
userPermissions: {
deleteWorkItem: false,
updateWorkItem: canUpdate,
},
widgets: [
{
__typename: 'WorkItemWidgetDescription',
type: 'DESCRIPTION',
description: 'some **great** text',
descriptionHtml:
'<p data-sourcepos="1:1-1:19" dir="auto">some <strong>great</strong> text</p>',
},
2022-08-13 15:12:31 +05:30
assigneesWidgetPresent
? {
__typename: 'WorkItemWidgetAssignees',
type: 'ASSIGNEES',
allowsMultipleAssignees,
assignees: {
nodes: mockAssignees,
},
}
: { type: 'MOCK TYPE' },
{
__typename: 'WorkItemWidgetHierarchy',
type: 'HIERARCHY',
children: {
edges: [
{
node: {
id: 'gid://gitlab/WorkItem/444',
},
},
],
},
parent,
},
2022-07-23 23:45:48 +05:30
],
},
},
});
export const updateWorkItemWidgetsResponse = {
data: {
workItemUpdateWidgets: {
workItem: {
id: 1234,
},
errors: [],
},
},
};
2022-04-04 11:22:00 +05:30
export const projectWorkItemTypesQueryResponse = {
data: {
workspace: {
2022-06-21 17:19:12 +05:30
id: 'gid://gitlab/WorkItem/1',
2022-04-04 11:22:00 +05:30
workItemTypes: {
nodes: [
2022-06-21 17:19:12 +05:30
{ id: 'gid://gitlab/WorkItems::Type/1', name: 'Issue' },
{ id: 'gid://gitlab/WorkItems::Type/2', name: 'Incident' },
2022-07-16 23:28:13 +05:30
{ id: 'gid://gitlab/WorkItems::Type/3', name: 'Task' },
2022-04-04 11:22:00 +05:30
],
},
},
},
};
2022-05-07 20:08:51 +05:30
export const createWorkItemMutationResponse = {
data: {
workItemCreate: {
__typename: 'WorkItemCreatePayload',
workItem: {
__typename: 'WorkItem',
2022-06-21 17:19:12 +05:30
id: 'gid://gitlab/WorkItem/1',
2022-05-07 20:08:51 +05:30
title: 'Updated title',
2022-07-16 23:28:13 +05:30
state: 'OPEN',
description: 'description',
2022-05-07 20:08:51 +05:30
workItemType: {
__typename: 'WorkItemType',
2022-06-21 17:19:12 +05:30
id: 'gid://gitlab/WorkItems::Type/5',
name: 'Task',
2022-05-07 20:08:51 +05:30
},
2022-07-16 23:28:13 +05:30
userPermissions: {
deleteWorkItem: false,
updateWorkItem: false,
},
2022-07-23 23:45:48 +05:30
widgets: [],
2022-05-07 20:08:51 +05:30
},
},
},
};
2022-06-21 17:19:12 +05:30
export const createWorkItemFromTaskMutationResponse = {
data: {
workItemCreateFromTask: {
__typename: 'WorkItemCreateFromTaskPayload',
errors: [],
workItem: {
__typename: 'WorkItem',
2022-08-13 15:12:31 +05:30
description: 'New description',
id: 'gid://gitlab/WorkItem/1',
title: 'Updated title',
state: 'OPEN',
workItemType: {
__typename: 'WorkItemType',
id: 'gid://gitlab/WorkItems::Type/5',
name: 'Task',
},
2022-07-16 23:28:13 +05:30
userPermissions: {
deleteWorkItem: false,
updateWorkItem: false,
},
2022-08-13 15:12:31 +05:30
widgets: [
{
__typename: 'WorkItemWidgetDescription',
type: 'DESCRIPTION',
description: 'New description',
descriptionHtml: '<p>New description</p>',
},
],
},
newWorkItem: {
__typename: 'WorkItem',
id: 'gid://gitlab/WorkItem/1000000',
title: 'Updated title',
state: 'OPEN',
description: '',
workItemType: {
__typename: 'WorkItemType',
id: 'gid://gitlab/WorkItems::Type/5',
name: 'Task',
},
userPermissions: {
deleteWorkItem: false,
updateWorkItem: false,
},
widgets: [],
2022-06-21 17:19:12 +05:30
},
},
},
};
export const deleteWorkItemResponse = {
data: { workItemDelete: { errors: [], __typename: 'WorkItemDeletePayload' } },
};
export const deleteWorkItemFailureResponse = {
data: { workItemDelete: null },
errors: [
{
message:
"The resource that you are attempting to access does not exist or you don't have permission to perform this action",
locations: [{ line: 2, column: 3 }],
path: ['workItemDelete'],
},
],
};
export const workItemTitleSubscriptionResponse = {
data: {
issuableTitleUpdated: {
id: 'gid://gitlab/WorkItem/1',
title: 'new title',
},
},
};
2022-07-23 23:45:48 +05:30
export const workItemHierarchyEmptyResponse = {
data: {
workItem: {
id: 'gid://gitlab/WorkItem/1',
workItemType: {
id: 'gid://gitlab/WorkItems::Type/6',
__typename: 'WorkItemType',
},
title: 'New title',
widgets: [
{
type: 'DESCRIPTION',
__typename: 'WorkItemWidgetDescription',
},
{
type: 'HIERARCHY',
parent: null,
children: {
nodes: [],
__typename: 'WorkItemConnection',
},
__typename: 'WorkItemWidgetHierarchy',
},
],
__typename: 'WorkItem',
},
},
};
export const workItemHierarchyResponse = {
data: {
workItem: {
id: 'gid://gitlab/WorkItem/1',
workItemType: {
id: 'gid://gitlab/WorkItems::Type/6',
__typename: 'WorkItemType',
},
title: 'New title',
widgets: [
{
type: 'DESCRIPTION',
__typename: 'WorkItemWidgetDescription',
},
{
type: 'HIERARCHY',
parent: null,
children: {
nodes: [
{
id: 'gid://gitlab/WorkItem/2',
workItemType: {
id: 'gid://gitlab/WorkItems::Type/5',
__typename: 'WorkItemType',
},
title: 'xyz',
state: 'OPEN',
__typename: 'WorkItem',
},
{
id: 'gid://gitlab/WorkItem/3',
workItemType: {
id: 'gid://gitlab/WorkItems::Type/5',
__typename: 'WorkItemType',
},
title: 'abc',
state: 'CLOSED',
__typename: 'WorkItem',
},
{
id: 'gid://gitlab/WorkItem/4',
workItemType: {
id: 'gid://gitlab/WorkItems::Type/5',
__typename: 'WorkItemType',
},
title: 'bar',
state: 'OPEN',
__typename: 'WorkItem',
},
{
id: 'gid://gitlab/WorkItem/5',
workItemType: {
id: 'gid://gitlab/WorkItems::Type/5',
__typename: 'WorkItemType',
},
title: 'foobar',
state: 'OPEN',
__typename: 'WorkItem',
},
],
__typename: 'WorkItemConnection',
},
__typename: 'WorkItemWidgetHierarchy',
},
],
__typename: 'WorkItem',
},
},
};
2022-08-13 15:12:31 +05:30
export const changeWorkItemParentMutationResponse = {
data: {
workItemUpdate: {
workItem: {
id: 'gid://gitlab/WorkItem/2',
workItemType: {
id: 'gid://gitlab/WorkItems::Type/5',
__typename: 'WorkItemType',
},
title: 'Foo',
state: 'OPEN',
__typename: 'WorkItem',
},
errors: [],
__typename: 'WorkItemUpdatePayload',
},
},
};
export const availableWorkItemsResponse = {
data: {
workspace: {
__typename: 'Project',
id: 'gid://gitlab/Project/2',
workItems: {
edges: [
{
node: {
id: 'gid://gitlab/WorkItem/458',
title: 'Task 1',
state: 'OPEN',
},
},
{
node: {
id: 'gid://gitlab/WorkItem/459',
title: 'Task 2',
state: 'OPEN',
},
},
],
},
},
},
};
export const projectMembersResponseWithCurrentUser = {
data: {
workspace: {
id: '1',
__typename: 'Project',
users: {
nodes: [
{
id: 'user-2',
user: {
__typename: 'UserCore',
id: 'gid://gitlab/User/5',
avatarUrl: '/avatar2',
name: 'rookie',
username: 'rookie',
webUrl: 'rookie',
status: null,
},
},
{
id: 'user-1',
user: {
__typename: 'UserCore',
id: 'gid://gitlab/User/1',
avatarUrl:
'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
name: 'Administrator',
username: 'root',
webUrl: '/root',
status: null,
},
},
],
},
},
},
};
export const projectMembersResponseWithoutCurrentUser = {
data: {
workspace: {
id: '1',
__typename: 'Project',
users: {
nodes: [
{
id: 'user-2',
user: {
__typename: 'UserCore',
id: 'gid://gitlab/User/5',
avatarUrl: '/avatar2',
name: 'rookie',
username: 'rookie',
webUrl: 'rookie',
status: null,
},
},
],
},
},
},
};
export const currentUserResponse = {
data: {
currentUser: {
__typename: 'UserCore',
id: 'gid://gitlab/User/1',
avatarUrl:
'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
name: 'Administrator',
username: 'root',
webUrl: '/root',
},
},
};
export const currentUserNullResponse = {
data: {
currentUser: null,
},
};
export const mockLabels = [
{
__typename: 'Label',
id: 'gid://gitlab/Label/1',
title: 'Label 1',
description: '',
color: '#f00',
textColor: '#00f',
},
{
__typename: 'Label',
id: 'gid://gitlab/Label/2',
title: 'Label 2',
description: '',
color: '#b00',
textColor: '#00b',
},
];
export const projectLabelsResponse = {
data: {
workspace: {
id: '1',
__typename: 'Project',
labels: {
nodes: mockLabels,
},
},
},
};
export const mockParent = {
parent: {
id: 'gid://gitlab/Issue/1',
iid: '5',
title: 'Parent title',
},
};