debian-mirror-gitlab/spec/features/boards/issue_ordering_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

197 lines
5.9 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2017-08-17 22:00:37 +05:30
2020-06-23 00:09:42 +05:30
RSpec.describe 'Issue Boards', :js do
2017-08-17 22:00:37 +05:30
include DragTo
2017-09-10 17:25:29 +05:30
let(:project) { create(:project, :public) }
2017-08-17 22:00:37 +05:30
let(:board) { create(:board, project: project) }
let(:user) { create(:user) }
let(:label) { create(:label, project: project) }
let!(:list1) { create(:list, board: board, label: label, position: 0) }
let!(:issue1) { create(:labeled_issue, project: project, title: 'testing 1', labels: [label], relative_position: 3) }
let!(:issue2) { create(:labeled_issue, project: project, title: 'testing 2', labels: [label], relative_position: 2) }
let!(:issue3) { create(:labeled_issue, project: project, title: 'testing 3', labels: [label], relative_position: 1) }
before do
2023-01-13 00:05:48 +05:30
stub_feature_flags(apollo_boards: false)
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
sign_in(user)
2017-08-17 22:00:37 +05:30
end
context 'un-ordered issues' do
2020-10-24 23:57:45 +05:30
let!(:issue4) { create(:labeled_issue, project: project, labels: [label], relative_position: nil) }
2017-08-17 22:00:37 +05:30
before do
2017-09-10 17:25:29 +05:30
visit project_board_path(project, board)
wait_for_requests
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(page).to have_selector('.board', count: 3)
2017-08-17 22:00:37 +05:30
end
it 'has un-ordered issue as last issue' do
2017-09-10 17:25:29 +05:30
page.within(find('.board:nth-child(2)')) do
2018-11-08 19:23:39 +05:30
expect(all('.board-card').last).to have_content(issue4.title)
2017-08-17 22:00:37 +05:30
end
end
it 'moves un-ordered issue to top of list' do
2018-11-08 19:23:39 +05:30
drag(from_index: 3, to_index: 0, duration: 1180)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
page.within(find('.board:nth-child(2)')) do
2018-11-08 19:23:39 +05:30
expect(first('.board-card')).to have_content(issue4.title)
2017-08-17 22:00:37 +05:30
end
end
end
2020-04-08 14:13:33 +05:30
context 'closed issues' do
let!(:issue7) { create(:closed_issue, project: project, title: 'Closed issue 1', closed_at: 1.day.ago) }
let!(:issue8) { create(:closed_issue, project: project, title: 'Closed issue 2', closed_at: 1.week.ago) }
let!(:issue9) { create(:closed_issue, project: project, title: 'Closed issue 3', closed_at: 2.weeks.ago) }
before do
visit project_board_path(project, board)
wait_for_requests
expect(page).to have_selector('.board', count: 3)
end
it 'orders issues by closed_at' do
wait_for_requests
page.within(find('.board:nth-child(3)')) do
first, second, third = all('.board-card').to_a
expect(first).to have_content(issue7.title)
expect(second).to have_content(issue8.title)
expect(third).to have_content(issue9.title)
end
end
end
2017-08-17 22:00:37 +05:30
context 'ordering in list' do
before do
2017-09-10 17:25:29 +05:30
visit project_board_path(project, board)
wait_for_requests
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(page).to have_selector('.board', count: 3)
2017-08-17 22:00:37 +05:30
end
it 'moves from middle to top' do
drag(from_index: 1, to_index: 0)
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
expect(first('.board-card')).to have_content(issue2.title)
2017-08-17 22:00:37 +05:30
end
it 'moves from middle to bottom' do
drag(from_index: 1, to_index: 2)
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
expect(all('.board-card').last).to have_content(issue2.title)
2017-08-17 22:00:37 +05:30
end
it 'moves from top to bottom' do
drag(from_index: 0, to_index: 2)
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
expect(all('.board-card').last).to have_content(issue3.title)
2017-08-17 22:00:37 +05:30
end
it 'moves from bottom to top' do
2018-12-13 13:39:08 +05:30
drag(from_index: 2, to_index: 0, duration: 1020)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
expect(first('.board-card')).to have_content(issue1.title)
2017-08-17 22:00:37 +05:30
end
it 'moves from top to middle' do
drag(from_index: 0, to_index: 1)
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
expect(first('.board-card')).to have_content(issue2.title)
2017-08-17 22:00:37 +05:30
end
it 'moves from bottom to middle' do
drag(from_index: 2, to_index: 1)
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
expect(all('.board-card').last).to have_content(issue2.title)
2017-08-17 22:00:37 +05:30
end
end
context 'ordering when changing list' do
let(:label2) { create(:label, project: project) }
let!(:list2) { create(:list, board: board, label: label2, position: 1) }
let!(:issue4) { create(:labeled_issue, project: project, title: 'testing 1', labels: [label2], relative_position: 3.0) }
let!(:issue5) { create(:labeled_issue, project: project, title: 'testing 2', labels: [label2], relative_position: 2.0) }
let!(:issue6) { create(:labeled_issue, project: project, title: 'testing 3', labels: [label2], relative_position: 1.0) }
before do
2017-09-10 17:25:29 +05:30
visit project_board_path(project, board)
wait_for_requests
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(page).to have_selector('.board', count: 4)
2017-08-17 22:00:37 +05:30
end
it 'moves to top of another list' do
2017-09-10 17:25:29 +05:30
drag(list_from_index: 1, list_to_index: 2)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 2)
expect(all('.board')[2]).to have_selector('.board-card', count: 4)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
page.within(all('.board')[2]) do
2018-11-08 19:23:39 +05:30
expect(first('.board-card')).to have_content(issue3.title)
2017-08-17 22:00:37 +05:30
end
end
it 'moves to bottom of another list' do
2021-09-04 01:27:46 +05:30
drag(list_from_index: 1, list_to_index: 2, to_index: 3, duration: 1020)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 2)
expect(all('.board')[2]).to have_selector('.board-card', count: 4)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
page.within(all('.board')[2]) do
2018-11-08 19:23:39 +05:30
expect(all('.board-card').last).to have_content(issue3.title)
2017-08-17 22:00:37 +05:30
end
end
it 'moves to index of another list' do
2017-09-10 17:25:29 +05:30
drag(list_from_index: 1, list_to_index: 2, to_index: 1)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 2)
expect(all('.board')[2]).to have_selector('.board-card', count: 4)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
page.within(all('.board')[2]) do
2018-11-08 19:23:39 +05:30
expect(all('.board-card')[1]).to have_content(issue3.title)
2017-08-17 22:00:37 +05:30
end
end
end
2018-11-08 19:23:39 +05:30
def drag(selector: '.board-list', list_from_index: 1, from_index: 0, to_index: 0, list_to_index: 1, duration: 1000)
2017-08-17 22:00:37 +05:30
drag_to(selector: selector,
scrollable: '#board-app',
list_from_index: list_from_index,
from_index: from_index,
to_index: to_index,
2018-11-08 19:23:39 +05:30
list_to_index: list_to_index,
duration: duration)
2017-08-17 22:00:37 +05:30
end
end