Commit 50111d1d authored by Coung Ngo's avatar Coung Ngo

Add reviewer suggestions

parent d7ec3b79
fragment Label on Label {
id
color
textColor
title
}
#import "./iteration.fragment.graphql"
query searchIterations($fullPath: ID!, $search: String, $id: ID, $isProject: Boolean = false) { query searchIterations($fullPath: ID!, $search: String, $id: ID, $isProject: Boolean = false) {
group(fullPath: $fullPath) @skip(if: $isProject) { group(fullPath: $fullPath) @skip(if: $isProject) {
iterations(title: $search, id: $id, includeAncestors: true) { iterations(title: $search, id: $id, includeAncestors: true) {
nodes { nodes {
id ...Iteration
title
} }
} }
} }
project(fullPath: $fullPath) @include(if: $isProject) { project(fullPath: $fullPath) @include(if: $isProject) {
iterations(title: $search, id: $id, includeAncestors: true) { iterations(title: $search, id: $id, includeAncestors: true) {
nodes { nodes {
id ...Iteration
title
} }
} }
} }
......
#import "./label.fragment.graphql"
query searchLabels($fullPath: ID!, $search: String, $isProject: Boolean = false) { query searchLabels($fullPath: ID!, $search: String, $isProject: Boolean = false) {
group(fullPath: $fullPath) @skip(if: $isProject) { group(fullPath: $fullPath) @skip(if: $isProject) {
labels(searchTerm: $search, includeAncestorGroups: true, includeDescendantGroups: true) { labels(searchTerm: $search, includeAncestorGroups: true, includeDescendantGroups: true) {
nodes { nodes {
id ...Label
color
textColor
title
} }
} }
} }
project(fullPath: $fullPath) @include(if: $isProject) { project(fullPath: $fullPath) @include(if: $isProject) {
labels(searchTerm: $search, includeAncestorGroups: true) { labels(searchTerm: $search, includeAncestorGroups: true) {
nodes { nodes {
id ...Label
color
textColor
title
} }
} }
} }
......
#import "./milestone.fragment.graphql"
query searchMilestones($fullPath: ID!, $search: String, $isProject: Boolean = false) { query searchMilestones($fullPath: ID!, $search: String, $isProject: Boolean = false) {
group(fullPath: $fullPath) @skip(if: $isProject) { group(fullPath: $fullPath) @skip(if: $isProject) {
milestones(searchTitle: $search, includeAncestors: true, includeDescendants: true) { milestones(searchTitle: $search, includeAncestors: true, includeDescendants: true) {
nodes { nodes {
id ...Milestone
title
} }
} }
} }
project(fullPath: $fullPath) @include(if: $isProject) { project(fullPath: $fullPath) @include(if: $isProject) {
milestones(searchTitle: $search, includeAncestors: true) { milestones(searchTitle: $search, includeAncestors: true) {
nodes { nodes {
id ...Milestone
title
} }
} }
} }
......
#import "./user.fragment.graphql"
query searchUsers($fullPath: ID!, $search: String, $isProject: Boolean = false) { query searchUsers($fullPath: ID!, $search: String, $isProject: Boolean = false) {
group(fullPath: $fullPath) @skip(if: $isProject) { group(fullPath: $fullPath) @skip(if: $isProject) {
groupMembers(search: $search) { groupMembers(search: $search) {
nodes { nodes {
user { user {
id ...User
avatarUrl
name
username
} }
} }
} }
...@@ -15,10 +14,7 @@ query searchUsers($fullPath: ID!, $search: String, $isProject: Boolean = false) ...@@ -15,10 +14,7 @@ query searchUsers($fullPath: ID!, $search: String, $isProject: Boolean = false)
projectMembers(search: $search) { projectMembers(search: $search) {
nodes { nodes {
user { user {
id ...User
avatarUrl
name
username
} }
} }
} }
......
fragment User on User {
id
avatarUrl
name
username
}
...@@ -191,7 +191,7 @@ describe('IssuesListApp component', () => { ...@@ -191,7 +191,7 @@ describe('IssuesListApp component', () => {
setWindowLocation(search); setWindowLocation(search);
wrapper = mountComponent({ wrapper = mountComponent({
provide: { ...defaultProvide, isSignedIn: true }, provide: { isSignedIn: true },
mountFn: mount, mountFn: mount,
}); });
...@@ -208,7 +208,15 @@ describe('IssuesListApp component', () => { ...@@ -208,7 +208,15 @@ describe('IssuesListApp component', () => {
describe('when user is not signed in', () => { describe('when user is not signed in', () => {
it('does not render', () => { it('does not render', () => {
wrapper = mountComponent({ provide: { ...defaultProvide, isSignedIn: false } }); wrapper = mountComponent({ provide: { isSignedIn: false } });
expect(findCsvImportExportButtons().exists()).toBe(false);
});
});
describe('when in a group context', () => {
it('does not render', () => {
wrapper = mountComponent({ provide: { isProject: false } });
expect(findCsvImportExportButtons().exists()).toBe(false); expect(findCsvImportExportButtons().exists()).toBe(false);
}); });
...@@ -625,70 +633,87 @@ describe('IssuesListApp component', () => { ...@@ -625,70 +633,87 @@ describe('IssuesListApp component', () => {
...defaultQueryResponse.data.project.issues.nodes[0], ...defaultQueryResponse.data.project.issues.nodes[0],
id: 'gid://gitlab/Issue/1', id: 'gid://gitlab/Issue/1',
iid: '101', iid: '101',
reference: 'group/project#1',
webPath: '/group/project/-/issues/1', webPath: '/group/project/-/issues/1',
}; };
const issueTwo = { const issueTwo = {
...defaultQueryResponse.data.project.issues.nodes[0], ...defaultQueryResponse.data.project.issues.nodes[0],
id: 'gid://gitlab/Issue/2', id: 'gid://gitlab/Issue/2',
iid: '102', iid: '102',
reference: 'group/project#2',
webPath: '/group/project/-/issues/2', webPath: '/group/project/-/issues/2',
}; };
const issueThree = { const issueThree = {
...defaultQueryResponse.data.project.issues.nodes[0], ...defaultQueryResponse.data.project.issues.nodes[0],
id: 'gid://gitlab/Issue/3', id: 'gid://gitlab/Issue/3',
iid: '103', iid: '103',
reference: 'group/project#3',
webPath: '/group/project/-/issues/3', webPath: '/group/project/-/issues/3',
}; };
const issueFour = { const issueFour = {
...defaultQueryResponse.data.project.issues.nodes[0], ...defaultQueryResponse.data.project.issues.nodes[0],
id: 'gid://gitlab/Issue/4', id: 'gid://gitlab/Issue/4',
iid: '104', iid: '104',
reference: 'group/project#4',
webPath: '/group/project/-/issues/4', webPath: '/group/project/-/issues/4',
}; };
const response = { const response = (isProject = true) => ({
data: { data: {
project: { [isProject ? 'project' : 'group']: {
issues: { issues: {
...defaultQueryResponse.data.project.issues, ...defaultQueryResponse.data.project.issues,
nodes: [issueOne, issueTwo, issueThree, issueFour], nodes: [issueOne, issueTwo, issueThree, issueFour],
}, },
}, },
}, },
};
beforeEach(() => {
wrapper = mountComponent({ issuesQueryResponse: jest.fn().mockResolvedValue(response) });
jest.runOnlyPendingTimers();
}); });
describe('when successful', () => { describe('when successful', () => {
describe.each` describe.each([true, false])('when isProject=%s', (isProject) => {
description | issueToMove | oldIndex | newIndex | moveBeforeId | moveAfterId describe.each`
${'to the beginning of the list'} | ${issueThree} | ${2} | ${0} | ${null} | ${issueOne.id} description | issueToMove | oldIndex | newIndex | moveBeforeId | moveAfterId
${'down the list'} | ${issueOne} | ${0} | ${1} | ${issueTwo.id} | ${issueThree.id} ${'to the beginning of the list'} | ${issueThree} | ${2} | ${0} | ${null} | ${issueOne.id}
${'up the list'} | ${issueThree} | ${2} | ${1} | ${issueOne.id} | ${issueTwo.id} ${'down the list'} | ${issueOne} | ${0} | ${1} | ${issueTwo.id} | ${issueThree.id}
${'to the end of the list'} | ${issueTwo} | ${1} | ${3} | ${issueFour.id} | ${null} ${'up the list'} | ${issueThree} | ${2} | ${1} | ${issueOne.id} | ${issueTwo.id}
`( ${'to the end of the list'} | ${issueTwo} | ${1} | ${3} | ${issueFour.id} | ${null}
'when moving issue $description', `(
({ issueToMove, oldIndex, newIndex, moveBeforeId, moveAfterId }) => { 'when moving issue $description',
it('makes API call to reorder the issue', async () => { ({ issueToMove, oldIndex, newIndex, moveBeforeId, moveAfterId }) => {
findIssuableList().vm.$emit('reorder', { oldIndex, newIndex }); beforeEach(() => {
wrapper = mountComponent({
await waitForPromises(); provide: { isProject },
issuesQueryResponse: jest.fn().mockResolvedValue(response(isProject)),
expect(axiosMock.history.put[0]).toMatchObject({ });
url: joinPaths(issueToMove.webPath, 'reorder'), jest.runOnlyPendingTimers();
data: JSON.stringify({
move_before_id: getIdFromGraphQLId(moveBeforeId),
move_after_id: getIdFromGraphQLId(moveAfterId),
}),
}); });
});
}, it('makes API call to reorder the issue', async () => {
); findIssuableList().vm.$emit('reorder', { oldIndex, newIndex });
await waitForPromises();
expect(axiosMock.history.put[0]).toMatchObject({
url: joinPaths(issueToMove.webPath, 'reorder'),
data: JSON.stringify({
move_before_id: getIdFromGraphQLId(moveBeforeId),
move_after_id: getIdFromGraphQLId(moveAfterId),
group_full_path: isProject ? undefined : defaultProvide.fullPath,
}),
});
});
},
);
});
}); });
describe('when unsuccessful', () => { describe('when unsuccessful', () => {
beforeEach(() => {
wrapper = mountComponent({
issuesQueryResponse: jest.fn().mockResolvedValue(response()),
});
jest.runOnlyPendingTimers();
});
it('displays an error message', async () => { it('displays an error message', async () => {
axiosMock.onPut(joinPaths(issueOne.webPath, 'reorder')).reply(500); axiosMock.onPut(joinPaths(issueOne.webPath, 'reorder')).reply(500);
......
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