Commit 19a499e8 authored by Eugenia Grieff's avatar Eugenia Grieff Committed by Nicolò Maria Mezzopera

Use full project path for issueMoveList mutation

parent 1922007e
...@@ -263,13 +263,13 @@ export default { ...@@ -263,13 +263,13 @@ export default {
commit(types.MOVE_ISSUE, { originalIssue, fromListId, toListId, moveBeforeId, moveAfterId }); commit(types.MOVE_ISSUE, { originalIssue, fromListId, toListId, moveBeforeId, moveAfterId });
const { boardId } = state.endpoints; const { boardId } = state.endpoints;
const [groupPath, project] = issuePath.split(/[/#]/); const [fullProjectPath] = issuePath.split(/[#]/);
gqlClient gqlClient
.mutate({ .mutate({
mutation: issueMoveListMutation, mutation: issueMoveListMutation,
variables: { variables: {
projectPath: `${groupPath}/${project}`, projectPath: fullProjectPath,
boardId: fullBoardId(boardId), boardId: fullBoardId(boardId),
iid: issueIid, iid: issueIid,
fromListId: getIdFromGraphQLId(fromListId), fromListId: getIdFromGraphQLId(fromListId),
......
...@@ -125,8 +125,8 @@ export const rawIssue = { ...@@ -125,8 +125,8 @@ export const rawIssue = {
timeEstimate: 0, timeEstimate: 0,
weight: null, weight: null,
confidential: false, confidential: false,
referencePath: 'gitlab-org/gitlab-test#27', referencePath: 'gitlab-org/test-subgroup/gitlab-test#27',
path: '/gitlab-org/gitlab-test/-/issues/27', path: '/gitlab-org/test-subgroup/gitlab-test/-/issues/27',
labels: { labels: {
nodes: [ nodes: [
{ {
...@@ -153,8 +153,8 @@ export const mockIssue = { ...@@ -153,8 +153,8 @@ export const mockIssue = {
timeEstimate: 0, timeEstimate: 0,
weight: null, weight: null,
confidential: false, confidential: false,
referencePath: 'gitlab-org/gitlab-test#27', referencePath: 'gitlab-org/test-subgroup/gitlab-test#27',
path: '/gitlab-org/gitlab-test/-/issues/27', path: '/gitlab-org/test-subgroup/gitlab-test/-/issues/27',
assignees, assignees,
labels: [ labels: [
{ {
...@@ -179,8 +179,8 @@ export const mockIssue2 = { ...@@ -179,8 +179,8 @@ export const mockIssue2 = {
timeEstimate: 0, timeEstimate: 0,
weight: null, weight: null,
confidential: false, confidential: false,
referencePath: 'gitlab-org/gitlab-test#2', referencePath: 'gitlab-org/test-subgroup/gitlab-test#28',
path: '/gitlab-org/gitlab-test/-/issues/28', path: '/gitlab-org/test-subgroup/gitlab-test/-/issues/28',
assignees, assignees,
labels, labels,
epic: { epic: {
......
...@@ -10,6 +10,8 @@ import { ...@@ -10,6 +10,8 @@ import {
import actions, { gqlClient } from '~/boards/stores/actions'; import actions, { gqlClient } from '~/boards/stores/actions';
import * as types from '~/boards/stores/mutation_types'; import * as types from '~/boards/stores/mutation_types';
import { inactiveId, ListType } from '~/boards/constants'; import { inactiveId, ListType } from '~/boards/constants';
import issueMoveListMutation from '~/boards/queries/issue_move_list.mutation.graphql';
import { fullBoardId } from '~/boards/boards_util';
const expectNotImplemented = action => { const expectNotImplemented = action => {
it('is not implemented', () => { it('is not implemented', () => {
...@@ -17,6 +19,10 @@ const expectNotImplemented = action => { ...@@ -17,6 +19,10 @@ const expectNotImplemented = action => {
}); });
}; };
// We need this helper to make sure projectPath is including
// subgroups when the movIssue action is called.
const getProjectPath = path => path.split('#')[0];
describe('setInitialBoardData', () => { describe('setInitialBoardData', () => {
it('sets data object', () => { it('sets data object', () => {
const mockData = { const mockData = {
...@@ -290,6 +296,42 @@ describe('moveIssue', () => { ...@@ -290,6 +296,42 @@ describe('moveIssue', () => {
); );
}); });
it('calls mutate with the correct variables', () => {
const mutationVariables = {
mutation: issueMoveListMutation,
variables: {
projectPath: getProjectPath(mockIssue.referencePath),
boardId: fullBoardId(state.endpoints.boardId),
iid: mockIssue.iid,
fromListId: 1,
toListId: 2,
moveBeforeId: undefined,
moveAfterId: undefined,
},
};
jest.spyOn(gqlClient, 'mutate').mockResolvedValue({
data: {
issueMoveList: {
issue: rawIssue,
errors: [],
},
},
});
actions.moveIssue(
{ state, commit: () => {} },
{
issueId: mockIssue.id,
issueIid: mockIssue.iid,
issuePath: mockIssue.referencePath,
fromListId: 'gid://gitlab/List/1',
toListId: 'gid://gitlab/List/2',
},
);
expect(gqlClient.mutate).toHaveBeenCalledWith(mutationVariables);
});
it('should commit MOVE_ISSUE mutation and MOVE_ISSUE_FAILURE mutation when unsuccessful', done => { it('should commit MOVE_ISSUE mutation and MOVE_ISSUE_FAILURE mutation when unsuccessful', done => {
jest.spyOn(gqlClient, 'mutate').mockResolvedValue({ jest.spyOn(gqlClient, 'mutate').mockResolvedValue({
data: { data: {
......
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