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/support/components/work_packages/relations.rb

234 lines
7.9 KiB

#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 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 docs/COPYRIGHT.rdoc for more details.
#++
require 'features/support/components/ui_autocomplete'
module Components
module WorkPackages
class Relations
include Capybara::DSL
include RSpec::Matchers
include ::Components::UIAutocompleteHelpers
attr_reader :work_package
def initialize(work_package)
@work_package = work_package
end
def find_row(relatable)
page.find(".relation-row-#{relatable.id}")
end
def click_relation(relatable)
page.find(".relation-row-#{relatable.id} .wp-relations--subject-field").click
end
def edit_relation_type(relatable, to_type:)
row = find_row(relatable)
row.find('.relation-row--type').click
expect(row).to have_selector('select.wp-inline-edit--field')
row.find('.wp-inline-edit--field option', text: to_type).select_option
end
def hover_action(relatable, action)
retry_block do
# Focus type edit to expose buttons
span = page.find(".relation-row-#{relatable.id} .relation-row--type", wait: 20)
scroll_to_element(span)
page.driver.browser.action.move_to(span.native).perform
# Click the corresponding action button
row = find_row(relatable)
case action
when :delete
row.find('.relation-row--remove-btn').click
when :info
row.find('.wp-relations--description-btn').click
end
end
end
def remove_relation(relatable)
## Delete relation
hover_action(relatable, :delete)
# Expect relation to be gone
expect_no_relation(relatable)
end
def add_relation(type:, to:)
# Open create form
find('#relation--add-relation').click
# Select relation type
container = find('.wp-relations-create--form', wait: 10)
# Labels to expect
relation_label = I18n.t('js.relation_labels.' + type)
select relation_label, from: 'relation-type--select'
# Enter the query and select the child
autocomplete = container.find(".wp-relations--autocomplete")
[27828] Feature: Query menu in sidenav (#6429) * in main menu add gantt as extra work package child item * Satisfy spec and code climate * Add gantt chart icon behin default gantt query name. * WIP Query menu in left sidebar * Shift query dropdown in left sidenav * Reload menu or load query on click from every project location * WIP set correct label for default queries * Query menu listens on all changes of queries (delete, create, rename, toggle starred) and updates immediatly * WIP: Inline edit, field validation * Inline Edit validation and comfirm * Inline edit: validation of duplicate name * Set default columns and sorting for static queries * Codeclimate issues fixed * WIP Inline edit validation not working perfectly in all error states * Inline edit working * Autocompleter hover disabled and hovering over categories fixed * Category hover and toggle fixed; tested in Chrome, Firefox and Opera * Placeholder cut off fixed and text wrap added * English and german wording adjusted * Styles of inline edit and menu adjusted; matching wiki page styles * prevent menus to be displayed to often * application menu only displayed on work package * specify using no_menu layout more often * adapt tests to altered production implementation * Hamburger icon only in project; on global wp page: default queries shown correctly and summary removed * searching for undefined leads to error * Accessible click fixed (listen on escape) * Gantt in top menu deleted (gantt chart is part of default queries on wp page) * load menu on wp summary page * reduce times queries are loaded * lowercase on second word * remove menu from search and home * Styles fixed (category toggle and correct highlighting) * reflect static query in url * fix autocomplete handling in specs * Open all global menus on default and hide hamburger icon on global pages; Rebuild changes that have been ovrwritten after merge" * Correct highlighting of default queries after reload * Replace summary cuke with spec * WIP * Clear up selectors * Avoid actively setting promises and instead use $state.go to load links [ci skip] * Make editable title component a little simpler We can reuse the component I built for the wiki, that wasn't present in the frontend beforehand. * Fix moving through the menu and selecting items [ci skip] * Add save button to query title when query changed * Improve static names lookup by comparing query_props * Adapt and fix specs * Allow inner scrolling of wp query results Also, style the webkit scrollbar to make it pretty where supported * Allow renaming the query through setting menu, but simply focus on field [ci skip]
6 years ago
select_autocomplete autocomplete,
results_selector: '.wp-relations-autocomplete--results',
query: to.subject,
select_text: to.subject
container.find('.wp-create-relation--save').click
expect(page).to have_selector('.relation-group--header',
text: relation_label.upcase,
wait: 10)
expect(page).to have_selector('.relation-row--type', text: to.type.name)
expect(page).to have_selector('.wp-relations--subject-field', text: to.subject)
## Test if relation exist
work_package.reload
relation = work_package.relations.last
expect(relation.label_for(work_package).to_s).to eq("label_#{type}")
expect(relation.other_work_package(work_package).id).to eq(to.id)
end
Add relations tables to Types via form configuration (#6773) * WIP: PrecedesFilter and FollowsFilter for WorkPackages * Create Type Form Groups per Query Type * generalize filters on relations avoiding alias * fix flickering spec * Rename dependency represeners for Follower and Predecessor Filters * Allow configuring templated queries within query configuring modal * Use `{id}` as templated value, instead of a now deprecated `templated` string * Rewrite ParentFilter to follow same structure as other relation filters. * Set Follower and Predecessor filters as hidden in Frontend * Default query shall show closed WPs, too * Remove relation filter type selection from form configuration view as we extend query configuration modal instead. * Allow ExternalQueryConfiguration to be more specific and prepend relation filters in its modal. * Quick unrelated fix on the way: the instruction text should start below the columns input and not to the right of it * - Add all missing relation filters. - Use verbs for naming instead of nouns to stay consistent with UI. * fix typo * Add relation filters to hidden filters and fix a rebase bug * Typo in docs * Fix broken rebase conflict resolution * Add part of and includes filter * adding specs for relation filters * rename RelatesFilter to RelatesToFilter * Rename shared example as direction does not matter anymore. * Fix spec for IncludesFilter * Fix name conflict for `includes` by calling typed_dag's `direct` later. * Fix shared filter examples as the parent filter does not get added per default anymore. * Fix spec after renaming PredecessorFilter to PrecedesFilter * Fix integration spec for type configuration form * Add filter dependency specs * Differentiate between WorkPackageFormChildrenQueryGroup and WorkPackageRelationQueryGroup types * Create inline-create for relation tables * Rewrite filters to use actual relation_type as key * Reload relations on change, change symbols * Fix relation filter i18n strings * Test presence of all relation filters frontend. * Extend integration test for form configuration to not only cover hierarchy, but also undirectional and directional relation types. * Consistent naming of filter dependency representer files * Satisfy codeclimate * Add missing copyright notes * Fixing PartofFilter and its specs * Reverse relation direction when created inline * WIP integration test for Relation Query Component and Children Query Component. * Correctly reload children tables when refreshed * Fix FilterOnUndirectedMixin * Fix removing of relation from embedded table after reload * Adding intergration tests for removing and adding relation or children, initiated form either embedded table or relations tab. * Fix specs * Fix implementation of duplicates and duplicated They are reversed in typed_dag and causes confusion [ci skip]
6 years ago
def expect_relation(relatable)
expect(relations_group).to have_selector('.wp-relations--subject-field', text: relatable.subject)
end
def expect_relation_by_text(text)
expect(relations_group).to have_text('.wp-relations--subject-field', text)
end
def expect_no_relation(relatable)
expect(page).to have_no_selector('.wp-relations--subject-field', text: relatable.subject)
end
def add_parent(query, work_package)
# Open the parent edit
find('.wp-relation--parent-change').click
# Enter the query and select the child
autocomplete = find(".wp-relations--autocomplete")
[27828] Feature: Query menu in sidenav (#6429) * in main menu add gantt as extra work package child item * Satisfy spec and code climate * Add gantt chart icon behin default gantt query name. * WIP Query menu in left sidebar * Shift query dropdown in left sidenav * Reload menu or load query on click from every project location * WIP set correct label for default queries * Query menu listens on all changes of queries (delete, create, rename, toggle starred) and updates immediatly * WIP: Inline edit, field validation * Inline Edit validation and comfirm * Inline edit: validation of duplicate name * Set default columns and sorting for static queries * Codeclimate issues fixed * WIP Inline edit validation not working perfectly in all error states * Inline edit working * Autocompleter hover disabled and hovering over categories fixed * Category hover and toggle fixed; tested in Chrome, Firefox and Opera * Placeholder cut off fixed and text wrap added * English and german wording adjusted * Styles of inline edit and menu adjusted; matching wiki page styles * prevent menus to be displayed to often * application menu only displayed on work package * specify using no_menu layout more often * adapt tests to altered production implementation * Hamburger icon only in project; on global wp page: default queries shown correctly and summary removed * searching for undefined leads to error * Accessible click fixed (listen on escape) * Gantt in top menu deleted (gantt chart is part of default queries on wp page) * load menu on wp summary page * reduce times queries are loaded * lowercase on second word * remove menu from search and home * Styles fixed (category toggle and correct highlighting) * reflect static query in url * fix autocomplete handling in specs * Open all global menus on default and hide hamburger icon on global pages; Rebuild changes that have been ovrwritten after merge" * Correct highlighting of default queries after reload * Replace summary cuke with spec * WIP * Clear up selectors * Avoid actively setting promises and instead use $state.go to load links [ci skip] * Make editable title component a little simpler We can reuse the component I built for the wiki, that wasn't present in the frontend beforehand. * Fix moving through the menu and selecting items [ci skip] * Add save button to query title when query changed * Improve static names lookup by comparing query_props * Adapt and fix specs * Allow inner scrolling of wp query results Also, style the webkit scrollbar to make it pretty where supported * Allow renaming the query through setting menu, but simply focus on field [ci skip]
6 years ago
select_autocomplete autocomplete,
query: query,
results_selector: '.wp-relations-autocomplete--results',
select_text: work_package.id
end
def expect_parent(work_package)
expect(page).to have_selector '.wp-breadcrumb-parent',
text: work_package.subject,
wait: 10
end
def expect_no_parent
expect(page).to have_no_selector '.wp-breadcrumb-parent', wait: 10
end
def remove_parent
# Open the parent edit
find('.wp-relation--parent-change').click
# Submit empty autocomplete to remove
autocomplete = find(".wp-relations--autocomplete")
autocomplete.set ''
autocomplete.send_keys :enter
end
def inline_create_child(subject_text)
container = find('.wp-relations--children')
scroll_to_and_click(container.find('.wp-inline-create-button-row .wp-inline-create--add-link'))
subject = ::WorkPackageField.new(container, 'subject')
subject.expect_active!
subject.update subject_text
end
def openChildrenAutocompleter
retry_block do
find('.wp-inline-create--reference-link', text: I18n.t('js.relation_buttons.add_existing_child')).click
# Security check to be sure that the autocompleter has finished loading
page.find '.wp-relations-autocomplete--results'
end
end
def add_existing_child(work_package)
# Locate the create row container
Add relations tables to Types via form configuration (#6773) * WIP: PrecedesFilter and FollowsFilter for WorkPackages * Create Type Form Groups per Query Type * generalize filters on relations avoiding alias * fix flickering spec * Rename dependency represeners for Follower and Predecessor Filters * Allow configuring templated queries within query configuring modal * Use `{id}` as templated value, instead of a now deprecated `templated` string * Rewrite ParentFilter to follow same structure as other relation filters. * Set Follower and Predecessor filters as hidden in Frontend * Default query shall show closed WPs, too * Remove relation filter type selection from form configuration view as we extend query configuration modal instead. * Allow ExternalQueryConfiguration to be more specific and prepend relation filters in its modal. * Quick unrelated fix on the way: the instruction text should start below the columns input and not to the right of it * - Add all missing relation filters. - Use verbs for naming instead of nouns to stay consistent with UI. * fix typo * Add relation filters to hidden filters and fix a rebase bug * Typo in docs * Fix broken rebase conflict resolution * Add part of and includes filter * adding specs for relation filters * rename RelatesFilter to RelatesToFilter * Rename shared example as direction does not matter anymore. * Fix spec for IncludesFilter * Fix name conflict for `includes` by calling typed_dag's `direct` later. * Fix shared filter examples as the parent filter does not get added per default anymore. * Fix spec after renaming PredecessorFilter to PrecedesFilter * Fix integration spec for type configuration form * Add filter dependency specs * Differentiate between WorkPackageFormChildrenQueryGroup and WorkPackageRelationQueryGroup types * Create inline-create for relation tables * Rewrite filters to use actual relation_type as key * Reload relations on change, change symbols * Fix relation filter i18n strings * Test presence of all relation filters frontend. * Extend integration test for form configuration to not only cover hierarchy, but also undirectional and directional relation types. * Consistent naming of filter dependency representer files * Satisfy codeclimate * Add missing copyright notes * Fixing PartofFilter and its specs * Reverse relation direction when created inline * WIP integration test for Relation Query Component and Children Query Component. * Correctly reload children tables when refreshed * Fix FilterOnUndirectedMixin * Fix removing of relation from embedded table after reload * Adding intergration tests for removing and adding relation or children, initiated form either embedded table or relations tab. * Fix specs * Fix implementation of duplicates and duplicated They are reversed in typed_dag and causes confusion [ci skip]
6 years ago
container = find('.wp-relations--add-form')
# Enter the query and select the child
autocomplete = container.find(".wp-relations--autocomplete")
[27828] Feature: Query menu in sidenav (#6429) * in main menu add gantt as extra work package child item * Satisfy spec and code climate * Add gantt chart icon behin default gantt query name. * WIP Query menu in left sidebar * Shift query dropdown in left sidenav * Reload menu or load query on click from every project location * WIP set correct label for default queries * Query menu listens on all changes of queries (delete, create, rename, toggle starred) and updates immediatly * WIP: Inline edit, field validation * Inline Edit validation and comfirm * Inline edit: validation of duplicate name * Set default columns and sorting for static queries * Codeclimate issues fixed * WIP Inline edit validation not working perfectly in all error states * Inline edit working * Autocompleter hover disabled and hovering over categories fixed * Category hover and toggle fixed; tested in Chrome, Firefox and Opera * Placeholder cut off fixed and text wrap added * English and german wording adjusted * Styles of inline edit and menu adjusted; matching wiki page styles * prevent menus to be displayed to often * application menu only displayed on work package * specify using no_menu layout more often * adapt tests to altered production implementation * Hamburger icon only in project; on global wp page: default queries shown correctly and summary removed * searching for undefined leads to error * Accessible click fixed (listen on escape) * Gantt in top menu deleted (gantt chart is part of default queries on wp page) * load menu on wp summary page * reduce times queries are loaded * lowercase on second word * remove menu from search and home * Styles fixed (category toggle and correct highlighting) * reflect static query in url * fix autocomplete handling in specs * Open all global menus on default and hide hamburger icon on global pages; Rebuild changes that have been ovrwritten after merge" * Correct highlighting of default queries after reload * Replace summary cuke with spec * WIP * Clear up selectors * Avoid actively setting promises and instead use $state.go to load links [ci skip] * Make editable title component a little simpler We can reuse the component I built for the wiki, that wasn't present in the frontend beforehand. * Fix moving through the menu and selecting items [ci skip] * Add save button to query title when query changed * Improve static names lookup by comparing query_props * Adapt and fix specs * Allow inner scrolling of wp query results Also, style the webkit scrollbar to make it pretty where supported * Allow renaming the query through setting menu, but simply focus on field [ci skip]
6 years ago
select_autocomplete autocomplete,
query: work_package.id,
results_selector: '.wp-relations-autocomplete--results',
select_text: work_package.subject
container.find('.wp-create-relation--save').click
end
def expect_child(work_package)
container = find('wp-relations-hierarchy wp-children-query')
within container do
expect(page)
Add relations tables to Types via form configuration (#6773) * WIP: PrecedesFilter and FollowsFilter for WorkPackages * Create Type Form Groups per Query Type * generalize filters on relations avoiding alias * fix flickering spec * Rename dependency represeners for Follower and Predecessor Filters * Allow configuring templated queries within query configuring modal * Use `{id}` as templated value, instead of a now deprecated `templated` string * Rewrite ParentFilter to follow same structure as other relation filters. * Set Follower and Predecessor filters as hidden in Frontend * Default query shall show closed WPs, too * Remove relation filter type selection from form configuration view as we extend query configuration modal instead. * Allow ExternalQueryConfiguration to be more specific and prepend relation filters in its modal. * Quick unrelated fix on the way: the instruction text should start below the columns input and not to the right of it * - Add all missing relation filters. - Use verbs for naming instead of nouns to stay consistent with UI. * fix typo * Add relation filters to hidden filters and fix a rebase bug * Typo in docs * Fix broken rebase conflict resolution * Add part of and includes filter * adding specs for relation filters * rename RelatesFilter to RelatesToFilter * Rename shared example as direction does not matter anymore. * Fix spec for IncludesFilter * Fix name conflict for `includes` by calling typed_dag's `direct` later. * Fix shared filter examples as the parent filter does not get added per default anymore. * Fix spec after renaming PredecessorFilter to PrecedesFilter * Fix integration spec for type configuration form * Add filter dependency specs * Differentiate between WorkPackageFormChildrenQueryGroup and WorkPackageRelationQueryGroup types * Create inline-create for relation tables * Rewrite filters to use actual relation_type as key * Reload relations on change, change symbols * Fix relation filter i18n strings * Test presence of all relation filters frontend. * Extend integration test for form configuration to not only cover hierarchy, but also undirectional and directional relation types. * Consistent naming of filter dependency representer files * Satisfy codeclimate * Add missing copyright notes * Fixing PartofFilter and its specs * Reverse relation direction when created inline * WIP integration test for Relation Query Component and Children Query Component. * Correctly reload children tables when refreshed * Fix FilterOnUndirectedMixin * Fix removing of relation from embedded table after reload * Adding intergration tests for removing and adding relation or children, initiated form either embedded table or relations tab. * Fix specs * Fix implementation of duplicates and duplicated They are reversed in typed_dag and causes confusion [ci skip]
6 years ago
.to have_selector('.wp-table--cell-td.subject', text: work_package.subject, wait: 10)
end
end
def expect_not_child(work_package)
Add relations tables to Types via form configuration (#6773) * WIP: PrecedesFilter and FollowsFilter for WorkPackages * Create Type Form Groups per Query Type * generalize filters on relations avoiding alias * fix flickering spec * Rename dependency represeners for Follower and Predecessor Filters * Allow configuring templated queries within query configuring modal * Use `{id}` as templated value, instead of a now deprecated `templated` string * Rewrite ParentFilter to follow same structure as other relation filters. * Set Follower and Predecessor filters as hidden in Frontend * Default query shall show closed WPs, too * Remove relation filter type selection from form configuration view as we extend query configuration modal instead. * Allow ExternalQueryConfiguration to be more specific and prepend relation filters in its modal. * Quick unrelated fix on the way: the instruction text should start below the columns input and not to the right of it * - Add all missing relation filters. - Use verbs for naming instead of nouns to stay consistent with UI. * fix typo * Add relation filters to hidden filters and fix a rebase bug * Typo in docs * Fix broken rebase conflict resolution * Add part of and includes filter * adding specs for relation filters * rename RelatesFilter to RelatesToFilter * Rename shared example as direction does not matter anymore. * Fix spec for IncludesFilter * Fix name conflict for `includes` by calling typed_dag's `direct` later. * Fix shared filter examples as the parent filter does not get added per default anymore. * Fix spec after renaming PredecessorFilter to PrecedesFilter * Fix integration spec for type configuration form * Add filter dependency specs * Differentiate between WorkPackageFormChildrenQueryGroup and WorkPackageRelationQueryGroup types * Create inline-create for relation tables * Rewrite filters to use actual relation_type as key * Reload relations on change, change symbols * Fix relation filter i18n strings * Test presence of all relation filters frontend. * Extend integration test for form configuration to not only cover hierarchy, but also undirectional and directional relation types. * Consistent naming of filter dependency representer files * Satisfy codeclimate * Add missing copyright notes * Fixing PartofFilter and its specs * Reverse relation direction when created inline * WIP integration test for Relation Query Component and Children Query Component. * Correctly reload children tables when refreshed * Fix FilterOnUndirectedMixin * Fix removing of relation from embedded table after reload * Adding intergration tests for removing and adding relation or children, initiated form either embedded table or relations tab. * Fix specs * Fix implementation of duplicates and duplicated They are reversed in typed_dag and causes confusion [ci skip]
6 years ago
page.within('wp-relations-tab .work-packages-embedded-view--container') do
row = ".wp-row-#{work_package.id}-table"
expect(page).to have_no_selector(row)
end
end
def children_table
Add relations tables to Types via form configuration (#6773) * WIP: PrecedesFilter and FollowsFilter for WorkPackages * Create Type Form Groups per Query Type * generalize filters on relations avoiding alias * fix flickering spec * Rename dependency represeners for Follower and Predecessor Filters * Allow configuring templated queries within query configuring modal * Use `{id}` as templated value, instead of a now deprecated `templated` string * Rewrite ParentFilter to follow same structure as other relation filters. * Set Follower and Predecessor filters as hidden in Frontend * Default query shall show closed WPs, too * Remove relation filter type selection from form configuration view as we extend query configuration modal instead. * Allow ExternalQueryConfiguration to be more specific and prepend relation filters in its modal. * Quick unrelated fix on the way: the instruction text should start below the columns input and not to the right of it * - Add all missing relation filters. - Use verbs for naming instead of nouns to stay consistent with UI. * fix typo * Add relation filters to hidden filters and fix a rebase bug * Typo in docs * Fix broken rebase conflict resolution * Add part of and includes filter * adding specs for relation filters * rename RelatesFilter to RelatesToFilter * Rename shared example as direction does not matter anymore. * Fix spec for IncludesFilter * Fix name conflict for `includes` by calling typed_dag's `direct` later. * Fix shared filter examples as the parent filter does not get added per default anymore. * Fix spec after renaming PredecessorFilter to PrecedesFilter * Fix integration spec for type configuration form * Add filter dependency specs * Differentiate between WorkPackageFormChildrenQueryGroup and WorkPackageRelationQueryGroup types * Create inline-create for relation tables * Rewrite filters to use actual relation_type as key * Reload relations on change, change symbols * Fix relation filter i18n strings * Test presence of all relation filters frontend. * Extend integration test for form configuration to not only cover hierarchy, but also undirectional and directional relation types. * Consistent naming of filter dependency representer files * Satisfy codeclimate * Add missing copyright notes * Fixing PartofFilter and its specs * Reverse relation direction when created inline * WIP integration test for Relation Query Component and Children Query Component. * Correctly reload children tables when refreshed * Fix FilterOnUndirectedMixin * Fix removing of relation from embedded table after reload * Adding intergration tests for removing and adding relation or children, initiated form either embedded table or relations tab. * Fix specs * Fix implementation of duplicates and duplicated They are reversed in typed_dag and causes confusion [ci skip]
6 years ago
::Pages::EmbeddedWorkPackagesTable.new find('wp-relations-tab .work-packages-embedded-view--container')
end
def relations_group
find('wp-relations-tab wp-relations-group')
end
def remove_child(work_package)
page.within('.work-packages-embedded-view--container') do
row = ".wp-row-#{work_package.id}-table"
find(row).hover
find("#{row} .wp-table-action--unlink").click
end
end
end
end
end