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/pages/work_packages_table.rb

274 lines
7.6 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 'support/pages/page'
module Pages
class WorkPackagesTable < Page
attr_reader :project
def initialize(project = nil)
@project = project
end
9 years ago
def visit_query(query)
visit "#{path}?query_id=#{query.id}"
end
def visit_with_params(params)
visit "#{path}?#{params}"
end
def expect_work_package_listed(*work_packages)
within(table_container) do
work_packages.each do |wp|
expect(page).to have_selector(".wp-row-#{wp.id} td.subject",
text: wp.subject,
wait: 20)
end
end
end
def expect_work_package_subject(subject)
within(table_container) do
expect(page).to have_selector("td.subject",
text: subject,
wait: 20)
end
end
def expect_work_package_count(n)
within(table_container) do
expect(page).to have_selector(".wp--row", count: n, wait: 20)
end
end
def expect_work_package_not_listed(*work_packages, wait: 3)
within(table_container) do
work_packages.each do |wp|
expect(page).to have_no_selector(".wp-row-#{wp.id} td.subject",
text: wp.subject,
wait: wait)
end
end
end
def expect_work_package_order(*ids)
rows = page.all '.wp-table--row'
ids = ids.map { |el| el.is_a?(WorkPackage) ? el.id.to_s : el.to_s }
expect(rows.map { |el| el['data-work-package-id'] }).to match_array(ids)
end
def expect_no_work_package_listed
within(table_container) do
expect(page).to have_selector('#empty-row-notification')
end
end
[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
def expect_title(name, editable: true)
if editable
expect(page).to have_field('wp-query-selectable-title', with: name, wait: 10)
else
expect(page)
.to have_selector('.toolbar-container', text: name, wait: 10)
end
end
def expect_query_in_select_dropdown(name)
page.find('.title-container').click
page.within('#querySelectDropdown') do
expect(page).to have_selector('.ui-menu-item', text: name)
end
end
def click_inline_create
##
# When using the inline create on initial page load,
# there is a delay on travis where inline create can be clicked.
sleep 3
container.find('.wp-inline-create--add-link').click
expect(container).to have_selector('.wp-inline-create-row', wait: 10)
end
def create_wp_split_screen(type)
click_wp_create_button
find('#types-context-menu .menu-item', text: type, wait: 10).click
SplitWorkPackageCreate.new(project: project)
end
def click_wp_create_button
find('.add-work-package:not([disabled])', text: 'Create').click
end
def expect_type_available_for_create(type)
click_wp_create_button
expect(page)
.to have_selector('#types-context-menu .menu-item', text: type.name)
end
def expect_type_not_available_for_create(type)
click_wp_create_button
expect(page)
.to have_no_selector('#types-context-menu .menu-item', text: type.name)
end
def open_split_view(work_package)
split_page = SplitWorkPackage.new(work_package, project)
# Hover row to show split screen button
row_element = row(work_package)
row_element.hover
scroll_to_and_click(row_element.find('.wp-table--details-link'))
split_page
end
def click_on_row(work_package)
loading_indicator_saveguard
page.driver.browser.action.click(row(work_package).native).perform
end
def add_filter(label, operator, value)
open_filter_section
select(label, from: 'Add filter:')
filter_name = get_filter_name(label)
select(operator, from: "operators-#{filter_name}") if operator
select(value, from: "values-#{filter_name}") if value
end
def expect_filter(label, operator, value)
open_filter_section
filter_name = get_filter_name(label)
expect(page).to have_select("operators-#{filter_name}", selected: operator) if operator
expect(page).to have_select("values-#{filter_name}", selected: value) if value
end
def open_full_screen_by_doubleclick(work_package)
loading_indicator_saveguard
# The 'id' column should have enough space to be clicked
click_target = row(work_package).find('.wp-table--cell-span.id')
8 years ago
page.driver.browser.action.double_click(click_target.native).perform
FullWorkPackage.new(work_package, project)
end
def open_full_screen_by_link(work_package)
row(work_package).click_link(work_package.id)
FullWorkPackage.new(work_package)
end
def row(work_package)
table_container.find(row_selector(work_package))
end
def row_selector(work_package)
".wp-row-#{work_package.id}-table"
end
def edit_field(work_package, attribute)
context =
if work_package.nil?
table_container.find('.wp-inline-create-row')
else
row(work_package)
end
::WorkPackageField.new(context, attribute)
end
def click_setting_item(label)
::Components::WorkPackages::SettingsMenu
.new.open_and_choose(label)
end
def save_as(name)
click_setting_item 'Save as'
fill_in 'save-query-name', with: name
click_button 'Save'
expect_notification message: 'Successful creation.'
expect_title name
end
def save
click_setting_item /Save$/
end
def open_filter_section
unless page.has_selector?('#work-packages-filter-toggle-button.-active')
click_button('work-packages-filter-toggle-button')
end
end
def table_container
find('#content .work-packages-split-view--tabletimeline-side')
end
def work_package_row_selector(work_package)
".wp-row-#{work_package.id}"
end
protected
def container
page
end
private
def path
project ? project_work_packages_path(project) : work_packages_path
end
def get_filter_name(label)
retry_block do
label_field = page.find('.advanced-filters--filter-name', text: label)
filter_container = label_field.find(:xpath, '..')
raise 'Missing ID on Filter (Angular not ready?)' if filter_container['id'].nil?
filter_container['id'].gsub('filter_', '')
end
end
end
end