From 354e054b7b85213a76793bf5c12ba6c851e68d58 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Mon, 26 May 2014 16:35:49 +0200 Subject: [PATCH 1/5] Clean out Test Unit assertions in web_steps.rb Signed-off-by: Alex Coles --- features/step_definitions/web_steps.rb | 92 +++++--------------------- 1 file changed, 17 insertions(+), 75 deletions(-) diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index f86a1722f3..d5cab35937 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -192,60 +192,36 @@ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field| end Then /^(?:|I )should see "([^"]*)"$/ do |text| - if page.respond_to? :should - page.should have_content(text) - else - assert page.has_content?(text) - end + page.should have_content(text) end Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp| regexp = Regexp.new(regexp) - if page.respond_to? :should - page.should have_xpath('//*', :text => regexp) - else - assert page.has_xpath?('//*', :text => regexp) - end + page.should have_xpath('//*', :text => regexp) end Then /^(?:|I )should not see "([^"]*)"$/ do |text| - if page.respond_to? :should - page.should have_no_content(text) - else - assert page.has_no_content?(text) - end + page.should have_no_content(text) end Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp| regexp = Regexp.new(regexp) - if page.respond_to? :should - page.should have_no_xpath('//*', :text => regexp) - else - assert page.has_no_xpath?('//*', :text => regexp) - end + page.should have_no_xpath('//*', :text => regexp) end Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value| with_scope(parent) do field = find_field(field) - if field.value.respond_to? :should - field.value.should =~ /#{value}/ - else - assert_match(/#{value}/, field.value) - end + field.value.should =~ /#{value}/ end end Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value| with_scope(parent) do field = find_field(field) - if field.value.respond_to? :should_not - field.value.should_not =~ /#{value}/ - else - assert_no_match(/#{value}/, field.value) - end + field.value.should_not =~ /#{value}/ end end @@ -257,66 +233,36 @@ Then /^the "([^"]*)" field should have the error "([^"]*)"$/ do |field, error_me using_formtastic = form_for_input[:class].include?('formtastic') error_class = using_formtastic ? 'error' : 'field_with_errors' - if classes.respond_to? :should - classes.should include(error_class) - else - assert classes.include?(error_class) - end + classes.should include(error_class) - if page.respond_to?(:should) - if using_formtastic - error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]') - error_paragraph.should have_content(error_message) - else - page.should have_content("#{field.titlecase} #{error_message}") - end + if using_formtastic + error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]') + error_paragraph.should have_content(error_message) else - if using_formtastic - error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]') - assert error_paragraph.has_content?(error_message) - else - assert page.has_content?("#{field.titlecase} #{error_message}") - end + page.should have_content("#{field.titlecase} #{error_message}") end end Then /^the "([^"]*)" field should have no error$/ do |field| element = find_field(field) classes = element.find(:xpath, '..')[:class].split(' ') - if classes.respond_to? :should - classes.should_not include('field_with_errors') - classes.should_not include('error') - else - assert !classes.include?('field_with_errors') - assert !classes.include?('error') - end + classes.should_not include('field_with_errors') + classes.should_not include('error') end Then /^the (hidden )?"([^"]*)" checkbox should be checked$/ do |hidden, label | field_checked = find_field(label, :visible => hidden.nil?)['checked'] - if field_checked.respond_to? :should - field_checked.should be_true - else - assert field_checked - end + field_checked.should be_true end Then /^the (hidden )?"([^"]*)" checkbox should not be checked$/ do |hidden, label | field_checked = find_field(label, :visible => hidden.nil?)['checked'] - if field_checked.respond_to? :should - field_checked.should be_false - else - assert !field_checked - end + field_checked.should be_false end Then /^(?:|I )should be on (.+)$/ do |page_name| current_path = URI.parse(current_url).path - if current_path.respond_to? :should - current_path.should == path_to(page_name) - else - assert_equal path_to(page_name), current_path - end + current_path.should == path_to(page_name) end Then /^(?:|I )should have the following query string:$/ do |expected_pairs| @@ -325,11 +271,7 @@ Then /^(?:|I )should have the following query string:$/ do |expected_pairs| expected_params = {} expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')} - if actual_params.respond_to? :should - actual_params.should == expected_params - else - assert_equal expected_params, actual_params - end + actual_params.should == expected_params end Then /^show me the page$/ do From e4b857050856c431e57634a1e1c43a6779b0d07a Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Mon, 26 May 2014 17:06:23 +0200 Subject: [PATCH 2/5] Make 'should see' step definition case-insensitive Many Cucumber features were broken as a result of the styling change introduced in fc473559. Cukes should test behaviour and semantics, _not styling_. `text-transform: uppercase` does not convey semantic meaning in the context of these particular headings. Selenium will match text as it is rendered and visible to the end-user. Thus, by default, we need to make the text matching in the "should (not) see" step definitions less strict. Signed-off-by: Alex Coles --- features/step_definitions/web_steps.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index d5cab35937..5827a00036 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -192,7 +192,8 @@ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field| end Then /^(?:|I )should see "([^"]*)"$/ do |text| - page.should have_content(text) + regexp = Regexp.new(Regexp.escape(text), Regexp::IGNORECASE) + page.should have_content(regexp) end Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp| @@ -202,7 +203,8 @@ Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp| end Then /^(?:|I )should not see "([^"]*)"$/ do |text| - page.should have_no_content(text) + regexp = Regexp.new(Regexp.escape(text), Regexp::IGNORECASE) + page.should have_no_content(regexp) end Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp| From 391540b77a8be1a112e04ddca84022427cb6880a Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Mon, 26 May 2014 17:23:23 +0200 Subject: [PATCH 3/5] Revert "Fix some cukes failing due to upper case conversions" e4b85705 provides an alternative solutin to make these features less brittle. This reverts commit 3373f77556bc4ff38ba4e9c2a1921428f5716ed7. --- features/projects/copy_project.feature | 2 +- features/step_definitions/common_steps.rb | 2 +- features/timelines/timeline_modal_views.feature | 4 ++-- .../work_packages/moves/work_package_moves_new_copy.feature | 3 +-- features/work_packages/work_package_show.feature | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/features/projects/copy_project.feature b/features/projects/copy_project.feature index 01c9c03c87..fbe4caf4c9 100644 --- a/features/projects/copy_project.feature +++ b/features/projects/copy_project.feature @@ -202,7 +202,7 @@ Feature: Project Settings Then I should see "foo" within "#content" And I follow "foo" within "#content" Then I should see "Alice Alison" within "#content" - And I should see "FOO" within "#content" + And I should see "foo" within "#content" And I should see "Bob Bobbit" within "#content" And I should see "version1" within "#content" And I should see "Description" within "#content" diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb index 461291dbe0..caf53eae25 100644 --- a/features/step_definitions/common_steps.rb +++ b/features/step_definitions/common_steps.rb @@ -77,4 +77,4 @@ end Then(/^"([^"]*)" should be the first row in table$/) do |name| should have_selector("table.list tbody tr td", :text => Regexp.new("#{name}")) -end +end \ No newline at end of file diff --git a/features/timelines/timeline_modal_views.feature b/features/timelines/timeline_modal_views.feature index 460499115a..883780f6cd 100644 --- a/features/timelines/timeline_modal_views.feature +++ b/features/timelines/timeline_modal_views.feature @@ -79,12 +79,12 @@ Feature: Timeline View Tests And I wait for timeline to load table And I click on the Planning Element with name "January" Then I should see a modal window - And I should see "#1: JANUARY" in the modal + And I should see "#1: January" in the modal And I should see "http://google.de" in the modal And I should see "01/01/2012" in the modal And I should see "01/31/2012" in the modal And I should see "New timeline report" And I should be on the page of the timeline "Testline" of the project called "ecookbook" When I ctrl-click on "#2" in the modal - Then I should see "FEBRUARY" in the new window + Then I should see "February" in the new window Then I should see "Avocado Rincon" in the new window diff --git a/features/work_packages/moves/work_package_moves_new_copy.feature b/features/work_packages/moves/work_package_moves_new_copy.feature index 00b62f4264..e04056f86e 100644 --- a/features/work_packages/moves/work_package_moves_new_copy.feature +++ b/features/work_packages/moves/work_package_moves_new_copy.feature @@ -114,7 +114,6 @@ Feature: Copying a work package And I should see "project_2" within ".breadcrumb" - @javascript Scenario: Move an issue to project with missing type When I go to the move page of the work package "issue3" And I select "project_1" from "Project" @@ -130,7 +129,7 @@ Feature: Copying a work package | issue1 | | issue2 | And I follow "Copy" within "#work-package-context-menu" - Then I should see "COPY" within "#content" + Then I should see "Copy" within "#content" And I should not see "Move" within "#content" # FIXME: Please check this: is this the same issue as reported in #1868 diff --git a/features/work_packages/work_package_show.feature b/features/work_packages/work_package_show.feature index 59c01e74a4..196bd2ac3f 100644 --- a/features/work_packages/work_package_show.feature +++ b/features/work_packages/work_package_show.feature @@ -154,7 +154,7 @@ Feature: Viewing a work package When I go to the page of the work package "issue1" When I select "Copy" from the action menu - Then I should see "COPY" + Then I should see "Copy" @javascript Scenario: For an issue move leads to work package copy page From 8439d737c5542f8e4f401c3ee89e1adeea0c9a36 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Mon, 26 May 2014 17:28:50 +0200 Subject: [PATCH 4/5] Partially revert "Fixed various core cukes relating to work packages table." e4b85705 provides an alternative solution to make these features less brittle. This reverts commit 8e9e05b28144a3f8ea06e47ab92d6eb33d62897b. --- features/work_packages/index_move_columns.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/work_packages/index_move_columns.feature b/features/work_packages/index_move_columns.feature index 0ed9b340b1..369f8de1eb 100644 --- a/features/work_packages/index_move_columns.feature +++ b/features/work_packages/index_move_columns.feature @@ -70,7 +70,7 @@ Feature: Disabled done ratio on the work package index And I click the toolbar button named "Filter" And I click "Options" And I select to see column "Author" - Then I should see "AUTHOR" within ".workpackages-table" + Then I should see "Author" within ".workpackages-table" @javascript Scenario: Subject column should not be displayed when Subject is moved out of selected columns @@ -78,4 +78,4 @@ Feature: Disabled done ratio on the work package index And I click the toolbar button named "Filter" And I click "Options" And I select to not see column "Subject" - Then I should not see "SUBJECT" within ".workpackages-table" + Then I should not see "Subject" within ".workpackages-table" From 11e7a1b5fbc04537206e08313ed5b6627c9b8666 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Tue, 27 May 2014 08:56:16 +0200 Subject: [PATCH 5/5] hacky fix for cuke erronously spotting "admin" in logged in user section --- features/users/status.feature | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/features/users/status.feature b/features/users/status.feature index 13a02c3078..fc76ee989c 100644 --- a/features/users/status.feature +++ b/features/users/status.feature @@ -63,28 +63,31 @@ Feature: User Status @javascript Scenario: Users can be filtered by status + # had to append the 'within ".list tbody"' in order to avoid the "I should + # (not) see "admin"' step to find the "OpenProject Admin" string for the + # logged in user as well as the "Administrator" string in the table header. Given the user "bobby" had too many recently failed logins And I filter the users list by status "active (1)" - Then I should not see "bobby" - And I should see "admin" - And I should not see "Anonymous" + Then I should not see "bobby" within ".list tbody" + And I should see "admin" within ".list tbody" + And I should not see "Anonymous" within ".list tbody" And I filter the users list by status "locked temporarily (1)" - Then I should see "bobby" - And I should not see "admin" - And I should not see "Anonymous" + Then I should see "bobby" within ".list tbody" + And I should not see "admin" within ".list tbody" + And I should not see "Anonymous" within ".list tbody" When the user "bobby" is locked And I filter the users list by status "locked permanently (1)" - Then I should see "bobby" - And I should not see "admin" - And I should not see "Anonymous" + Then I should see "bobby" within ".list tbody" + And I should not see "admin" within ".list tbody" + And I should not see "Anonymous" within ".list tbody" And I filter the users list by status "locked temporarily (1)" - Then I should see "bobby" - And I should not see "admin" - And I should not see "Anonymous" + Then I should see "bobby" within ".list tbody" + And I should not see "admin" within ".list tbody" + And I should not see "Anonymous" within ".list tbody" And I filter the users list by status "all (2)" - Then I should see "bobby" - And I should see "admin" - And I should not see "Anonymous" + Then I should see "bobby" within ".list tbody" + And I should see "admin" within ".list tbody" + And I should not see "Anonymous" within ".list tbody" @javascript Scenario: User can be unlocked on the index page