|
|
|
@ -9,9 +9,17 @@ describe 'Work package relations tab', js: true, selenium: true do |
|
|
|
|
let(:work_package) { FactoryGirl.create(:work_package, project: project) } |
|
|
|
|
let(:work_packages_page) { ::Pages::SplitWorkPackage.new(work_package) } |
|
|
|
|
|
|
|
|
|
let(:visit) { true } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
login_as user |
|
|
|
|
|
|
|
|
|
if visit |
|
|
|
|
visit_relations |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def visit_relations |
|
|
|
|
work_packages_page.visit_tab!('relations') |
|
|
|
|
work_packages_page.expect_subject |
|
|
|
|
loading_indicator_saveguard |
|
|
|
@ -41,7 +49,6 @@ describe 'Work package relations tab', js: true, selenium: true do |
|
|
|
|
|
|
|
|
|
# Labels to expect |
|
|
|
|
relation_label = I18n.t('js.relation_labels.' + relation_type) |
|
|
|
|
type_upcase = wp.type.name.upcase |
|
|
|
|
|
|
|
|
|
select relation_label, from: 'relation-type--select' |
|
|
|
|
|
|
|
|
@ -52,10 +59,10 @@ describe 'Work package relations tab', js: true, selenium: true do |
|
|
|
|
container.find('.wp-create-relation--save').click |
|
|
|
|
|
|
|
|
|
expect(page).to have_selector('.relation-group--header', |
|
|
|
|
text: type_upcase, |
|
|
|
|
text: relation_label.upcase, |
|
|
|
|
wait: 10) |
|
|
|
|
|
|
|
|
|
expect(page).to have_selector('.relation-row--type', text: relation_label) |
|
|
|
|
expect(page).to have_selector('.relation-row--type', text: wp.type.name) |
|
|
|
|
|
|
|
|
|
expect(page).to have_selector('.wp-relations--subject-field', text: wp.subject) |
|
|
|
|
|
|
|
|
@ -106,6 +113,58 @@ describe 'Work package relations tab', js: true, selenium: true do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'relation group-by toggler' do |
|
|
|
|
let(:project) { FactoryGirl.create :project, types: [type_1, type_2] } |
|
|
|
|
let(:type_1) { FactoryGirl.create :type } |
|
|
|
|
let(:type_2) { FactoryGirl.create :type } |
|
|
|
|
|
|
|
|
|
let(:to_1) { FactoryGirl.create(:work_package, type: type_1, project: project) } |
|
|
|
|
let(:to_2) { FactoryGirl.create(:work_package, type: type_2, project: project) } |
|
|
|
|
|
|
|
|
|
let!(:relation_1) do |
|
|
|
|
FactoryGirl.create :relation, |
|
|
|
|
from: work_package, |
|
|
|
|
to: to_1, |
|
|
|
|
relation_type: :follows |
|
|
|
|
end |
|
|
|
|
let!(:relation_2) do |
|
|
|
|
FactoryGirl.create :relation, |
|
|
|
|
from: work_package, |
|
|
|
|
to: to_2, |
|
|
|
|
relation_type: :relates |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
let(:toggle_btn_selector) { '#wp-relation-group-by-toggle' } |
|
|
|
|
let(:visit) { false } |
|
|
|
|
|
|
|
|
|
it 'allows to toggle how relations are grouped' do |
|
|
|
|
visit_relations |
|
|
|
|
|
|
|
|
|
work_packages_page.visit_tab!('relations') |
|
|
|
|
work_packages_page.expect_subject |
|
|
|
|
loading_indicator_saveguard |
|
|
|
|
|
|
|
|
|
# Expect to be grouped by relation type by default |
|
|
|
|
expect(page).to have_selector(toggle_btn_selector, |
|
|
|
|
text: 'Group by work package type', wait: 10) |
|
|
|
|
|
|
|
|
|
expect(page).to have_selector('.relation-group--header', text: 'FOLLOWS') |
|
|
|
|
expect(page).to have_selector('.relation-group--header', text: 'RELATED TO') |
|
|
|
|
|
|
|
|
|
expect(page).to have_selector('.relation-row--type', text: type_1.name) |
|
|
|
|
expect(page).to have_selector('.relation-row--type', text: type_2.name) |
|
|
|
|
|
|
|
|
|
find(toggle_btn_selector).click |
|
|
|
|
expect(page).to have_selector(toggle_btn_selector, text: 'Group by relation type', wait: 10) |
|
|
|
|
|
|
|
|
|
expect(page).to have_selector('.relation-group--header', text: type_1.name.upcase) |
|
|
|
|
expect(page).to have_selector('.relation-group--header', text: type_2.name.upcase) |
|
|
|
|
|
|
|
|
|
expect(page).to have_selector('.relation-row--type', text: 'Follows') |
|
|
|
|
expect(page).to have_selector('.relation-row--type', text: 'Related To') |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'with limited permissions' do |
|
|
|
|
let(:permissions) { %i(view_work_packages) } |
|
|
|
|
let(:user_role) do |
|
|
|
@ -200,8 +259,7 @@ describe 'Work package relations tab', js: true, selenium: true do |
|
|
|
|
created_row.hover |
|
|
|
|
created_row.find('.relation-row--remove-btn').click |
|
|
|
|
|
|
|
|
|
expect(page).to have_no_selector('.relation-group--header', |
|
|
|
|
text: relatable.type.name.upcase) |
|
|
|
|
expect(page).to have_no_selector('.relation-group--header', text: 'FOLLOWS') |
|
|
|
|
expect(page).to have_no_selector('.wp-relations--subject-field', text: relatable.subject) |
|
|
|
|
|
|
|
|
|
work_package.reload |
|
|
|
|