wiki-textarea

pull/4338/head
manuschiller 9 years ago
commit 6c93b32c95
  1. 9
      frontend/app/components/wp-edit/wp-edit-field/wp-edit-field.directive.html
  2. 6
      spec/features/work_packages/details/inplace_editor/shared_examples.rb
  3. 9
      spec/features/work_packages/details/inplace_editor/subject_editor_spec.rb
  4. 4
      spec/support/pages/abstract_work_package.rb
  5. 4
      spec/support/pages/full_work_package.rb
  6. 4
      spec/support/pages/split_work_package.rb
  7. 11
      spec/support/pages/work_packages_table.rb
  8. 38
      spec/support/work_packages/work_package_field.rb

@ -1,5 +1,14 @@
<div class="wp-edit-field"
ng-class="{ '-error': vm.errorenous, '-active': vm.active }">
<div class="wp-edit-field"
ng-class="[
vm.errorenous && '-error' || '',
vm.isEditable && '-editable' || '',
vm.active && '-active' || '',
vm.fieldName
]">
<form ng-if="vm.workPackage && vm.active"
name="vm.wpEditForm"
ng-submit="vm.submit()">

@ -42,7 +42,7 @@ shared_examples 'an auth aware field' do
}
it 'is not editable' do
expect { field.trigger_link }.to raise_error Capybara::ElementNotFound
expect(field).not_to be_editable
end
end
end
@ -107,10 +107,6 @@ shared_examples 'a cancellable field' do
field.cancel_by_escape
end
after do
field.cancel_by_click
end
it_behaves_like 'cancelling properly'
end
end

@ -9,16 +9,17 @@ describe 'subject inplace editor', js: true, selenium: true do
let(:project) { FactoryGirl.create :project_with_types, is_public: true }
let(:property_name) { :subject }
let(:property_title) { 'Subject' }
let!(:work_package) { FactoryGirl.create :work_package, project: project }
let(:work_package) { FactoryGirl.create :work_package, project: project }
let(:user) { FactoryGirl.create :admin }
let(:work_packages_page) { WorkPackagesPage.new(project) }
let(:field) { WorkPackageField.new page, property_name }
let(:work_packages_page) { Pages::SplitWorkPackage.new(work_package,project) }
let(:field) { work_packages_page.edit_field(property_name) }
let(:notification) { ::PageObjects::Notifications.new(page) }
before do
login_as(user)
work_packages_page.visit_index(work_package)
work_packages_page.visit!
work_packages_page.ensure_page_loaded
end
context 'in read state' do

@ -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