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 {
commit(types.MOVE_ISSUE, { originalIssue, fromListId, toListId, moveBeforeId, moveAfterId });
const { boardId } = state.endpoints;
const [groupPath, project] = issuePath.split(/[/#]/);
const [fullProjectPath] = issuePath.split(/[#]/);
gqlClient
.mutate({
mutation: issueMoveListMutation,
variables: {
projectPath: `${groupPath}/${project}`,
projectPath: fullProjectPath,
boardId: fullBoardId(boardId),
iid: issueIid,
fromListId: getIdFromGraphQLId(fromListId),
......
......@@ -125,8 +125,8 @@ export const rawIssue = {
timeEstimate: 0,
weight: null,
confidential: false,
referencePath: 'gitlab-org/gitlab-test#27',
path: '/gitlab-org/gitlab-test/-/issues/27',
referencePath: 'gitlab-org/test-subgroup/gitlab-test#27',
path: '/gitlab-org/test-subgroup/gitlab-test/-/issues/27',
labels: {
nodes: [
{
......@@ -153,8 +153,8 @@ export const mockIssue = {
timeEstimate: 0,
weight: null,
confidential: false,
referencePath: 'gitlab-org/gitlab-test#27',
path: '/gitlab-org/gitlab-test/-/issues/27',
referencePath: 'gitlab-org/test-subgroup/gitlab-test#27',
path: '/gitlab-org/test-subgroup/gitlab-test/-/issues/27',
assignees,
labels: [
{
......@@ -179,8 +179,8 @@ export const mockIssue2 = {
timeEstimate: 0,
weight: null,
confidential: false,
referencePath: 'gitlab-org/gitlab-test#2',
path: '/gitlab-org/gitlab-test/-/issues/28',
referencePath: 'gitlab-org/test-subgroup/gitlab-test#28',
path: '/gitlab-org/test-subgroup/gitlab-test/-/issues/28',
assignees,
labels,
epic: {
......
......@@ -10,6 +10,8 @@ import {
import actions, { gqlClient } from '~/boards/stores/actions';
import * as types from '~/boards/stores/mutation_types';
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 => {
it('is not implemented', () => {
......@@ -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', () => {
it('sets data object', () => {
const mockData = {
......@@ -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 => {
jest.spyOn(gqlClient, 'mutate').mockResolvedValue({
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