Commit 12900923 authored by Florie Guibert's avatar Florie Guibert

Fix creating issue in milestone list

Review feedback
parent e7b3a118
import { sortBy, cloneDeep } from 'lodash'; import { sortBy, cloneDeep } from 'lodash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { ListType } from './constants'; import { ListType, MilestoneIDs } from './constants';
export function getMilestone() { export function getMilestone() {
return null; return null;
...@@ -109,7 +109,9 @@ export function formatIssueInput(issueInput, boardConfig) { ...@@ -109,7 +109,9 @@ export function formatIssueInput(issueInput, boardConfig) {
return { return {
...issueInput, ...issueInput,
milestoneId: milestoneId:
milestoneId && milestoneId !== -1 ? fullMilestoneId(milestoneId) : issueInput.milestoneId, milestoneId && milestoneId !== MilestoneIDs.ANY
? fullMilestoneId(milestoneId)
: issueInput?.milestoneId,
labelIds: [...labelIds, ...(labels?.map((l) => fullLabelId(l)) || [])], labelIds: [...labelIds, ...(labels?.map((l) => fullLabelId(l)) || [])],
assigneeIds: [...assigneeIds, ...(assigneeId ? [fullUserId(assigneeId)] : [])], assigneeIds: [...assigneeIds, ...(assigneeId ? [fullUserId(assigneeId)] : [])],
}; };
......
...@@ -119,6 +119,11 @@ export const DraggableItemTypes = { ...@@ -119,6 +119,11 @@ export const DraggableItemTypes = {
list: 'list', list: 'list',
}; };
export const MilestoneIDs = {
NONE: 0,
ANY: -1,
};
export default { export default {
BoardType, BoardType,
ListType, ListType,
......
...@@ -53,6 +53,7 @@ export const MilestoneFilterType = { ...@@ -53,6 +53,7 @@ export const MilestoneFilterType = {
export const MilestoneIDs = { export const MilestoneIDs = {
NONE: 0, NONE: 0,
ANY: -1,
}; };
export const ANY_MILESTONE = { export const ANY_MILESTONE = {
......
...@@ -28,17 +28,7 @@ RSpec.describe 'Issue Boards new issue', :js do ...@@ -28,17 +28,7 @@ RSpec.describe 'Issue Boards new issue', :js do
end end
it 'successfully assigns weight to newly-created issue' do it 'successfully assigns weight to newly-created issue' do
page.within(first('.board')) do create_issue_in_board_list(0)
find('.issue-count-badge-add-button').click
end
page.within(first('.board-new-issue-form')) do
fill_in 'issue_title', with: 'new issue'
click_button 'Create issue'
end
wait_for_requests
page.within(first('.board')) do page.within(first('.board')) do
find('.board-card').click find('.board-card').click
...@@ -58,16 +48,7 @@ RSpec.describe 'Issue Boards new issue', :js do ...@@ -58,16 +48,7 @@ RSpec.describe 'Issue Boards new issue', :js do
describe 'milestone list' do describe 'milestone list' do
it 'successfuly loads milestone to be added to newly created issue' do it 'successfuly loads milestone to be added to newly created issue' do
page.within(all('.board')[1]) do create_issue_in_board_list(1)
click_button 'New issue'
end
page.within(first('.board-new-issue-form')) do
find('.form-control').set('new issue')
click_button 'Create issue'
end
wait_for_requests
page.within(all('.board')[1]) do page.within(all('.board')[1]) do
find('.board-card').click find('.board-card').click
...@@ -83,4 +64,17 @@ RSpec.describe 'Issue Boards new issue', :js do ...@@ -83,4 +64,17 @@ RSpec.describe 'Issue Boards new issue', :js do
end end
end end
end end
def create_issue_in_board_list(list_index)
page.within(all('.board')[list_index]) do
click_button 'New issue'
end
page.within(first('.board-new-issue-form')) do
find('.form-control').set('new issue')
click_button 'Create issue'
end
wait_for_requests
end
end end
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