Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add rdoc for Pages::WorkPackagesTable

Christophe Bliardff9a69876cc9
diff --git a/spec/support/pages/work_packages/work_packages_table.rb b/spec/support/pages/work_packages/work_packages_table.rb
index 7106f4b40cb..43fee4ddd71 100644
--- a/spec/support/pages/work_packages/work_packages_table.rb
+++ b/spec/support/pages/work_packages/work_packages_table.rb
@@ -35,19 +35,33 @@ module Pages
attr_reader :project
+ # Initializes a new instance of the WorkPackagesTable class to drive the
+ # work package table page.
+ #
+ # @param project [Project] (optional) The project object used to construct
+ # the URL. If unspecified or `nil` the global work packages page is used.
def initialize(project = nil)
@project = project
super()
end
+ # Visits the work packages table with the specified query.
+ #
+ # @param query [Query] The query object.
def visit_query(query)
visit "#{path}?query_id=#{query.id}"
end
+ # Visits the work packages table with the specified parameters.
+ #
+ # @param params [String] The query parameters.
def visit_with_params(params)
visit "#{path}?#{params}"
end
+ # Expects the specified work packages to be listed in the table.
+ #
+ # @param work_packages [Array<WorkPackage>] The work package objects.
def expect_work_package_listed(*work_packages)
within(table_container) do
work_packages.each do |wp|
@@ -58,6 +72,11 @@ module Pages
end
end
+ # Expects the specified work package to have the specified attributes in the
+ # table.
+ #
+ # @param work_package [WorkPackage] The work package object.
+ # @param attr_value_hash [Hash] The attribute-value hash.
def expect_work_package_with_attributes(work_package, attr_value_hash)
within(table_container) do
attr_value_hash.each do |column, value|
@@ -68,6 +87,9 @@ module Pages
end
end
+ # Expects the sums row in the table to have the specified attributes.
+ #
+ # @param attr_value_hash [Hash] The attribute-value hash.
def expect_sums_row_with_attributes(attr_value_hash)
within(table_container) do
attr_value_hash.each do |column, value|
@@ -78,6 +100,9 @@ module Pages
end
end
+ # Expects a work package with the specified subject to be listed in the table.
+ #
+ # @param subject [String] The subject of the work package.
def expect_work_package_subject(subject)
within(table_container) do
expect(page).to have_css("td.subject",
@@ -86,12 +111,19 @@ module Pages
end
end
+ # Expects the specified number of work packages to be listed in the table.
+ #
+ # @param count [Integer] The expected number of work packages.
def expect_work_package_count(count)
within(table_container) do
expect(page).to have_css(".wp--row", count:, wait: 20)
end
end
+ # Updates the attributes of the specified work package.
+ #
+ # @param work_package [Object] The work package object.
+ # @param key_value_map [Hash] The attribute-value map.
def update_work_package_attributes(work_package, **key_value_map)
key_value_map.each do |key, value|
field = EditField.new(work_package_container(work_package), key)
@@ -99,10 +131,13 @@ module Pages
end
end
- ##
- # Wraps expecting the page not to have the given work packages
+ # Ensures that the specified work packages are not listed in the table.
+ #
+ # It wraps expecting the page not to have the given work packages
# within a retry_block to ensure we do not fail when the page is
- # still reloading (causing stale references or not found errors)
+ # still reloading (causing stale references or not found errors).
+ #
+ # @param work_packages [Array<Object>] The work package objects.
def ensure_work_package_not_listed!(*work_packages)
retry_block(args: { tries: 3, base_interval: 5 }) do
within(table_container) do
@@ -113,6 +148,10 @@ module Pages
end
end
+ # Expects the work packages to be listed in the specified order.
+ #
+ # @param ids [Array<WorkPackage, String, Integer>] The work package IDs or
+ # objects.
def expect_work_package_order(*ids)
retry_block do
rows = page.all '.work-package-table .wp--row'
@@ -123,12 +162,18 @@ module Pages
end
end
+ # Expects no work packages to be listed in the table.
def expect_no_work_package_listed
within(table_container) do
expect(page).to have_css('#empty-row-notification')
end
end
+ # Expects the title of the table to be the specified name.
+ #
+ # @param name [String] The expected title.
+ # @param editable [Boolean] (optional) Whether the title is expected to be
+ # editable.
def expect_title(name, editable: true)
if editable
expect(page).to have_field('editable-toolbar-title', with: name, wait: 10)
@@ -138,6 +183,9 @@ module Pages
end
end
+ # Expects the specified query to be present in the select dropdown.
+ #
+ # @param name [String] The name of the query.
def expect_query_in_select_dropdown(name)
page.find('.title-container').click
@@ -146,6 +194,7 @@ module Pages
end
end
+ # Clicks the inline create button.
def click_inline_create
##
# When using the inline create on initial page load,
@@ -156,6 +205,10 @@ module Pages
expect(container).to have_css('.wp-inline-create-row', wait: 10)
end
+ # Opens the split view for the specified work package.
+ #
+ # @param work_package [WorkPackage] The work package object.
+ # @return [Pages::SplitWorkPackage] The split work package page object.
def open_split_view(work_package)
split_page = SplitWorkPackage.new(work_package, project)
@@ -168,11 +221,19 @@ module Pages
split_page
end
+ # Clicks on the row of the specified work package.
+ #
+ # @param work_package [WorkPackage] The work package object.
def click_on_row(work_package)
loading_indicator_saveguard
page.driver.browser.action.click(row(work_package).native).perform
end
+ # Opens the full screen view of the specified work package by
+ # double-clicking.
+ #
+ # @param work_package [WorkPackage] The work package object.
+ # @return [Pages::FullWorkPackage] The full work package page object.
def open_full_screen_by_doubleclick(work_package)
loading_indicator_saveguard
# The 'id' column should have enough space to be clicked
@@ -182,25 +243,47 @@ module Pages
FullWorkPackage.new(work_package, project)
end
+ # Opens the full screen view of the specified work package by clicking on
+ # the link.
+ #
+ # @param work_package [WorkPackage] The work package object.
+ # @return [Pages::FullWorkPackage] The full work package page oobject.
def open_full_screen_by_link(work_package)
row(work_package).click_link(work_package.id.to_s)
FullWorkPackage.new(work_package)
end
+ # Drags and drops a work package from one position to another.
+ #
+ # @param from [WorkPackage] The source work package object.
+ # @param to [WorkPackage] The target work package object.
def drag_and_drop_work_package(from:, to:)
drag_and_drop_list(from:, to:, elements: '.wp-table--row', handler: '.wp-table--drag-and-drop-handle')
end
+ # Returns the row element for the specified work package.
+ #
+ # @param work_package [WorkPackage] The work package object.
+ # @return [Capybara::Node::Element] The row element.
def row(work_package)
table_container.find(row_selector(work_package))
end
+ # Returns the CSS selector for the row of the specified work package.
+ #
+ # @param elem [WorkPackage, String, Integer] The work package object or ID.
+ # @return [String] The CSS selector.
def row_selector(elem)
id = elem.is_a?(WorkPackage) ? elem.id.to_s : elem.to_s
".wp-row-#{id}-table"
end
+ # Returns the edit field for the specified work package attribute.
+ #
+ # @param work_package [WorkPackage] The work package object.
+ # @param attribute [Symbol] The attribute name.
+ # @return [EditField, DateEditField] The edit field.
def edit_field(work_package, attribute)
context =
if work_package.nil?
@@ -212,11 +295,19 @@ module Pages
work_package_field(work_package, context, attribute)
end
+ # Clicks on the specified setting item in the page context menu.
+ #
+ # @param label [String] The label of the setting item.
def click_setting_item(label)
::Components::WorkPackages::SettingsMenu
.new.open_and_choose(label)
end
+ # Saves the work package as a new query with the specified name.
+ #
+ # @param name [String] The name of the new query.
+ # @param by_title [Boolean] (optional) Whether to save through the title.
+ # If `false` it will save through the context menu..
def save_as(name, by_title: false)
if by_title
title_input = find('.editable-toolbar-title--input')
@@ -232,6 +323,7 @@ module Pages
expect_title name
end
+ # Saves the work package query.
def save
click_setting_item /Save$/
end