Merge pull request #4111 from ulferts/fix/rewrite_wp_edit_cuke_as_spec

rewrite wp edit cuke as spec
pull/4117/head
Oliver Günther 9 years ago
commit 6323228334
  1. 38
      features/work_packages/update.feature
  2. 4
      frontend/app/components/work-packages/work-package-comment/work-package-comment.directive.js
  3. 1
      frontend/app/templates/work_packages/activities/_user.html
  4. 2
      spec/features/work_packages/details/activity_comments_spec.rb
  5. 24
      spec/features/work_packages/details/inplace_editor/work_package_field.rb
  6. 93
      spec/features/work_packages/edit_work_package_spec.rb
  7. 39
      spec/support/pages/abstract_work_package.rb
  8. 2
      spec/support/pages/full_work_package.rb
  9. 4
      spec/support/pages/page.rb
  10. 2
      spec/support/pages/split_work_package.rb

@ -73,44 +73,6 @@ Feature: Updating work packages
| wp1 | Phase1 | status1 | version1 |
And I am already logged in as "manager"
@javascript
Scenario: Updating the work package and seeing the results on the show page
When I go to the edit page of the work package called "wp1"
And I click the edit work package button
And I click to see all work package attributes
And I fill in the following:
| Type | Phase2 |
# This is to be removed once the bug
# that clears the inserted/selected values
# after a type refresh is fixed.
And I wait for the AJAX requests to finish
And I fill in the following:
| Responsible | the manager |
| Assignee | the manager |
| Start date | 2013-03-04 |
| Due date | 2013-03-06 |
| Estimated time | 5.00 |
| Progress (%) | 30 |
| Priority | prio2 |
| Status | status2 |
| Subject | New subject |
| Description | Desc2 |
And I submit the form by the "Save" button
And I wait for the AJAX requests to finish
Then I should see "Successful update"
Then I should be on the page of the work package "New subject"
And the work package should be shown with the following values:
| Responsible | the manager |
| Assignee | the manager |
| Date | 03/04/2013 - 03/06/2013 |
| Estimated time | 5.00 |
| Progress (%) | 30 |
| Priority | prio2 |
| Status | status2 |
| Subject | New subject |
| Type | Phase2 |
| Description | Desc2 |
@javascript
Scenario: User adds a comment to a work package with previewing the stuff before
When I go to the page of the issue "wp1"

@ -34,7 +34,9 @@ function workPackageComment($timeout, $location, EditableFieldsState, FocusHelpe
inplaceEditMultiStorage, ConfigurationService, AutoCompleteHelper, inplaceEditAll) {
function commentFieldDirectiveController($scope, $element) {
var field = {},
var field = {
name: 'activity'
},
commentStore = inplaceEditMultiStorage.stores.comment;
$scope.field = field;

@ -45,6 +45,7 @@
<textarea wiki-toolbar
msd-elastic="\n"
class="edit-comment-text focus-input inplace-edit--textarea"
id="inplace-edit--write-value--activity-comment"
ng-hide="inPreview"
ng-model="activity.editedComment"
preview-toggle="toggleCommentPreview()"

@ -23,7 +23,7 @@ describe 'activity comments', js: true, selenium: true do
context 'with permission' do
let(:user) { FactoryGirl.create :admin }
let(:field) { WorkPackageField.new page, 'activity-comment', selector }
let(:field) { WorkPackageField.new page, 'activity', selector }
before do
work_packages_page.visit_index(work_package)

@ -8,7 +8,11 @@ class WorkPackageField
@property_name = property_name
if selector.nil?
@selector = ".work-package-field.work-packages--details--#{@property_name}"
if property_name == :'start-date' || property_name == :'end-date'
@selector = '.work-package-field.work-packages--details--date'
else
@selector = ".work-package-field.work-packages--details--#{@property_name}"
end
else
@selector = selector
end
@ -35,11 +39,16 @@ class WorkPackageField
end
def activate_edition
trigger_link.click
tag = element.find("#{trigger_link_selector}, #{input_selector}")
if tag.tag_name == 'a'
tag.click
end
# else do nothing as the element is already in edit mode
end
def input_element
@element.find('.focus-input')
@element.find input_selector
end
def submit_by_click
@ -85,4 +94,13 @@ class WorkPackageField
expect(page).to have_selector('.work-packages--details--subject')
end
end
private
def input_selector
selector = { :'start-date' => 'date-start',
:'end-date' => 'date-end' }[@property_name] || @property_name
"#inplace-edit--write-value--#{selector}"
end
end

@ -1,30 +1,93 @@
require 'spec_helper'
require 'features/work_packages/details/inplace_editor/work_package_field'
require 'features/page_objects/notification'
describe 'edit work package', js: true do
let(:user) { FactoryGirl.create :admin }
let(:project) { FactoryGirl.create(:project) }
let(:work_package) { FactoryGirl.create(:work_package, project: project) }
let(:dev_role) do
FactoryGirl.create :role,
permissions: [:view_work_packages,
:add_work_packages]
end
let(:dev) do
FactoryGirl.create :user,
firstname: 'Dev',
lastname: 'Guy',
member_in_project: project,
member_through_role: dev_role
end
let(:manager_role) do
FactoryGirl.create :role,
permissions: [:view_work_packages,
:edit_work_packages]
end
let(:manager) do
FactoryGirl.create :user,
firstname: 'Manager',
lastname: 'Guy',
member_in_project: project,
member_through_role: manager_role
end
let(:type) { FactoryGirl.create :type }
let(:type2) { FactoryGirl.create :type }
let(:project) { FactoryGirl.create(:project, types: [type, type2]) }
let(:work_package) { FactoryGirl.create(:work_package, author: dev, project: project, type: type) }
let(:new_subject) { 'Some other subject' }
let(:subject_field) { WorkPackageField.new(page, :subject) }
let(:wp_page) { Pages::FullWorkPackage.new(work_package) }
let(:priority2) { FactoryGirl.create :priority }
let(:status2) { FactoryGirl.create :status }
let(:workflow) do
FactoryGirl.create :workflow,
type_id: type2.id,
old_status: work_package.status,
new_status: status2,
role: manager_role
end
let(:version) { FactoryGirl.create :version, project: project }
let(:category) { FactoryGirl.create :category, project: project }
before do
login_as(user)
login_as(manager)
manager
dev
priority2
workflow
visit edit_work_package_path(work_package)
wp_page.visit!
end
it 'shows the work package in edit mode' do
subject = page.find("#inplace-edit--write-value--subject")
expect(subject.value).to eq(work_package.subject)
it 'allows updating and seeing the results' do
wp_page.ensure_page_loaded
wp_page.view_all_attributes
wp_page.update_attributes type: type2.name,
:'start-date' => '2013-03-04',
:'end-date' => '2013-03-20',
responsible: manager.name,
assignee: manager.name,
estimatedTime: '5.00',
percentageDone: '30',
subject: 'a new subject',
description: 'a new description',
priority: priority2.name,
status: status2.name,
version: version.name,
category: category.name
subject.set new_subject
find('#work-packages--edit-actions-save').click
wp_page.expect_notification message: I18n.t('js.notice_successful_update')
subject_field.expect_state_text(new_subject)
expect(work_package.reload.subject).to eq(new_subject)
wp_page.expect_attributes Type: type2.name,
Responsible: manager.name,
Assignee: manager.name,
Date: '03/04/2013 - 03/20/2013',
'Estimated time' => '5.00',
Progress: '30',
Subject: 'a new subject',
Description: 'a new description',
Priority: priority2.name,
Status: status2.name,
Version: version.name,
Category: category.name
end
end

@ -27,6 +27,7 @@
#++
require 'support/pages/page'
require 'features/work_packages/details/inplace_editor/work_package_field'
module Pages
class AbstractWorkPackage < Page
@ -87,6 +88,30 @@ module Pages
text: "##{parent.id} #{parent.subject}")
end
def update_attributes(key_value_map)
set_attributes(key_value_map).last.submit_by_click
end
def set_attributes(key_value_map)
key_value_map.map do |key, value|
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
end
end
def add_child
visit_tab!('relations')
@ -104,6 +129,20 @@ module Pages
page
end
def view_all_attributes
# click_link does not work for reasons(TM)
page.find('a', text: I18n.t('js.label_show_attributes')).click
end
def trigger_edit_mode
page.click_button(I18n.t('js.button_edit'))
end
def save!
page.click_button(I18n.t('js.button_save'))
end
private
def create_page(_args)

@ -26,7 +26,7 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'support/pages/page'
require 'support/pages/abstract_work_package'
module Pages
class FullWorkPackage < Pages::AbstractWorkPackage

@ -82,6 +82,10 @@ module Pages
expect(expected_path).to eql path
end
def expect_notification(type: :success, message:)
expect(page).to have_selector(".notification-box.-#{type}", text: message)
end
def path
nil
end

@ -26,7 +26,7 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'support/pages/page'
require 'support/pages/abstract_work_package'
module Pages
class SplitWorkPackage < Pages::AbstractWorkPackage

Loading…
Cancel
Save