Commit e3f23968 authored by Natalia Tepluhina's avatar Natalia Tepluhina Committed by Nicolò Maria Mezzopera

Make swimlanes choice persisting after board has been edited [RUN AS-IF-FOSS]

parent 4d647a21
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
import { GlModal } from '@gitlab/ui'; import { GlModal } from '@gitlab/ui';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import { deprecatedCreateFlash as Flash } from '~/flash'; import { deprecatedCreateFlash as Flash } from '~/flash';
import { visitUrl, stripFinalUrlSegment } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import { getIdFromGraphQLId, convertToGraphQLId } from '~/graphql_shared/utils'; import { getParameterByName } from '~/lib/utils/common_utils';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import boardsStore from '~/boards/stores/boards_store'; import boardsStore from '~/boards/stores/boards_store';
import { fullLabelId, fullBoardId } from '../boards_util'; import { fullLabelId, fullBoardId } from '../boards_util';
...@@ -216,9 +217,15 @@ export default { ...@@ -216,9 +217,15 @@ export default {
variables: { input: this.mutationVariables }, variables: { input: this.mutationVariables },
}); });
return this.board.id if (!this.board.id) {
? getIdFromGraphQLId(response.data.updateBoard.board.id) return response.data.createBoard.board.webPath;
: getIdFromGraphQLId(response.data.createBoard.board.id); }
const path = response.data.updateBoard.board.webPath;
const param = getParameterByName('group_by')
? `?group_by=${getParameterByName('group_by')}`
: '';
return `${path}${param}`;
}, },
async submit() { async submit() {
if (this.board.name.length === 0) return; if (this.board.name.length === 0) return;
...@@ -239,9 +246,7 @@ export default { ...@@ -239,9 +246,7 @@ export default {
} }
} else { } else {
try { try {
const path = await this.createOrUpdateBoard(); const url = await this.createOrUpdateBoard();
const strippedUrl = stripFinalUrlSegment(window.location.href);
const url = strippedUrl.includes('boards') ? `${path}` : `boards/${path}`;
visitUrl(url); visitUrl(url);
} catch { } catch {
Flash(this.$options.i18n.saveErrorMessage); Flash(this.$options.i18n.saveErrorMessage);
......
...@@ -2,6 +2,8 @@ mutation createBoard($input: CreateBoardInput!) { ...@@ -2,6 +2,8 @@ mutation createBoard($input: CreateBoardInput!) {
createBoard(input: $input) { createBoard(input: $input) {
board { board {
id id
webPath
} }
errors
} }
} }
...@@ -2,8 +2,8 @@ mutation UpdateBoard($input: UpdateBoardInput!) { ...@@ -2,8 +2,8 @@ mutation UpdateBoard($input: UpdateBoardInput!) {
updateBoard(input: $input) { updateBoard(input: $input) {
board { board {
id id
hideClosedList webPath
hideBacklogList
} }
errors
} }
} }
---
title: Resolve Grouping/swimlanes choice should persist after board has been edited
merge_request: 51317
author:
type: changed
...@@ -159,7 +159,7 @@ describe('BoardForm', () => { ...@@ -159,7 +159,7 @@ describe('BoardForm', () => {
beforeEach(() => { beforeEach(() => {
mutate = jest.fn().mockResolvedValue({ mutate = jest.fn().mockResolvedValue({
data: { data: {
createBoard: { board: { id: 'gid://gitlab/Board/123' } }, createBoard: { board: { id: 'gid://gitlab/Board/123', webPath: 'test-path' } },
}, },
}); });
}); });
...@@ -174,7 +174,6 @@ describe('BoardForm', () => { ...@@ -174,7 +174,6 @@ describe('BoardForm', () => {
}); });
it('calls a correct GraphQL mutation and redirects to correct page from existing board', async () => { it('calls a correct GraphQL mutation and redirects to correct page from existing board', async () => {
window.location = new URL('https://test/boards/1');
createComponent({ canAdminBoard: true }); createComponent({ canAdminBoard: true });
fillForm(); fillForm();
...@@ -190,27 +189,7 @@ describe('BoardForm', () => { ...@@ -190,27 +189,7 @@ describe('BoardForm', () => {
}); });
await waitForPromises(); await waitForPromises();
expect(visitUrl).toHaveBeenCalledWith('123'); expect(visitUrl).toHaveBeenCalledWith('test-path');
});
it('calls a correct GraphQL mutation and redirects to correct page from boards list', async () => {
window.location = new URL('https://test/boards');
createComponent({ canAdminBoard: true });
fillForm();
await waitForPromises();
expect(mutate).toHaveBeenCalledWith({
mutation: createBoardMutation,
variables: {
input: expect.objectContaining({
name: 'test',
}),
},
});
await waitForPromises();
expect(visitUrl).toHaveBeenCalledWith('boards/123');
}); });
it('shows an error flash if GraphQL mutation fails', async () => { it('shows an error flash if GraphQL mutation fails', async () => {
...@@ -261,10 +240,10 @@ describe('BoardForm', () => { ...@@ -261,10 +240,10 @@ describe('BoardForm', () => {
}); });
}); });
it('calls GraphQL mutation with correct parameters', async () => { it('calls GraphQL mutation with correct parameters when issues are not grouped', async () => {
mutate = jest.fn().mockResolvedValue({ mutate = jest.fn().mockResolvedValue({
data: { data: {
updateBoard: { board: { id: 'gid://gitlab/Board/321' } }, updateBoard: { board: { id: 'gid://gitlab/Board/321', webPath: 'test-path' } },
}, },
}); });
window.location = new URL('https://test/boards/1'); window.location = new URL('https://test/boards/1');
...@@ -284,7 +263,33 @@ describe('BoardForm', () => { ...@@ -284,7 +263,33 @@ describe('BoardForm', () => {
}); });
await waitForPromises(); await waitForPromises();
expect(visitUrl).toHaveBeenCalledWith('321'); expect(visitUrl).toHaveBeenCalledWith('test-path');
});
it('calls GraphQL mutation with correct parameters when issues are grouped by epic', async () => {
mutate = jest.fn().mockResolvedValue({
data: {
updateBoard: { board: { id: 'gid://gitlab/Board/321', webPath: 'test-path' } },
},
});
window.location = new URL('https://test/boards/1?group_by=epic');
createComponent({ canAdminBoard: true });
findInput().trigger('keyup.enter', { metaKey: true });
await waitForPromises();
expect(mutate).toHaveBeenCalledWith({
mutation: updateBoardMutation,
variables: {
input: expect.objectContaining({
id: `gid://gitlab/Board/${currentBoard.id}`,
}),
},
});
await waitForPromises();
expect(visitUrl).toHaveBeenCalledWith('test-path?group_by=epic');
}); });
it('shows an error flash if GraphQL mutation fails', async () => { it('shows an error flash if GraphQL mutation fails', async () => {
......
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