Commit 594668ce authored by Illya Klymov's avatar Illya Klymov

Merge branch '334260-some-users-cannot-move-issues-in-epic-swimlanes' into 'master'

Fix - Some users cannot move issues in epic swimlanes

See merge request gitlab-org/gitlab!68922
parents 8ed2b60a d5536cfa
...@@ -51,7 +51,9 @@ export default { ...@@ -51,7 +51,9 @@ export default {
computed: { computed: {
...mapState(['activeId', 'filterParams', 'canAdminEpic', 'listsFlags', 'highlightedLists']), ...mapState(['activeId', 'filterParams', 'canAdminEpic', 'listsFlags', 'highlightedLists']),
treeRootWrapper() { treeRootWrapper() {
return this.canAdminList && this.canAdminEpic ? Draggable : 'ul'; return this.canAdminList && (this.canAdminEpic || this.isUnassignedIssuesLane)
? Draggable
: 'ul';
}, },
treeRootOptions() { treeRootOptions() {
const options = { const options = {
......
...@@ -16,17 +16,10 @@ RSpec.describe 'epics swimlanes', :js do ...@@ -16,17 +16,10 @@ RSpec.describe 'epics swimlanes', :js do
let_it_be(:list) { create(:list, board: board, label: label, position: 0) } let_it_be(:list) { create(:list, board: board, label: label, position: 0) }
let_it_be(:issue1) { create(:issue, project: project, labels: [label]) } let_it_be(:issue1) { create(:issue, project: project, labels: [label]) }
let_it_be(:issue2) { create(:issue, project: project) }
let_it_be(:issue3) { create(:issue, project: project, state: :closed) }
let_it_be(:issue4) { create(:issue, project: project) }
let_it_be(:epic1) { create(:epic, group: group) } let_it_be(:epic1) { create(:epic, group: group) }
let_it_be(:epic2) { create(:epic, group: group) } let_it_be(:epic2) { create(:epic, group: group) }
let_it_be(:epic_issue1) { create(:epic_issue, epic: epic1, issue: issue1) }
let_it_be(:epic_issue2) { create(:epic_issue, epic: epic2, issue: issue2) }
let_it_be(:epic_issue3) { create(:epic_issue, epic: epic2, issue: issue3) }
before do before do
project.add_maintainer(user) project.add_maintainer(user)
group.add_maintainer(user) group.add_maintainer(user)
...@@ -38,7 +31,27 @@ RSpec.describe 'epics swimlanes', :js do ...@@ -38,7 +31,27 @@ RSpec.describe 'epics swimlanes', :js do
load_unassigned_issues load_unassigned_issues
end end
context 'when no epic is displayed' do
it('user can drag and drop between columns') do
wait_for_board_cards_in_unassigned_lane(1, 1)
epic_lanes = page.all(:css, '.board-epic-lane')
expect(epic_lanes.length).to eq(0)
drag(list_from_index: 1, list_to_index: 0)
wait_for_board_cards_in_unassigned_lane(0, 1)
end
end
context 'drag and drop issue' do context 'drag and drop issue' do
let_it_be(:issue2) { create(:issue, project: project) }
let_it_be(:issue3) { create(:issue, project: project, state: :closed) }
let_it_be(:issue4) { create(:issue, project: project) }
let_it_be(:epic_issue1) { create(:epic_issue, epic: epic1, issue: issue1) }
let_it_be(:epic_issue2) { create(:epic_issue, epic: epic2, issue: issue2) }
let_it_be(:epic_issue3) { create(:epic_issue, epic: epic2, issue: issue3) }
it 'between epics' do it 'between epics' do
wait_for_board_cards(1, 2) wait_for_board_cards(1, 2)
wait_for_board_cards_in_first_epic(0, 1) wait_for_board_cards_in_first_epic(0, 1)
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import Draggable from 'vuedraggable';
import IssuesLaneList from 'ee/boards/components/issues_lane_list.vue'; import IssuesLaneList from 'ee/boards/components/issues_lane_list.vue';
import { mockList } from 'jest/boards/mock_data'; import { mockList } from 'jest/boards/mock_data';
import BoardCard from '~/boards/components/board_card.vue'; import BoardCard from '~/boards/components/board_card.vue';
...@@ -11,7 +12,11 @@ describe('IssuesLaneList', () => { ...@@ -11,7 +12,11 @@ describe('IssuesLaneList', () => {
let wrapper; let wrapper;
let store; let store;
const createComponent = ({ listType = ListType.backlog, collapsed = false } = {}) => { const createComponent = ({
listType = ListType.backlog,
collapsed = false,
isUnassignedIssuesLane = false,
} = {}) => {
const listMock = { const listMock = {
...mockList, ...mockList,
listType, listType,
...@@ -30,6 +35,7 @@ describe('IssuesLaneList', () => { ...@@ -30,6 +35,7 @@ describe('IssuesLaneList', () => {
issues: mockIssues, issues: mockIssues,
disabled: false, disabled: false,
canAdminList: true, canAdminList: true,
isUnassignedIssuesLane,
}, },
}); });
}; };
...@@ -71,6 +77,24 @@ describe('IssuesLaneList', () => { ...@@ -71,6 +77,24 @@ describe('IssuesLaneList', () => {
}); });
}); });
describe('drag & drop permissions', () => {
beforeEach(() => {
store = createStore();
createComponent();
});
it('user cannot drag on epic lane if canAdminEpic is false', () => {
expect(wrapper.vm.treeRootWrapper).toBe('ul');
});
it('user can drag on unassigned lane if canAdminEpic is false', () => {
createComponent({ isUnassignedIssuesLane: true });
expect(wrapper.vm.treeRootWrapper).toBe(Draggable);
});
});
describe('drag & drop issue', () => { describe('drag & drop issue', () => {
beforeEach(() => { beforeEach(() => {
const defaultStore = createStore(); const defaultStore = createStore();
......
...@@ -277,7 +277,11 @@ describe('fetchEpicsSwimlanes', () => { ...@@ -277,7 +277,11 @@ describe('fetchEpicsSwimlanes', () => {
[ [
{ {
type: types.RECEIVE_EPICS_SUCCESS, type: types.RECEIVE_EPICS_SUCCESS,
payload: { epics: [mockEpic], hasMoreEpics: true, epicsEndCursor: 'ENDCURSOR' }, payload: {
epics: [mockEpic],
hasMoreEpics: true,
epicsEndCursor: 'ENDCURSOR',
},
}, },
], ],
[], [],
......
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