Commit 30e604cf authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '340011-creating-issue-in-milestone-list-on-boards-fails' into 'master'

Fix creating issue in milestone list

See merge request gitlab-org/gitlab!69529
parents c7ddd836 12900923
import { sortBy, cloneDeep } from 'lodash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { ListType } from './constants';
import { ListType, MilestoneIDs } from './constants';
export function getMilestone() {
return null;
......@@ -108,7 +108,10 @@ export function formatIssueInput(issueInput, boardConfig) {
return {
...issueInput,
milestoneId: milestoneId ? fullMilestoneId(milestoneId) : null,
milestoneId:
milestoneId && milestoneId !== MilestoneIDs.ANY
? fullMilestoneId(milestoneId)
: issueInput?.milestoneId,
labelIds: [...labelIds, ...(labels?.map((l) => fullLabelId(l)) || [])],
assigneeIds: [...assigneeIds, ...(assigneeId ? [fullUserId(assigneeId)] : [])],
};
......
......@@ -119,6 +119,11 @@ export const DraggableItemTypes = {
list: 'list',
};
export const MilestoneIDs = {
NONE: 0,
ANY: -1,
};
export default {
BoardType,
ListType,
......
......@@ -53,6 +53,7 @@ export const MilestoneFilterType = {
export const MilestoneIDs = {
NONE: 0,
ANY: -1,
};
export const ANY_MILESTONE = {
......
......@@ -3,10 +3,17 @@
require 'spec_helper'
RSpec.describe 'Issue Boards new issue', :js do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:board) { create(:board, project: project) }
let_it_be(:backlog_list) { create(:backlog_list, board: board) }
before do
stub_licensed_features(board_milestone_lists: true)
end
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:milestone) { create(:milestone, project: project, title: 'Milestone 1') }
let_it_be(:board) { create(:board, project: project) }
let_it_be(:backlog_list) { create(:backlog_list, board: board) }
let!(:milestone_list) { create(:milestone_list, board: board, milestone: milestone, position: 0) }
context 'authorized user' do
before do
......@@ -17,21 +24,11 @@ RSpec.describe 'Issue Boards new issue', :js do
visit project_board_path(project, board)
wait_for_requests
expect(page).to have_selector('.board', count: 2)
expect(page).to have_selector('.board', count: 3)
end
it 'successfully assigns weight to newly-created issue' do
page.within(first('.board')) do
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
create_issue_in_board_list(0)
page.within(first('.board')) do
find('.board-card').click
......@@ -48,5 +45,36 @@ RSpec.describe 'Issue Boards new issue', :js do
expect(find('.board-card-weight .board-card-info-text').text).to eq("10")
end
end
describe 'milestone list' do
it 'successfuly loads milestone to be added to newly created issue' do
create_issue_in_board_list(1)
page.within(all('.board')[1]) do
find('.board-card').click
end
page.within('[data-testid="sidebar-milestones"]') do
click_button 'Edit'
wait_for_requests
expect(page).to have_content 'Milestone 1'
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
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