Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add spec

Oliver Günther371440696404
diff --git a/modules/bim/spec/features/bcf/create_spec.rb b/modules/bim/spec/features/bcf/create_spec.rb
index 8559c8c845d..071cbad3375 100644
--- a/modules/bim/spec/features/bcf/create_spec.rb
+++ b/modules/bim/spec/features/bcf/create_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
-
-require_relative '../../support/pages/ifc_models/show_default'
-
+require_relative '../../spec_helper'
describe 'Create BCF', type: :feature, js: true, with_mail: false do
let(:project) do
- FactoryBot.create(:project, types: [type, type_with_cf], work_package_custom_fields: [integer_cf])
+ FactoryBot.create(:project,
+ types: [type, type_with_cf],
+ enabled_module_names: %i[bim work_package_tracking],
+ work_package_custom_fields: [integer_cf])
end
let(:index_page) { Pages::IfcModels::ShowDefault.new(project) }
- let(:permissions) { %i[view_ifc_models manage_ifc_models add_work_packages view_work_packages] }
+ let(:permissions) { %i[view_ifc_models manage_ifc_models view_linked_issues manage_bcf add_work_packages edit_work_packages view_work_packages] }
let!(:status) { FactoryBot.create(:default_status) }
let!(:priority) { FactoryBot.create :priority, is_default: true }
@@ -31,7 +31,7 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false do
FactoryBot.create(:int_wp_custom_field)
end
- shared_examples 'bcf details creation' do
+ shared_examples 'bcf details creation' do |with_viewpoints|
it 'can create a new bcf work package' do
create_page = index_page.create_wp_by_button(type)
create_page.view_route = view_route
@@ -40,6 +40,24 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false do
create_page.subject_field.set(subject)
+ if with_viewpoints
+ create_page.add_viewpoint
+ create_page.expect_viewpoint_count 1
+
+ sleep 1
+ create_page.add_viewpoint
+ create_page.expect_viewpoint_count 2
+
+ # Create and delete one viewpoint
+ sleep 1
+ create_page.add_viewpoint
+ create_page.expect_viewpoint_count 3
+
+ # Expect no confirm dialog to be present
+ create_page.delete_current_viewpoint
+ create_page.expect_viewpoint_count 2
+ end
+
# switch the type
type_field = create_page.edit_field(:type)
type_field.activate!
@@ -50,10 +68,16 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false do
create_page.save!
+ sleep 5
+
index_page.expect_and_dismiss_notification(
message: 'Successful creation. Click here to open this work package in fullscreen view.'
)
+ if with_viewpoints
+ create_page.expect_viewpoint_count 2
+ end
+
work_package = WorkPackage.last
split_page = ::Pages::SplitWorkPackage.new(work_package, project)
split_page.ensure_page_loaded
@@ -62,6 +86,11 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false do
split_page.close
split_page.expect_closed
+ if with_viewpoints
+ expect(work_package.bcf_issue).to be_present
+ expect(work_package.bcf_issue.viewpoints.count).to eq 2
+ end
+
expect(page).to have_current_path /bcf\/#{Regexp.escape(view_route)}$/, ignore_query: true
end
end
@@ -77,7 +106,7 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false do
index_page.visit!
end
- it_behaves_like 'bcf details creation'
+ it_behaves_like 'bcf details creation', true
end
context 'on the split page switching to list' do
@@ -88,7 +117,7 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false do
expect(page).to have_current_path /\/bcf\/list$/, ignore_query: true
end
- it_behaves_like 'bcf details creation'
+ it_behaves_like 'bcf details creation', false
end
context 'starting on the list page' do
@@ -98,7 +127,7 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false do
expect(page).to have_current_path /\/bcf\/list$/, ignore_query: true
end
- it_behaves_like 'bcf details creation'
+ it_behaves_like 'bcf details creation', false
end
context 'starting on the details page of an existing work package' do
diff --git a/modules/bim/spec/support/components/bcf_details_viewpoints.rb b/modules/bim/spec/support/components/bcf_details_viewpoints.rb
new file mode 100644
index 00000000000..25f27a5ef7c
--- /dev/null
+++ b/modules/bim/spec/support/components/bcf_details_viewpoints.rb
@@ -0,0 +1,62 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2020 the OpenProject GmbH
+#
+# 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 docs/COPYRIGHT.rdoc for more details.
+#++
+
+module Components
+ module BcfDetailsViewpoints
+
+ def expect_viewpoint_count(number)
+ expect(page).to have_selector('.ngx-gallery-thumbnail', visible: :all, count: number, wait: 20)
+ end
+
+ def next_viewpoint
+ page.find('.icon-arrow-right2.ngx-gallery-icon-content').click
+ end
+
+ def previous_viewpoint
+ page.find('.icon-arrow-left2.ngx-gallery-icon-content').click
+ end
+
+ def show_current_viewpoint
+ page.find('.icon-watched.ngx-gallery-icon-content').click
+ end
+
+ def delete_current_viewpoint(confirm: true)
+ page.find('.icon-delete.ngx-gallery-icon-content').click
+
+ if confirm
+ page.driver.browser.switch_to.alert.accept
+ else
+ page.driver.browser.switch_to.alert.dismiss
+ end
+ end
+
+ def add_viewpoint
+ page.find('a.button', text: 'Viewpoint').click
+ end
+ end
+end
diff --git a/modules/bim/spec/support/pages/bcf/create_split.rb b/modules/bim/spec/support/pages/bcf/create_split.rb
index b749beee5fb..4ff51695cb8 100644
--- a/modules/bim/spec/support/pages/bcf/create_split.rb
+++ b/modules/bim/spec/support/pages/bcf/create_split.rb
@@ -28,10 +28,13 @@
require 'support/pages/page'
require 'support/pages/work_packages/abstract_work_package_create'
+require_relative '../../components/bcf_details_viewpoints'
module Pages
module BCF
class CreateSplit < ::Pages::AbstractWorkPackageCreate
+ include ::Components::BcfDetailsViewpoints
+
attr_accessor :project,
:model_id,
:type_id,
@@ -44,6 +47,11 @@ module Pages
self.view_route = :split
end
+ # Override delete viewpoint since we don't have confirm alert
+ def delete_current_viewpoint
+ page.find('.icon-delete.ngx-gallery-icon-content').click
+ end
+
def path
bcf_project_frontend_path(project, "#{view_route}/create_new")
end
diff --git a/modules/bim/spec/support/pages/ifc_models/bcf_details_page.rb b/modules/bim/spec/support/pages/ifc_models/bcf_details_page.rb
index e72c5979bcc..9acd6551198 100644
--- a/modules/bim/spec/support/pages/ifc_models/bcf_details_page.rb
+++ b/modules/bim/spec/support/pages/ifc_models/bcf_details_page.rb
@@ -27,38 +27,11 @@
#++
require 'support/pages/work_packages/split_work_package'
+require_relative '../../components/bcf_details_viewpoints'
module Pages
class BcfDetailsPage < Pages::SplitWorkPackage
- def expect_viewpoint_count(number)
- expect(page).to have_selector('.ngx-gallery-thumbnail', count: number, wait: 20)
- end
-
- def next_viewpoint
- page.find('.icon-arrow-right2.ngx-gallery-icon-content').click
- end
-
- def previous_viewpoint
- page.find('.icon-arrow-left2.ngx-gallery-icon-content').click
- end
-
- def show_current_viewpoint
- page.find('.icon-watched.ngx-gallery-icon-content').click
- end
-
- def delete_current_viewpoint(confirm: true)
- page.find('.icon-delete.ngx-gallery-icon-content').click
-
- if confirm
- page.driver.browser.switch_to.alert.accept
- else
- page.driver.browser.switch_to.alert.dismiss
- end
- end
-
- def add_viewpoint
- page.find('a.button', text: 'Viewpoint').click
- end
+ include ::Components::BcfDetailsViewpoints
protected