From af0ebe7bdc2a3e4e2b86f33ad79453852b542dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 3 Mar 2020 14:47:01 +0100 Subject: [PATCH] Specs --- .../wp-button-macro.modal.ts | 3 +- .../routing/split-view-routes.template.ts | 2 +- modules/bim/spec/features/bcf/create_spec.rb | 36 +++++++++++++++++-- modules/bim/spec/features/bcf/export_spec.rb | 2 +- .../spec/support/pages/bcf/create_split.rb | 22 ++++-------- .../support/pages/ifc_models/show_default.rb | 2 +- .../work_package_by_button_creator.rb | 2 +- 7 files changed, 45 insertions(+), 24 deletions(-) diff --git a/frontend/src/app/components/modals/editor/macro-wp-button-modal/wp-button-macro.modal.ts b/frontend/src/app/components/modals/editor/macro-wp-button-modal/wp-button-macro.modal.ts index b9cf9e8ea3..6e61c88348 100644 --- a/frontend/src/app/components/modals/editor/macro-wp-button-modal/wp-button-macro.modal.ts +++ b/frontend/src/app/components/modals/editor/macro-wp-button-modal/wp-button-macro.modal.ts @@ -44,8 +44,7 @@ import {CurrentProjectService} from "core-components/projects/current-project.se import {WorkPackageDmService} from "core-app/modules/hal/dm-services/work-package-dm.service"; @Component({ - templateUrl: './wp-button-macro.modal.html', - changeDetection: ChangeDetectionStrategy.OnPush + templateUrl: './wp-button-macro.modal.html' }) export class WpButtonMacroModal extends OpModalComponent implements AfterViewInit { diff --git a/frontend/src/app/modules/work_packages/routing/split-view-routes.template.ts b/frontend/src/app/modules/work_packages/routing/split-view-routes.template.ts index aa93277fd9..abf1daca2a 100644 --- a/frontend/src/app/modules/work_packages/routing/split-view-routes.template.ts +++ b/frontend/src/app/modules/work_packages/routing/split-view-routes.template.ts @@ -115,7 +115,7 @@ export function makeSplitViewRoutes(baseRoute:string, // Split create route { name: baseRoute + '.new', - url: '/new?{type:[0-9]+}', + url: '/create_new?{type:[0-9]+}', reloadOnSearch: false, data: { partition: '-split', diff --git a/modules/bim/spec/features/bcf/create_spec.rb b/modules/bim/spec/features/bcf/create_spec.rb index c61201ab23..f99f1538d4 100644 --- a/modules/bim/spec/features/bcf/create_spec.rb +++ b/modules/bim/spec/features/bcf/create_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' require_relative '../../support/pages/ifc_models/show_default' + 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]) @@ -36,7 +37,7 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false do end context 'with all permissions' do - it 'can create a new bcf work package' do + it 'can create a new bcf work package on split page' do create_page = index_page.create_wp_by_button(type) create_page.expect_current_path @@ -53,14 +54,43 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false do create_page.save! - # TODO: adapt notification message index_page.expect_and_dismiss_notification( message: 'Successful creation. Click here to open this work package in fullscreen view.' ) work_package = WorkPackage.last + split_page = ::Pages::SplitWorkPackage.new(work_package, project) + split_page.ensure_page_loaded + split_page.expect_subject + + split_page.close + split_page.expect_closed + + expect(page).to have_current_path /\/bcf\/split$/, ignore_query: true + end + + it 'can create on the list view' do + index_page.switch_view 'List' + + create_page = index_page.create_wp_by_button(type) + create_page.view_route = :list + create_page.expect_current_path + create_page.subject_field.set(subject) + create_page.save! + + index_page.expect_and_dismiss_notification( + message: 'Successful creation. Click here to open this work package in fullscreen view.' + ) + + work_package = WorkPackage.last + split_page = ::Pages::SplitWorkPackage.new(work_package, project) + split_page.ensure_page_loaded + split_page.expect_subject + + split_page.close + split_page.expect_closed - index_page.expect_work_package_listed(work_package) + expect(page).to have_current_path /\/bcf\/list$/, ignore_query: true end end diff --git a/modules/bim/spec/features/bcf/export_spec.rb b/modules/bim/spec/features/bcf/export_spec.rb index 67e7960f71..08efcaa1d0 100644 --- a/modules/bim/spec/features/bcf/export_spec.rb +++ b/modules/bim/spec/features/bcf/export_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe 'bcf export', type: :feature, js: true do let(:status) { FactoryBot.create(:status, name: 'New', is_default: true) } let(:closed_status) { FactoryBot.create(:closed_status, name: 'Closed') } - let(:project) { FactoryBot.create :project, enabled_module_names: [:bim, :work_package_tracking] } + let(:project) { FactoryBot.create :project, enabled_module_names: %i[bim work_package_tracking] } let!(:open_work_package) { FactoryBot.create(:work_package, project: project, subject: 'Open WP', status: status) } let!(:closed_work_package) { FactoryBot.create(:work_package, project: project, subject: 'Closed WP', status: closed_status) } diff --git a/modules/bim/spec/support/pages/bcf/create_split.rb b/modules/bim/spec/support/pages/bcf/create_split.rb index fad4569316..b749beee5f 100644 --- a/modules/bim/spec/support/pages/bcf/create_split.rb +++ b/modules/bim/spec/support/pages/bcf/create_split.rb @@ -34,35 +34,27 @@ module Pages class CreateSplit < ::Pages::AbstractWorkPackageCreate attr_accessor :project, :model_id, - :type_id + :type_id, + :view_route - def initialize(project, model_id: nil, type_id: nil) + def initialize(project:, model_id: nil, type_id: nil) super(project: project) self.model_id = model_id self.type_id = type_id + self.view_route = :split end def path - path = if default? - defaults_ifc_models_project_ifc_models_path(project) - else - ifc_models_project_ifc_model(project, id: model_id) - end + '/new' - - query = if type_id - "?type=#{type_id}" - end - - path + query + bcf_project_frontend_path(project, "#{view_route}/create_new") end def expect_current_path expect(page) - .to have_current_path(path) + .to have_current_path(path, ignore_query: true) end def container - find("bcf-new-split") + find("wp-new-split-view") end private diff --git a/modules/bim/spec/support/pages/ifc_models/show_default.rb b/modules/bim/spec/support/pages/ifc_models/show_default.rb index 731163dd9c..4126217a95 100644 --- a/modules/bim/spec/support/pages/ifc_models/show_default.rb +++ b/modules/bim/spec/support/pages/ifc_models/show_default.rb @@ -101,7 +101,7 @@ module Pages end def create_page_class_instance(type) - create_page_class.new(project, type_id: type.id) + create_page_class.new(project: project, type_id: type.id) end def create_page_class diff --git a/spec/support/pages/work_packages/concerns/work_package_by_button_creator.rb b/spec/support/pages/work_packages/concerns/work_package_by_button_creator.rb index 34ed0880c7..c33195900a 100644 --- a/spec/support/pages/work_packages/concerns/work_package_by_button_creator.rb +++ b/spec/support/pages/work_packages/concerns/work_package_by_button_creator.rb @@ -64,7 +64,7 @@ module Pages private def create_page_class_instance(_type) - create_page_class.new(project) + create_page_class.new(project: project) end def create_page_class