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 { 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;
...@@ -108,7 +108,10 @@ export function formatIssueInput(issueInput, boardConfig) { ...@@ -108,7 +108,10 @@ export function formatIssueInput(issueInput, boardConfig) {
return { return {
...issueInput, ...issueInput,
milestoneId: milestoneId ? fullMilestoneId(milestoneId) : null, 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 = {
......
...@@ -3,11 +3,18 @@ ...@@ -3,11 +3,18 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Issue Boards new issue', :js do RSpec.describe 'Issue Boards new issue', :js do
before do
stub_licensed_features(board_milestone_lists: true)
end
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) } 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(:board) { create(:board, project: project) }
let_it_be(:backlog_list) { create(:backlog_list, board: board) } 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 context 'authorized user' do
before do before do
project.add_maintainer(user) project.add_maintainer(user)
...@@ -17,21 +24,11 @@ RSpec.describe 'Issue Boards new issue', :js do ...@@ -17,21 +24,11 @@ RSpec.describe 'Issue Boards new issue', :js do
visit project_board_path(project, board) visit project_board_path(project, board)
wait_for_requests wait_for_requests
expect(page).to have_selector('.board', count: 2) expect(page).to have_selector('.board', count: 3)
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
...@@ -48,5 +45,36 @@ RSpec.describe 'Issue Boards new issue', :js do ...@@ -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") expect(find('.board-card-weight .board-card-info-text').text).to eq("10")
end end
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
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