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/modules/bim/spec/features/bim_navigation_spec.rb

175 lines
6.0 KiB

5 years ago
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
5 years ago
#
# 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-2013 Jean-Philippe Lang
5 years ago
# 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.
#++
require_relative '../spec_helper'
5 years ago
describe 'BIM navigation spec',
type: :feature,
with_config: { edition: 'bim' },
js: true do
let(:project) { FactoryBot.create :project, enabled_module_names: %i[bim work_package_tracking] }
5 years ago
let!(:work_package) { FactoryBot.create(:work_package, project: project) }
let(:role) do
FactoryBot.create(:role, permissions: %i[view_ifc_models manage_ifc_models view_work_packages delete_work_packages])
end
5 years ago
let(:user) do
FactoryBot.create :user,
member_in_project: project,
member_through_role: role
end
[37868] Whitelist for attachment mime types and extensions on upload (#9431) * Add setting for whitelist * Make attachments API BaseServices compatible * Add prepare service and contract * Correctly pass the filename to the UploadedFile * Add presence check to filename * Fix expected validation message * We no longer raise a multipart error when metadata is empty * Fix filesize validation on prepared uploads * Add parser error if invalid metadata json * When attachment is not saved, use filename property * Return correct error message on JSON parser erroro * Fix specs * Use attachment upload representer * Fix direct uploads mocks with new service layer * Lint * Fix export job using attachment service * Fix IFC controller using attachment prepare service * Fix export job * RenameRename params_getter to params_source * Fix mail handler using attachment service * Fix usage of attachment create service in documents * Reuse shared examples for document attachment spec * Fix stubbed attachment service in export job spec * Use admin user in backup spec * Fix export job for bim * Fix attachment integration spec * Fix issues_controller spec * Make budget resource spec reuse common examples * Fix attachment parsing representer spec * Replace prepare part of attachment spec into separate service spec * Clear cache for login spec * Convert document create/update into services * Budget services * Allow options to be passed to property twin * Remove setting author on budget initialize * Replace meetings update with services * Replace ifc models attachment handling with services * Don't check uploader if changed by system * Fix uploader being changed by system * Replace wiki page attach_files with attachable services * Replace avatar saving * Replace snapshot attach_files * Skip double validation when container present * Set snapshot through attachment service * Remove attach_files * Validate content type in contract * Enforce writing the content type without accepting user input * Expect changed content_type * Fix content of viewpoint image to get correct content type * Fix tsv spec * Add create contract spec * Bypass whitelist in internal services when conflicting with user * Fix expects in specs after whitelist bypass * Render contract errors for wiki * Add before_hook to bodied to allow to pre-authorize permissions * Budget errors from contract * Document errors from contract
3 years ago
let(:model) do
FactoryBot.create(:ifc_model_minimal_converted,
5 years ago
project: project,
uploader: user)
end
let(:card_view) { ::Pages::WorkPackageCards.new(project) }
let(:details_view) { ::Pages::BcfDetailsPage.new(work_package, project) }
let(:full_view) { Pages::FullWorkPackage.new(work_package) }
let(:model_tree) { ::Components::XeokitModelTree.new }
let(:destroy_modal) { Components::WorkPackages::DestroyModal.new }
5 years ago
[37868] Whitelist for attachment mime types and extensions on upload (#9431) * Add setting for whitelist * Make attachments API BaseServices compatible * Add prepare service and contract * Correctly pass the filename to the UploadedFile * Add presence check to filename * Fix expected validation message * We no longer raise a multipart error when metadata is empty * Fix filesize validation on prepared uploads * Add parser error if invalid metadata json * When attachment is not saved, use filename property * Return correct error message on JSON parser erroro * Fix specs * Use attachment upload representer * Fix direct uploads mocks with new service layer * Lint * Fix export job using attachment service * Fix IFC controller using attachment prepare service * Fix export job * RenameRename params_getter to params_source * Fix mail handler using attachment service * Fix usage of attachment create service in documents * Reuse shared examples for document attachment spec * Fix stubbed attachment service in export job spec * Use admin user in backup spec * Fix export job for bim * Fix attachment integration spec * Fix issues_controller spec * Make budget resource spec reuse common examples * Fix attachment parsing representer spec * Replace prepare part of attachment spec into separate service spec * Clear cache for login spec * Convert document create/update into services * Budget services * Allow options to be passed to property twin * Remove setting author on budget initialize * Replace meetings update with services * Replace ifc models attachment handling with services * Don't check uploader if changed by system * Fix uploader being changed by system * Replace wiki page attach_files with attachable services * Replace avatar saving * Replace snapshot attach_files * Skip double validation when container present * Set snapshot through attachment service * Remove attach_files * Validate content type in contract * Enforce writing the content type without accepting user input * Expect changed content_type * Fix content of viewpoint image to get correct content type * Fix tsv spec * Add create contract spec * Bypass whitelist in internal services when conflicting with user * Fix expects in specs after whitelist bypass * Render contract errors for wiki * Add before_hook to bodied to allow to pre-authorize permissions * Budget errors from contract * Document errors from contract
3 years ago
before do
login_as user
model
end
5 years ago
shared_examples 'can switch from split to viewer to list-only' do
before do
model_page.visit!
model_page.finished_loading
end
context 'deep link on the page' do
before do
model_page.visit!
model_page.finished_loading
# Should be at split view
model_page.model_viewer_visible true
model_page.model_viewer_shows_a_toolbar true
model_page.page_shows_a_toolbar true
model_tree.sidebar_shows_viewer_menu true
expect(page).to have_selector('[data-qa-selector="op-wp-card-view"]')
5 years ago
card_view.expect_work_package_listed work_package
end
5 years ago
it 'can switch between the different view modes' do
# Go to single view
card_view.open_full_screen_by_details(work_package)
details_view.ensure_page_loaded
details_view.expect_subject
details_view.switch_to_tab tab: 'Activity'
details_view.expect_tab 'Activity'
# Going to full screen and back again
details_view.switch_to_fullscreen
full_view.expect_tab 'Activity'
full_view.go_back
details_view.ensure_page_loaded
details_view.expect_subject
details_view.go_back
details_view.expect_closed
card_view.expect_work_package_listed work_package
5 years ago
# Go to viewer only
model_page.switch_view 'Viewer'
5 years ago
model_page.model_viewer_visible true
expect(page).to have_no_selector('[data-qa-selector="op-wp-card-view"]')
5 years ago
# Go to list only
model_page.switch_view 'Cards'
5 years ago
model_page.model_viewer_visible false
expect(page).to have_selector('[data-qa-selector="op-wp-card-view"]')
5 years ago
card_view.expect_work_package_listed work_package
# Go to single view
card_view.open_full_screen_by_details(work_package)
details_view.ensure_page_loaded
details_view.expect_subject
details_view.switch_to_tab tab: 'Activity'
details_view.expect_tab 'Activity'
details_view.close
details_view.expect_closed
5 years ago
end
it 'after deleting an WP in full view it returns to the model and list view (see #33317)' do
# Go to full single view
card_view.open_full_screen_by_details(work_package)
details_view.switch_to_fullscreen
full_view.expect_tab 'Activity'
# Delete via the context menu
find('#action-show-more-dropdown-menu .button').click
find('.menu-item', text: 'Delete').click
destroy_modal.expect_listed(work_package)
destroy_modal.confirm_deletion
# Expect to return to the start page with closed details view and delete WP
model_page.model_viewer_visible true
details_view.expect_closed
card_view.expect_work_package_not_listed work_package
end
it 'after going to the full view with a selected tab,
the same tab shoud be opened in full screen view and after going back to details view(see #33747)' do
card_view.open_full_screen_by_details(work_package)
details_view.ensure_page_loaded
details_view.expect_subject
details_view.switch_to_tab tab: 'Relations'
details_view.switch_to_fullscreen
full_view.expect_tab 'Relations'
full_view.go_back
details_view.expect_tab 'Relations'
end
5 years ago
end
end
context 'on default page' do
let(:model_page) { ::Pages::IfcModels::ShowDefault.new project }
it_behaves_like 'can switch from split to viewer to list-only'
end
context 'on show page' do
let(:model_page) { ::Pages::IfcModels::Show.new project, model.id }
it_behaves_like 'can switch from split to viewer to list-only'
end
end