##// END OF EJS Templates
Replace Date.today with User.current.today (#22320)....
Replace Date.today with User.current.today (#22320). Depending on the offset between a user's configured timezone and the server timezone, Date.today may be more or less often wrong from the user's perspective, leading to things like issues marked as overdue too early or too late, or yesterday / tomorrow being displayed / selected where 'today' is intended. A test case illustrating the problem with Issue#overdue? is included Patch by Jens Kraemer. git-svn-id: http://svn.redmine.org/redmine/trunk@15379 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r14856:cda9c63d9c21
r14997:ed50d42210ea
Show More
issues_test_ui.rb
293 lines | 10.7 KiB | text/x-ruby | RubyLexer
/ test / ui / issues_test_ui.rb
Jean-Philippe Lang
Adds first Capybara tests (#12822)....
r11040 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
Adds first Capybara tests (#12822)....
r11040 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../base', __FILE__)
class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base
Jean-Philippe Lang
Missing fixtures....
r13904 fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
Jean-Philippe Lang
Adds first Capybara tests (#12822)....
r11040 :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
Jean-Philippe Lang
Adds context menu tests and skip test_preview_issue_description that breaks the test suite....
r11111 :enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
Jean-Philippe Lang
Missing fixtures....
r14586 :watchers, :journals, :journal_details
Jean-Philippe Lang
Adds first Capybara tests (#12822)....
r11040
Jean-Philippe Lang
Submit the form after preview....
r11118 def test_create_issue
Jean-Philippe Lang
Adds first Capybara tests (#12822)....
r11040 log_user('jsmith', 'jsmith')
Jean-Philippe Lang
Submit the form after preview....
r11118 visit '/projects/ecookbook/issues/new'
Jean-Philippe Lang
Adds first Capybara tests (#12822)....
r11040 within('form#issue-form') do
select 'Bug', :from => 'Tracker'
select 'Low', :from => 'Priority'
fill_in 'Subject', :with => 'new test issue'
fill_in 'Description', :with => 'new issue'
select '0 %', :from => 'Done'
fill_in 'Due date', :with => ''
fill_in 'Searchable field', :with => 'Value for field 2'
# click_button 'Create' would match both 'Create' and 'Create and continue' buttons
find('input[name=commit]').click
end
# find created issue
issue = Issue.find_by_subject("new test issue")
assert_kind_of Issue, issue
# check redirection
find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created."
assert_equal issue_path(:id => issue), current_path
# check issue attributes
assert_equal 'jsmith', issue.author.login
assert_equal 1, issue.project.id
assert_equal IssueStatus.find_by_name('New'), issue.status
assert_equal Tracker.find_by_name('Bug'), issue.tracker
assert_equal IssuePriority.find_by_name('Low'), issue.priority
assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field'))
end
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175 def test_create_issue_with_form_update
Jean-Philippe Lang
Make sure that fields filled before tracker change are preserved....
r11180 field1 = IssueCustomField.create!(
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175 :field_format => 'string',
Jean-Philippe Lang
Make sure that fields filled before tracker change are preserved....
r11180 :name => 'Field1',
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175 :is_for_all => true,
Jean-Philippe Lang
Fixed errors in UI tests (#18782)....
r13478 :trackers => Tracker.where(:id => [1, 2])
Jean-Philippe Lang
Make sure that fields filled before tracker change are preserved....
r11180 )
field2 = IssueCustomField.create!(
:field_format => 'string',
:name => 'Field2',
:is_for_all => true,
Jean-Philippe Lang
Fixed errors in UI tests (#18782)....
r13478 :trackers => Tracker.where(:id => 2)
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175 )
Role.non_member.add_permission! :add_issues
Role.non_member.remove_permission! :edit_issues, :add_issue_notes
log_user('someone', 'foo')
visit '/projects/ecookbook/issues/new'
Jean-Philippe Lang
Make sure that fields filled before tracker change are preserved....
r11180 assert page.has_no_content?(field2.name)
assert page.has_content?(field1.name)
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175
Jean-Philippe Lang
Make sure that fields filled before tracker change are preserved....
r11180 fill_in 'Subject', :with => 'New test issue'
fill_in 'Description', :with => 'New test issue description'
fill_in field1.name, :with => 'CF1 value'
select 'Low', :from => 'Priority'
# field2 should show up when changing tracker
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175 select 'Feature request', :from => 'Tracker'
Jean-Philippe Lang
Make sure that fields filled before tracker change are preserved....
r11180 assert page.has_content?(field2.name)
assert page.has_content?(field1.name)
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175
Jean-Philippe Lang
Make sure that fields filled before tracker change are preserved....
r11180 fill_in field2.name, :with => 'CF2 value'
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175 assert_difference 'Issue.count' do
Jean-Philippe Lang
Make sure that fields filled before tracker change are preserved....
r11180 page.first(:button, 'Create').click
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175 end
issue = Issue.order('id desc').first
Jean-Philippe Lang
Make sure that fields filled before tracker change are preserved....
r11180 assert_equal 'New test issue', issue.subject
assert_equal 'New test issue description', issue.description
assert_equal 'Low', issue.priority.name
assert_equal 'CF1 value', issue.custom_field_value(field1)
assert_equal 'CF2 value', issue.custom_field_value(field2)
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175 end
Jean-Philippe Lang
Adds a test for creating an issue with watchers....
r11110 def test_create_issue_with_watchers
Toshi MARUYAMA
prevent UI test failure randomly...
r11743 user = User.generate!(:firstname => 'Some', :lastname => 'Watcher')
assert_equal 'Some Watcher', user.name
Jean-Philippe Lang
Submit the form after preview....
r11118 log_user('jsmith', 'jsmith')
visit '/projects/ecookbook/issues/new'
fill_in 'Subject', :with => 'Issue with watchers'
# Add a project member as watcher
check 'Dave Lopper'
# Search for another user
Toshi MARUYAMA
add more asserting to test_create_issue_with_watchers of ui issues_test...
r11574 assert page.has_no_css?('form#new-watcher-form')
assert page.has_no_content?('Some Watcher')
Jean-Philippe Lang
Submit the form after preview....
r11118 click_link 'Search for watchers to add'
within('form#new-watcher-form') do
fill_in 'user_search', :with => 'watch'
Jean-Philippe Lang
Watcher search now displays project members by default....
r12676 assert page.has_content?('Some Watcher')
Jean-Philippe Lang
Submit the form after preview....
r11118 check 'Some Watcher'
click_button 'Add'
end
Toshi MARUYAMA
prevent failure of test_create_issue_with_watchers at UI IssuesTest...
r11592 assert page.has_css?('form#issue-form')
Toshi MARUYAMA
prevent UI test failure randomly...
r11740 assert page.has_css?('p#watchers_form')
Toshi MARUYAMA
prevent UI test failure randomly...
r11748 using_wait_time(30) do
within('span#watchers_inputs') do
within("label#issue_watcher_user_ids_#{user.id}") do
assert has_content?('Some Watcher'), "No watcher content"
end
Toshi MARUYAMA
prevent UI test failure randomly...
r11743 end
Toshi MARUYAMA
prevent failure of test_create_issue_with_watchers at UI IssuesTest...
r11594 end
Jean-Philippe Lang
Adds a test for creating an issue with watchers....
r11110 assert_difference 'Issue.count' do
find('input[name=commit]').click
end
issue = Issue.order('id desc').first
assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort
end
Toshi MARUYAMA
add test of current issue start and due date datepicker (#14024)...
r11649 def test_create_issue_start_due_date
with_settings :default_issue_start_date_to_creation_date => 0 do
log_user('jsmith', 'jsmith')
visit '/projects/ecookbook/issues/new'
assert_equal "", page.find('input#issue_start_date').value
assert_equal "", page.find('input#issue_due_date').value
page.first('p#start_date_area img').click
page.first("td.ui-datepicker-days-cell-over a").click
assert_equal Date.today.to_s, page.find('input#issue_start_date').value
page.first('p#due_date_area img').click
page.first("td.ui-datepicker-days-cell-over a").click
assert_equal Date.today.to_s, page.find('input#issue_due_date').value
end
end
Jean-Philippe Lang
Don't set default due date in the past (#21488)....
r14587 def test_default_due_date_proposed_in_date_picker
Toshi MARUYAMA
set default issue start/due datepicker from due/start date (#14024)...
r11653 log_user('jsmith', 'jsmith')
visit '/projects/ecookbook/issues/new'
Jean-Philippe Lang
Don't set default due date in the past (#21488)....
r14587
# Future start date: due date should default to start date
fill_in 'Start date', :with => '2027-04-01'
fill_in 'Due date', :with => ''
page.first('p#due_date_area img').click
page.first("td.ui-datepicker-days-cell-over a").click
assert_equal '2027-04-01', page.find('input#issue_due_date').value
# Passed start date: due date should default to today
Toshi MARUYAMA
set default issue start/due datepicker from due/start date (#14024)...
r11653 fill_in 'Start date', :with => '2012-04-01'
fill_in 'Due date', :with => ''
page.first('p#due_date_area img').click
page.first("td.ui-datepicker-days-cell-over a").click
Jean-Philippe Lang
Don't set default due date in the past (#21488)....
r14587 assert_equal Date.today.to_s, page.find('input#issue_due_date').value
end
def test_default_start_date_proposed_in_date_picker
log_user('jsmith', 'jsmith')
visit '/projects/ecookbook/issues/new'
Toshi MARUYAMA
set default issue start/due datepicker from due/start date (#14024)...
r11653
Jean-Philippe Lang
Don't set default due date in the past (#21488)....
r14587 # Passed due date: start date should default to due date
Toshi MARUYAMA
set default issue start/due datepicker from due/start date (#14024)...
r11653 fill_in 'Start date', :with => ''
fill_in 'Due date', :with => '2012-04-01'
page.first('p#start_date_area img').click
page.first("td.ui-datepicker-days-cell-over a").click
assert_equal '2012-04-01', page.find('input#issue_start_date').value
end
Jean-Philippe Lang
Adds first Capybara tests (#12822)....
r11040 def test_preview_issue_description
log_user('jsmith', 'jsmith')
Jean-Philippe Lang
Submit the form after preview....
r11118 visit '/projects/ecookbook/issues/new'
Jean-Philippe Lang
Adds first Capybara tests (#12822)....
r11040 within('form#issue-form') do
Jean-Philippe Lang
Submit the form after preview....
r11118 fill_in 'Subject', :with => 'new issue subject'
Jean-Philippe Lang
Adds first Capybara tests (#12822)....
r11040 fill_in 'Description', :with => 'new issue description'
click_link 'Preview'
end
find 'div#preview fieldset', :visible => true, :text => 'new issue description'
Jean-Philippe Lang
Submit the form after preview....
r11118 assert_difference 'Issue.count' do
find('input[name=commit]').click
end
issue = Issue.order('id desc').first
assert_equal 'new issue description', issue.description
Jean-Philippe Lang
Adds first Capybara tests (#12822)....
r11040 end
Jean-Philippe Lang
Adds context menu tests and skip test_preview_issue_description that breaks the test suite....
r11111
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175 def test_update_issue_with_form_update
field = IssueCustomField.create!(
:field_format => 'string',
:name => 'Form update CF',
:is_for_all => true,
Jean-Philippe Lang
Fixed errors in UI tests (#18782)....
r13478 :trackers => Tracker.where(:name => 'Feature request')
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175 )
Role.non_member.add_permission! :edit_issues
Role.non_member.remove_permission! :add_issues, :add_issue_notes
log_user('someone', 'foo')
visit '/issues/1'
assert page.has_no_content?('Form update CF')
Jean-Philippe Lang
Fixed UI tests....
r12057 page.first(:link, 'Edit').click
Jean-Philippe Lang
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
r11175 # the custom field should show up when changing tracker
select 'Feature request', :from => 'Tracker'
assert page.has_content?('Form update CF')
fill_in 'Form update', :with => 'CF value'
assert_no_difference 'Issue.count' do
page.first(:button, 'Submit').click
end
issue = Issue.find(1)
assert_equal 'CF value', issue.custom_field_value(field)
end
Jean-Philippe Lang
Fixed that delete watcher link was broken by r11290 (#13231)....
r11213 def test_remove_issue_watcher_from_sidebar
user = User.find(3)
Watcher.create!(:watchable => Issue.find(1), :user => user)
log_user('jsmith', 'jsmith')
visit '/issues/1'
Jean-Philippe Lang
Asserts that the watchers list is updated....
r11215 assert page.first('#sidebar').has_content?('Watchers (1)')
Jean-Philippe Lang
Fixed that delete watcher link was broken by r11290 (#13231)....
r11213 assert page.first('#sidebar').has_content?(user.name)
assert_difference 'Watcher.count', -1 do
page.first('ul.watchers .user-3 a.delete').click
Toshi MARUYAMA
fix failure of test_remove_issue_watcher_from_sidebar at UI IssuesTest...
r11577 assert page.first('#sidebar').has_content?('Watchers (0)')
Jean-Philippe Lang
Fixed that delete watcher link was broken by r11290 (#13231)....
r11213 end
assert page.first('#sidebar').has_no_content?(user.name)
end
Jean-Philippe Lang
Refresh watchers list when watching/unwatching an issue (#4334)....
r13856 def test_watch_should_update_watchers_list
user = User.find(2)
log_user('jsmith', 'jsmith')
visit '/issues/1'
assert page.first('#sidebar').has_content?('Watchers (0)')
page.first('a.issue-1-watcher').click
assert page.first('#sidebar').has_content?('Watchers (1)')
assert page.first('#sidebar').has_content?(user.name)
end
Jean-Philippe Lang
Adds context menu tests and skip test_preview_issue_description that breaks the test suite....
r11111 def test_watch_issue_via_context_menu
Jean-Philippe Lang
Removed delay....
r11117 log_user('jsmith', 'jsmith')
visit '/issues'
Toshi MARUYAMA
prevent assert_difference failure of test_watch_issue_via_context_menu at UI IssuesTest...
r11578 assert page.has_css?('tr#issue-1')
Jean-Philippe Lang
Removed delay....
r11117 find('tr#issue-1 td.updated_on').click
page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
Jean-Philippe Lang
Adds context menu tests and skip test_preview_issue_description that breaks the test suite....
r11111 assert_difference 'Watcher.count' do
within('#context-menu') do
click_link 'Watch'
end
Jean-Philippe Lang
Time dependend failures in UI tests (#18789)....
r13479 # wait for ajax response
assert page.has_css?('#context-menu .issue-1-watcher.icon-fav')
Toshi MARUYAMA
prevent assert_difference failure of test_watch_issue_via_context_menu at UI IssuesTest...
r11578 assert page.has_css?('tr#issue-1')
Jean-Philippe Lang
Adds context menu tests and skip test_preview_issue_description that breaks the test suite....
r11111 end
assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
end
def test_bulk_watch_issues_via_context_menu
Jean-Philippe Lang
Removed delay....
r11117 log_user('jsmith', 'jsmith')
visit '/issues'
Toshi MARUYAMA
prevent assert_difference failure of test_bulk_watch_issues_via_context_menu at UI IssuesTest...
r11579 assert page.has_css?('tr#issue-1')
assert page.has_css?('tr#issue-4')
Jean-Philippe Lang
Removed delay....
r11117 find('tr#issue-1 input[type=checkbox]').click
find('tr#issue-4 input[type=checkbox]').click
page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
Jean-Philippe Lang
Adds context menu tests and skip test_preview_issue_description that breaks the test suite....
r11111 assert_difference 'Watcher.count', 2 do
within('#context-menu') do
click_link 'Watch'
end
Jean-Philippe Lang
Time dependend failures in UI tests (#18789)....
r13479 # wait for ajax response
assert page.has_css?('#context-menu .issue-bulk-watcher.icon-fav')
Toshi MARUYAMA
prevent assert_difference failure of test_bulk_watch_issues_via_context_menu at UI IssuesTest...
r11579 assert page.has_css?('tr#issue-1')
assert page.has_css?('tr#issue-4')
Jean-Philippe Lang
Adds context menu tests and skip test_preview_issue_description that breaks the test suite....
r11111 end
assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
assert Issue.find(4).watched_by?(User.find_by_login('jsmith'))
end
Jean-Philippe Lang
Adds first Capybara tests (#12822)....
r11040 end