Add work package fields to WP pages for context

Since we may have several `.wp-edit-field` locations now (e.g., subject
in table and split view), we need context in the work package field.

This adds a helper method to table, split, and full page to create work
package fields.
pull/4338/head
Oliver Günther 9 years ago
parent 7848fedd7b
commit a034615025
  1. 4
      spec/support/pages/abstract_work_package.rb
  2. 4
      spec/support/pages/full_work_package.rb
  3. 4
      spec/support/pages/split_work_package.rb
  4. 11
      spec/support/pages/work_packages_table.rb
  5. 38
      spec/support/work_packages/work_package_field.rb

@ -41,6 +41,10 @@ module Pages
visit path(tab)
end
def edit_field(attribute, context)
WorkPackageField.new(context, attribute)
end
def expect_subject
within(container) do
expect(page).to have_content(work_package.subject)

@ -31,6 +31,10 @@ require 'support/pages/abstract_work_package'
module Pages
class FullWorkPackage < Pages::AbstractWorkPackage
def edit_field(attribute)
super(attribute, container)
end
private
def container

@ -37,6 +37,10 @@ module Pages
@project = project
end
def edit_field(attribute)
super(attribute, container)
end
private
def container

@ -88,11 +88,20 @@ module Pages
end
def edit_field(work_package, attribute)
InlineEditField.new(work_package, attribute)
context =
if work_package.nil?
table_container.find('.wp--row.-new')
else
row(work_package)
end
super(attribute, context)
end
private
def row_selector(work_package)
end
def path
project ? project_work_packages_path(project) : work_packages_path
end

@ -4,14 +4,15 @@ class WorkPackageField
attr_reader :element
def initialize(page, property_name, selector = nil)
def initialize(context, property_name, selector: nil)
@property_name = property_name
@context = context
if selector.nil?
if property_name == :'start-date' || property_name == :'end-date'
@selector = '.work-package-field.work-packages--details--date'
@selector = '.wp-edit-field.date'
else
@selector = ".work-package-field.work-packages--details--#{@property_name}"
@selector = ".wp-edit-field.#{@property_name}"
end
else
@selector = selector
@ -19,11 +20,11 @@ class WorkPackageField
ensure_page_loaded
@element = page.find(field_selector)
@element = @context.find(@selector)
end
def expect_state_text(text)
expect(@element).to have_selector('.inplace-edit--read-value', text: text)
expect(@element).to have_selector(trigger_link_selector, text: text)
end
def trigger_link
@ -31,7 +32,7 @@ class WorkPackageField
end
def trigger_link_selector
'a.inplace-editing--trigger-link'
'.wp-table--cell-span'
end
def field_selector
@ -41,7 +42,7 @@ class WorkPackageField
def activate_edition
tag = element.find("#{trigger_link_selector}, #{input_selector}")
if tag.tag_name == 'a'
if tag.tag_name == 'span'
tag.click
end
# else do nothing as the element is already in edit mode
@ -52,7 +53,8 @@ class WorkPackageField
end
def submit_by_click
@element.find('.inplace-edit--control--save > a', wait: 5).click
ActiveSupport::Deprecation.warn('submit_by_click is no longer available')
submit_by_enter
end
def submit_by_enter
@ -60,10 +62,8 @@ class WorkPackageField
end
def cancel_by_click
cancel_link_selector = '.inplace-edit--control--cancel a'
if @element.has_selector?(cancel_link_selector)
@element.find(cancel_link_selector).click
end
ActiveSupport::Deprecation.warn('cancel_by_click is no longer available')
cancel_by_escape
end
def cancel_by_escape
@ -71,11 +71,14 @@ class WorkPackageField
end
def editable?
trigger_link.visible? rescue false
@element['class'].include? '-editable'
end
def editing?
@element.find('.inplace-edit--write').visible? rescue false
@element.find(input_selector)
true
rescue
false
end
def errors_text
@ -91,16 +94,13 @@ class WorkPackageField
extend ::Angular::DSL unless singleton_class.included_modules.include?(::Angular::DSL)
ng_wait
expect(page).to have_selector('.work-packages--details--subject')
expect(page).to have_selector('.work-packages--details--title')
end
end
private
def input_selector
selector = { :'start-date' => 'date-start',
:'end-date' => 'date-end' }[@property_name] || @property_name
"#inplace-edit--write-value--#{selector}"
'.wp-inline-edit--field'
end
end
Loading…
Cancel
Save