Add some feature tests

pull/5505/head
Oliver Günther 8 years ago
parent 4ad0647aac
commit e1ef3157a8
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 123
      spec/features/work_packages/timeline/timeline_hierarchy_spec.rb
  2. 40
      spec/features/work_packages/timeline/timeline_navigation_spec.rb
  3. 42
      spec/support/pages/work_packages_timeline.rb

@ -0,0 +1,123 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
RSpec.feature 'Work package timeline hierarchies', js: true, selenium: true do
let(:user) { FactoryGirl.create :admin }
let(:project) { FactoryGirl.create(:project) }
let(:wp_table) { Pages::WorkPackagesTable.new(project) }
let(:hierarchy) { ::Components::WorkPackages::Hierarchies.new }
let(:wp_timeline) { Pages::WorkPackagesTimeline.new(project) }
let(:settings_menu) { Components::WorkPackages::SettingsMenu.new }
before do
login_as(user)
end
let!(:wp_root) do
FactoryGirl.create :work_package,
project: project
end
let!(:wp_leaf) do
FactoryGirl.create :work_package,
project: project,
parent: wp_root,
start_date: Date.today,
due_date: (Date.today + 5.days)
end
let!(:query) do
query = FactoryGirl.build(:query, user: user, project: project)
query.column_names = ['subject']
query.filters.clear
query.show_hierarchies = true
query.timeline_visible = true
query.save!
query
end
it 'hides the row in both hierarchy and timeline' do
wp_timeline.visit_query query
# Expect root and leaf visible in table and timeline
wp_timeline.expect_work_package_listed(wp_root, wp_leaf)
# Hide the hierarchy root
hierarchy.expect_hierarchy_at(wp_root)
hierarchy.expect_leaf_at(wp_leaf)
# Toggling hierarchies hides the inner children
hierarchy.toggle_row(wp_root)
# Root, other showing
wp_timeline.expect_work_package_listed(wp_root)
# Inter, Leaf hidden
hierarchy.expect_hidden(wp_leaf)
wp_timeline.expect_hidden_row(wp_leaf)
# Should now have exactly two rows (one in each split view)
expect(page).to have_selector('.wp--row', count: 2)
end
context 'with a relation being rendered to a hidden row' do
let!(:wp_other) do
FactoryGirl.create :work_package,
project: project,
start_date: Date.today + 5.days,
due_date: (Date.today + 10.days)
end
let!(:relation) do
FactoryGirl.create(:relation,
from: wp_leaf,
to: wp_other,
relation_type: Relation::TYPE_FOLLOWS)
end
it 'does not render the relation when hierarchy is collapsed' do
wp_timeline.visit_query query
# Expect root and leaf visible in table and timeline
wp_timeline.expect_work_package_listed(wp_root, wp_leaf, wp_other)
wp_timeline.expect_timeline_relation(wp_leaf, wp_other)
# Toggling hierarchies hides the inner children
hierarchy.toggle_row(wp_root)
wp_timeline.expect_work_package_listed(wp_root, wp_other)
hierarchy.expect_hidden(wp_leaf)
# Relation should now not be rendered
wp_timeline.expect_no_timeline_relation(wp_leaf, wp_other)
wp_timeline.expect_no_relations
end
end
end

@ -115,16 +115,39 @@ RSpec.feature 'Work package timeline navigation', js: true, selenium: true do
let(:project) { FactoryGirl.create(:project) }
let(:category) { FactoryGirl.create :category, project: project, name: 'Foo' }
let(:category2) { FactoryGirl.create :category, project: project, name: 'Bar' }
let!(:wp_cat1) { FactoryGirl.create(:work_package, project: project, category: category) }
let!(:wp_cat2) { FactoryGirl.create(:work_package, project: project, category: category2) }
let!(:wp_none) { FactoryGirl.create(:work_package, project: project) }
let(:wp_table) { Pages::WorkPackagesTable.new(project) }
let!(:wp_cat1) do
FactoryGirl.create :work_package,
project: project,
category: category,
start_date: Date.today,
due_date: (Date.today + 5.days)
end
let!(:wp_cat2) do
FactoryGirl.create :work_package,
project: project,
category: category2,
start_date: Date.today + 5.days,
due_date: (Date.today + 10.days)
end
let!(:wp_none) do
FactoryGirl.create :work_package,
project: project
end
let!(:relation) do
FactoryGirl.create(:relation,
from: wp_cat1,
to: wp_cat2,
relation_type: Relation::TYPE_FOLLOWS)
end
let!(:query) do
query = FactoryGirl.build(:query, user: user, project: project)
query.column_names = ['subject', 'category']
query.show_hierarchies = false
query.timeline_visible = true
query.save!
query
@ -142,10 +165,15 @@ RSpec.feature 'Work package timeline navigation', js: true, selenium: true do
# Expect table to be grouped as WP created above
expect(page).to have_selector('.group--value .count', count: 3)
# Expect timeline to have relation between first and second group
wp_timeline.expect_timeline_relation(wp_cat1, wp_cat2)
# Collapse first section
find('#wp-table-rowgroup-0').click
wp_table.expect_work_package_not_listed(wp_cat1)
wp_timeline.expect_hidden_row(wp_cat1)
wp_timeline.expect_work_package_not_listed(wp_cat1)
# Relation should be hidden
wp_timeline.expect_no_timeline_relation(wp_cat1, wp_cat2)
end
end
end

@ -39,6 +39,30 @@ module Pages
"#wp-timeline-row-#{wp_id}"
end
def timeline_container
'.work-packages-tabletimeline--timeline-side'
end
def expect_work_package_listed(*work_packages)
super(*work_packages)
within(table_container) do
work_packages.each do |wp|
expect(page).to have_selector("#wp-timeline-row-#{wp.id}", visible: true)
end
end
end
def expect_work_package_not_listed(*work_packages)
super(*work_packages)
within(table_container) do
work_packages.each do |wp|
expect(page).to have_no_selector("#wp-timeline-row-#{wp.id}", visible: true)
end
end
end
def expect_timeline!(open: true)
if open
expect(page).to have_selector('#work-packages-timeline-toggle-button.-active')
@ -54,6 +78,24 @@ module Pages
expect(page).to have_selector("#{timeline_row_selector(work_package.id)} .timeline-element.#{type}")
end
def expect_timeline_relation(from, to)
within(timeline_container) do
expect(page).to have_selector(".relation-line.__tl-relation-#{from.id}-#{to.id}", minimum: 1)
end
end
def expect_no_timeline_relation(from, to)
within(timeline_container) do
expect(page).to have_no_selector(".relation-line.__tl-relation-#{from.id}-#{to.id}")
end
end
def expect_no_relations
within(timeline_container) do
expect(page).to have_no_selector(".relation-line")
end
end
def expect_hidden_row(work_package)
expect(page).to have_selector("#wp-timeline-row-#{work_package.id}", visible: :hidden)
end

Loading…
Cancel
Save