OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/spec/features/work_packages/details/details_relations_spec.rb

113 lines
3.4 KiB

require 'spec_helper'
describe 'Work package relations tab', js: true, selenium: true do
let(:user) { FactoryGirl.create :admin }
8 years ago
let(:project) { FactoryGirl.create :project }
let(:work_package) { FactoryGirl.create(:work_package, project: project) }
let(:work_packages_page) { ::Pages::SplitWorkPackage.new(work_package) }
before do
login_as user
work_packages_page.visit_tab!('relations')
loading_indicator_saveguard
work_packages_page.expect_subject
end
describe 'no relations' do
it 'shows empty relation tabs' do
8 years ago
expect(page).to have_selector('.wp-relations-create')
expect(page).to have_selector('.wp-relations-hierarchy-section')
end
end
describe 'with parent' do
let(:parent) { FactoryGirl.create(:work_package) }
let(:work_package) { FactoryGirl.create(:work_package, parent: parent) }
8 years ago
it 'shows the parent in hierarchy section' do
expect(page).to have_selector('.wp-relations-hierarchy-subject a',
text: "#{parent.subject}")
end
end
describe 'create parent relationship' do
8 years ago
let(:parent) { FactoryGirl.create(:work_package, project: project) }
include_context 'ui-select helpers'
8 years ago
let(:user_role) do
FactoryGirl.create :role, permissions: permissions
end
8 years ago
8 years ago
let(:user) do
FactoryGirl.create :user,
member_in_project: project,
member_through_role: user_role
end
8 years ago
context 'with permissions' do
let(:permissions) { %i(view_work_packages manage_subtasks) }
8 years ago
8 years ago
it 'activates the change parent form' do
8 years ago
find('.wp-inline-create--add-link', text: I18n.t('js.relation_buttons.add_parent')).click
8 years ago
find('.inplace-edit--select').click
8 years ago
input = find(:css, ".ui-select-search")
input.set(parent.id)
8 years ago
sleep(2)
8 years ago
8 years ago
input.send_keys [:down, :return]
8 years ago
8 years ago
save_button = find(:xpath, ".//a[.//span//span[contains(concat(' ',@class,' '), ' icon-checkmark ')]]")
8 years ago
save_button.click
8 years ago
8 years ago
expect(page).to have_selector('.wp-relations-hierarchy-subject a',
text: "#{parent.subject}")
end
end
end
8 years ago
describe 'create child relationship' do
let(:child) { FactoryGirl.create(:work_package, project: project) }
include_context 'ui-select helpers'
let(:user_role) do
FactoryGirl.create :role, permissions: permissions
end
let(:user) do
FactoryGirl.create :user,
member_in_project: project,
member_through_role: user_role
end
context 'with permissions' do
let(:permissions) { %i(view_work_packages manage_subtasks) }
it 'activates the add existing child form' do
find('.wp-inline-create--add-link', text: I18n.t('js.relation_buttons.add_existing_child')).click
find('.inplace-edit--select').click
input = find(:css, ".ui-select-search")
input.set(child.id)
sleep(2)
input.send_keys [:down, :return]
save_button = find(:xpath, ".//a[.//span//span[contains(concat(' ',@class,' '), ' icon-checkmark ')]]")
save_button.click
sleep(2)
expect(page).to have_selector('.wp-relations-hierarchy-subject a',
text: "#{child.subject}")
end
end
end
end