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/table/context_menu_spec.rb

167 lines
6.0 KiB

require 'spec_helper'
describe 'Work package table context menu', js: true do
let(:user) { FactoryBot.create(:admin) }
let(:work_package) { FactoryBot.create(:work_package) }
let(:wp_table) { Pages::WorkPackagesTable.new }
let(:wp_timeline) { Pages::WorkPackagesTimeline.new(work_package.project) }
let(:menu) { Components::WorkPackages::ContextMenu.new }
let(:destroy_modal) { Components::WorkPackages::DestroyModal.new }
let(:time_logging_modal) { Components::TimeLoggingModal.new }
let(:display_representation) { ::Components::WorkPackages::DisplayRepresentation.new }
def goto_context_menu(list_view = true)
# Go to table
wp_table.visit!
wp_table.expect_work_package_listed(work_package)
display_representation.switch_to_card_layout unless list_view
loading_indicator_saveguard
# Open context menu
menu.expect_closed
menu.open_for(work_package)
end
shared_examples_for 'provides a context menu' do
let(:list_view) { raise 'needs to be defined' }
context 'for a single work package' do
it 'provide a context menu' do
# Open detail pane
goto_context_menu list_view
menu.choose('Open details view')
split_page = Pages::SplitWorkPackage.new(work_package)
split_page.expect_attributes Subject: work_package.subject
# Open full view
goto_context_menu list_view
menu.choose('Open fullscreen view')
[31023] Preparation for project edit fields: Generalize edit and display fields currently work package specific (#7726) * Check edit fields for Work package dependencies * Make EditForm, NotificationService, EditContext indepenedent of Work Packages * Make EventsService independent of WorkPackages * Start renaming WpNotificationService (WiP) * Fix more references * Fix typescript errors * Add basic halEditingService * Rename to global halResourceEditingService (WiP) * Move typing from class to methods (WiP) * Fix typescript errors * Remove space in type * Add test project widget && generalize the editFieldGroup * Rename editing portal service [ci skip] * Rename WpEditFieldComponent * Rename WpDisplayFields * Rename display-XX-field to XX-display-field [ci skip] * Add WP specific ID field to distinguish between resources * Re-add state in work package resource * Generalize display field renderer * Rename spent-time to wp-spent-time and fix highlight specifics [ci skip] * Actually load the project schema and make field editable * Make edit-field-group.component an edit-form.component and subclass EditForm * Remove edit context in favor of specialized EditForm * Add special cases for work package editing * Fix edit actions bar * Fix codeclimate issues * Use WorkPackageNotificationService if necessary * Override NotificationService for WPs to allow WP specififc notifications (WiP) * Correctly provide wpNotification service Because the ui-router doesn't seem to correctly use the parent element's injector, we need to provide the wpNotification service not in the wp-base, but rather the wp-list component as well as in the isolated query space. * Allow to filter halEvents for specific resourceTypes (e.g. WorkPackage) * Remove superfluous cell class constant * Start renaming selectors for wp-edit-field into generics * Remove wp-table--cell-span in favor of display field selector * Consolidate other display and edit field styles * Provide specialized service for transitions in active edit forms * Remove superfluous overflowSelector * Accept that date field contains some work package specifics * Ignore unreadable files * Provide the changeset for work packages as a hook Since hal resource editing service is provided per query space, we cannot register them once (would only work globally) * Fix dangerfile * Remove another todo in halResourceNotification service * Fix npm TestBed for changed dependencies * Show inplace edit field in project details widget * Fix highlighting in single view * Provide HalResourceEditingService outside of project context * Used typedState for single-view * Also provide wpNotification service in split view * Correct check for resource type in eventsService * Fix getSchemaName in display field renderer * Fix passing ids into `halEditing.stopEditing` * Do not globally inject the halResourceEditingService There's a bug(?) in ui-router that gives you the global service before the parent injected service for a ui-view * Fix wpCreate service on copying and parallel creation * Remove test project widget * Revert changes for project details widget
5 years ago
expect(page).to have_selector('.work-packages--show-view .inline-edit--container.subject',
text: work_package.subject)
# Open log time
goto_context_menu list_view
menu.choose('Log time')
time_logging_modal.is_visible true
time_logging_modal.work_package_is_missing false
time_logging_modal.perform_action 'Cancel'
# Open Move
goto_context_menu list_view
menu.choose('Change project')
expect(page).to have_selector('h2', text: I18n.t(:button_move))
expect(page).to have_selector('a.work_package', text: "##{work_package.id}")
# Open Copy
goto_context_menu list_view
menu.choose('Copy')
# Split view open in copy state
expect(page)
.to have_selector('.wp-new-top-row',
text: "#{work_package.status.name.capitalize}\n#{work_package.type.name.upcase}")
expect(page).to have_field('wp-new-inline-edit--field-subject', with: work_package.subject)
# Open Delete
goto_context_menu list_view
menu.choose('Delete')
destroy_modal.expect_listed(work_package)
destroy_modal.cancel_deletion
# Open create new child
goto_context_menu list_view
menu.choose('Create new child')
[31023] Preparation for project edit fields: Generalize edit and display fields currently work package specific (#7726) * Check edit fields for Work package dependencies * Make EditForm, NotificationService, EditContext indepenedent of Work Packages * Make EventsService independent of WorkPackages * Start renaming WpNotificationService (WiP) * Fix more references * Fix typescript errors * Add basic halEditingService * Rename to global halResourceEditingService (WiP) * Move typing from class to methods (WiP) * Fix typescript errors * Remove space in type * Add test project widget && generalize the editFieldGroup * Rename editing portal service [ci skip] * Rename WpEditFieldComponent * Rename WpDisplayFields * Rename display-XX-field to XX-display-field [ci skip] * Add WP specific ID field to distinguish between resources * Re-add state in work package resource * Generalize display field renderer * Rename spent-time to wp-spent-time and fix highlight specifics [ci skip] * Actually load the project schema and make field editable * Make edit-field-group.component an edit-form.component and subclass EditForm * Remove edit context in favor of specialized EditForm * Add special cases for work package editing * Fix edit actions bar * Fix codeclimate issues * Use WorkPackageNotificationService if necessary * Override NotificationService for WPs to allow WP specififc notifications (WiP) * Correctly provide wpNotification service Because the ui-router doesn't seem to correctly use the parent element's injector, we need to provide the wpNotification service not in the wp-base, but rather the wp-list component as well as in the isolated query space. * Allow to filter halEvents for specific resourceTypes (e.g. WorkPackage) * Remove superfluous cell class constant * Start renaming selectors for wp-edit-field into generics * Remove wp-table--cell-span in favor of display field selector * Consolidate other display and edit field styles * Provide specialized service for transitions in active edit forms * Remove superfluous overflowSelector * Accept that date field contains some work package specifics * Ignore unreadable files * Provide the changeset for work packages as a hook Since hal resource editing service is provided per query space, we cannot register them once (would only work globally) * Fix dangerfile * Remove another todo in halResourceNotification service * Fix npm TestBed for changed dependencies * Show inplace edit field in project details widget * Fix highlighting in single view * Provide HalResourceEditingService outside of project context * Used typedState for single-view * Also provide wpNotification service in split view * Correct check for resource type in eventsService * Fix getSchemaName in display field renderer * Fix passing ids into `halEditing.stopEditing` * Do not globally inject the halResourceEditingService There's a bug(?) in ui-router that gives you the global service before the parent injected service for a ui-view * Fix wpCreate service on copying and parallel creation * Remove test project widget * Revert changes for project details widget
5 years ago
expect(page).to have_selector('.inline-edit--container.subject input')
expect(page).to have_selector('.inline-edit--field.type')
expect(current_url).to match(/.*\/create_new\?.*(&)*parent_id=#{work_package.id}/)
find('#work-packages--edit-actions-cancel').click
[31023] Preparation for project edit fields: Generalize edit and display fields currently work package specific (#7726) * Check edit fields for Work package dependencies * Make EditForm, NotificationService, EditContext indepenedent of Work Packages * Make EventsService independent of WorkPackages * Start renaming WpNotificationService (WiP) * Fix more references * Fix typescript errors * Add basic halEditingService * Rename to global halResourceEditingService (WiP) * Move typing from class to methods (WiP) * Fix typescript errors * Remove space in type * Add test project widget && generalize the editFieldGroup * Rename editing portal service [ci skip] * Rename WpEditFieldComponent * Rename WpDisplayFields * Rename display-XX-field to XX-display-field [ci skip] * Add WP specific ID field to distinguish between resources * Re-add state in work package resource * Generalize display field renderer * Rename spent-time to wp-spent-time and fix highlight specifics [ci skip] * Actually load the project schema and make field editable * Make edit-field-group.component an edit-form.component and subclass EditForm * Remove edit context in favor of specialized EditForm * Add special cases for work package editing * Fix edit actions bar * Fix codeclimate issues * Use WorkPackageNotificationService if necessary * Override NotificationService for WPs to allow WP specififc notifications (WiP) * Correctly provide wpNotification service Because the ui-router doesn't seem to correctly use the parent element's injector, we need to provide the wpNotification service not in the wp-base, but rather the wp-list component as well as in the isolated query space. * Allow to filter halEvents for specific resourceTypes (e.g. WorkPackage) * Remove superfluous cell class constant * Start renaming selectors for wp-edit-field into generics * Remove wp-table--cell-span in favor of display field selector * Consolidate other display and edit field styles * Provide specialized service for transitions in active edit forms * Remove superfluous overflowSelector * Accept that date field contains some work package specifics * Ignore unreadable files * Provide the changeset for work packages as a hook Since hal resource editing service is provided per query space, we cannot register them once (would only work globally) * Fix dangerfile * Remove another todo in halResourceNotification service * Fix npm TestBed for changed dependencies * Show inplace edit field in project details widget * Fix highlighting in single view * Provide HalResourceEditingService outside of project context * Used typedState for single-view * Also provide wpNotification service in split view * Correct check for resource type in eventsService * Fix getSchemaName in display field renderer * Fix passing ids into `halEditing.stopEditing` * Do not globally inject the halResourceEditingService There's a bug(?) in ui-router that gives you the global service before the parent injected service for a ui-view * Fix wpCreate service on copying and parallel creation * Remove test project widget * Revert changes for project details widget
5 years ago
expect(page).to have_no_selector('.inline-edit--container.subject input')
# Timeline actions only shown when open
wp_timeline.expect_timeline!(open: false)
goto_context_menu list_view
menu.expect_no_options 'Add predecessor', 'Add follower'
end
end
context 'for multiple selected WPs' do
let!(:work_package2) { FactoryBot.create(:work_package) }
it 'provides a context menu with a subset of the available menu items' do
# Go to table
wp_table.visit!
wp_table.expect_work_package_listed(work_package)
wp_table.expect_work_package_listed(work_package2)
display_representation.switch_to_card_layout unless list_view
loading_indicator_saveguard
# Select all WPs
find('body').send_keys [:control, 'a']
menu.open_for(work_package)
menu.expect_options ['Open details view', 'Open fullscreen view',
'Bulk edit', 'Bulk copy', 'Bulk change of project', 'Bulk delete']
end
end
end
before do
login_as(user)
work_package
end
context 'in the table' do
it_behaves_like 'provides a context menu' do
let(:list_view) { true }
end
it 'provides a context menu with timeline options' do
goto_context_menu true
# Open timeline
wp_timeline.toggle_timeline
wp_timeline.expect_timeline!(open: true)
# Open context menu
menu.expect_closed
menu.open_for(work_package)
menu.expect_options ['Add predecessor', 'Add follower']
end
describe 'creating work packages' do
let!(:priority) { FactoryBot.create :issue_priority, is_default: true }
let!(:status) { FactoryBot.create :default_status }
let!(:type) { FactoryBot.create :type_task }
let!(:project) { FactoryBot.create :project, types: [type] }
let!(:work_package) { FactoryBot.create :work_package, project: project, type: type, status: status, priority: priority }
let(:wp_table) { Pages::WorkPackagesTable.new project }
it 'can create a new child from the context menu (Regression #33329)' do
goto_context_menu true
menu.choose('Create new child')
expect(page).to have_selector('.inline-edit--container.subject input')
expect(current_url).to match(/.*\/create_new\?.*(&)*parent_id=#{work_package.id}/)
split_view = ::Pages::SplitWorkPackageCreate.new project: work_package.project
subject = split_view.edit_field(:subject)
subject.set_value 'Child task'
subject.submit_by_enter
split_view.expect_and_dismiss_notification message: 'Successful creation.'
expect(page).to have_selector('[data-qa-selector="op-wp-breadcrumb"]', text: "Parent:\n#{work_package.subject}")
wp = WorkPackage.last
expect(wp.parent).to eq work_package
end
end
end
context 'in the card view' do
it_behaves_like 'provides a context menu' do
let(:list_view) { false }
end
end
end