addapt spec support classes to altered html classes

pull/4338/head
Jens Ulferts 9 years ago
parent 6ed17f1eaf
commit 4c085b6c29
  1. 27
      spec/support/pages/abstract_work_package.rb
  2. 6
      spec/support/pages/work_packages_table.rb
  3. 2
      spec/support/work_packages/inline_edit_field.rb
  4. 55
      spec/support/work_packages/work_package_field.rb

@ -59,24 +59,12 @@ module Pages
attribute_expectations.each do |label_name, value|
label = label_name.to_s
if label == 'Subject'
expect(page).to have_selector('.attribute-subject', text: value)
elsif label == 'Description'
expect(page).to have_selector('.attribute-description', text: value)
else
expect(page).to have_selector('.attributes-key-value--key', text: label)
dl_element = page.find('.attributes-key-value--key', text: label).parent
unless value.nil?
expect(dl_element).to have_selector('.attributes-key-value--value-container', text: value)
end
end
expect(page).to have_selector(".wp-edit-field.#{label.downcase}", text: value)
end
end
def expect_attribute_hidden(label)
expect(page).not_to have_selector('.attributes-key-value--key', text: label)
expect(page).not_to have_selector(".wp-edit-field.#{label.downcase}")
end
def expect_activity(user, number: nil)
@ -106,16 +94,7 @@ module Pages
field = WorkPackageField.new(page, key)
field.activate_edition
input = field.input_element
case input.tag_name
when 'select'
input.select value
when 'input', 'textarea'
input.set value
else
raise 'Attribute is not supported as of now.'
end
field.set_value value
# Workaround for fields with datepickers, which
# may cover other fields we want to click next

@ -94,14 +94,12 @@ module Pages
else
row(work_package)
end
super(attribute, context)
WorkPackageField.new(context, attribute)
end
private
def row_selector(work_package)
end
def path
project ? project_work_packages_path(project) : work_packages_path
end

@ -11,7 +11,7 @@ class InlineEditField
@selector =
if work_package.nil?
".wp--row.-new .#{attribute}"
".wp--row.-new .wp-table--cell.#{attribute}"
else
"#work-package-#{work_package.id} .#{attribute}"
end

@ -2,7 +2,8 @@ class WorkPackageField
include Capybara::DSL
include RSpec::Matchers
attr_reader :element
attr_reader :element,
:property_name
def initialize(context, property_name, selector: nil)
@property_name = property_name
@ -27,6 +28,44 @@ class WorkPackageField
expect(@element).to have_selector(trigger_link_selector, text: text)
end
def expect_text(text)
expect(element).to have_content(text)
end
##
# Activate the field and check it opened correctly
def activate!
element.find(trigger_link_selector).click
expect_active!
end
def expect_active!
expect(element).to have_selector(field_type, wait: 10)
end
def expect_inactive!
expect(element).to have_no_selector(field_type, wait: 10)
end
def expect_error
expect(page).to have_selector("#{field_selector}.-error")
end
def save!
input_element.native.send_keys(:return)
end
##
# Set or select the given value.
# For fields of type select, will check for an option with that value.
def set_value(content)
if field_type == 'select'
input_element.find(:option, content).select_option
else
input_element.set(content)
end
end
def trigger_link
@element.find trigger_link_selector
end
@ -94,7 +133,8 @@ class WorkPackageField
extend ::Angular::DSL unless singleton_class.included_modules.include?(::Angular::DSL)
ng_wait
expect(page).to have_selector('.work-packages--details--title')
expect(page).to have_selector('#work-packages-list-view-button.-active,
.work-packages--details--title')
end
end
@ -103,4 +143,15 @@ class WorkPackageField
def input_selector
'.wp-inline-edit--field'
end
def field_type
@field_type ||= begin
case property_name
when :assignee, :priority, :status
:select
else
:input
end.to_s
end
end
end

Loading…
Cancel
Save