Fixes #2229 - Wrong dates on synced calendars.
This commit is contained in:
parent
a883bbadb3
commit
8d16bcbfdd
5 changed files with 100 additions and 1 deletions
|
@ -15,7 +15,7 @@
|
||||||
<%- @Icon('checkbox', 'icon-unchecked') %>
|
<%- @Icon('checkbox', 'icon-unchecked') %>
|
||||||
<%- @Icon('checkbox-checked', 'icon-checked') %>
|
<%- @Icon('checkbox-checked', 'icon-checked') %>
|
||||||
</label>
|
</label>
|
||||||
<td><%- @Tdate(day) %>
|
<td><%= day %>
|
||||||
<td class="settings-list-control-cell"><input class="form-control form-control--small js-summary <% if !meta.active: %>is-disabled<% end %>" type="text" name="public_holidays::<%= day %>::summary" value="<%= meta.summary %>" required/>
|
<td class="settings-list-control-cell"><input class="form-control form-control--small js-summary <% if !meta.active: %>is-disabled<% end %>" type="text" name="public_holidays::<%= day %>::summary" value="<%= meta.summary %>" required/>
|
||||||
<td class="settings-list-row-control">
|
<td class="settings-list-row-control">
|
||||||
<% if !meta.feed: %>
|
<% if !meta.feed: %>
|
||||||
|
|
|
@ -80,6 +80,27 @@ module BrowserTestHelper
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This method is a derivation of Selenium::WebDriver::Wait#until
|
||||||
|
# which ignores Capybara::ElementNotFound exceptions raised
|
||||||
|
# in the given block.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# wait(5).until_disappear { find('[data-title="example"]') }
|
||||||
|
#
|
||||||
|
def until_disappears
|
||||||
|
self.until do
|
||||||
|
|
||||||
|
yield
|
||||||
|
false
|
||||||
|
rescue Capybara::ElementNotFound
|
||||||
|
true
|
||||||
|
end
|
||||||
|
rescue Selenium::WebDriver::Error::TimeOutError => e
|
||||||
|
# cleanup backtrace
|
||||||
|
e.set_backtrace(e.backtrace.drop(3))
|
||||||
|
raise e
|
||||||
|
end
|
||||||
|
|
||||||
# This method loops a given block until the result of it is constant.
|
# This method loops a given block until the result of it is constant.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
|
|
|
@ -183,6 +183,33 @@ module CommonActions
|
||||||
click '.js-openDropdownMacro'
|
click '.js-openDropdownMacro'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Checks if modal is ready
|
||||||
|
#
|
||||||
|
# @param timeout [Integer] seconds to wait
|
||||||
|
def modal_ready(timeout: 4)
|
||||||
|
wait(timeout).until_exists { find('.modal.in') }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Checks if modal has disappeared
|
||||||
|
#
|
||||||
|
# @param timeout [Integer] seconds to wait
|
||||||
|
def modal_disappear(timeout: 4)
|
||||||
|
wait(timeout).until_disappears { find('.modal.in') }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Scrolls to given element
|
||||||
|
#
|
||||||
|
# @option options [String] :css selector
|
||||||
|
# @option options [String] :vertical may be "start", "center", "end", or "nearest". Defaults to "start".
|
||||||
|
def scroll_to(params)
|
||||||
|
vertical = params.fetch :vertical, 'start'
|
||||||
|
|
||||||
|
script = "$('#{params[:css]}').get(0).scrollIntoView({block: '#{vertical}'})"
|
||||||
|
|
||||||
|
execute_script script
|
||||||
|
|
||||||
|
wait(1).until_constant { evaluate_script "$('#{params[:css]}').get(0).scrollTop" }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
|
|
10
spec/support/time_zone.rb
Normal file
10
spec/support/time_zone.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.around(:each, :time_zone) do |example|
|
||||||
|
old_tz = ENV['TZ']
|
||||||
|
ENV['TZ'] = example.metadata[:time_zone]
|
||||||
|
|
||||||
|
example.run
|
||||||
|
ensure
|
||||||
|
ENV['TZ'] = old_tz
|
||||||
|
end
|
||||||
|
end
|
41
spec/system/admin/calendars/date_spec.rb
Normal file
41
spec/system/admin/calendars/date_spec.rb
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Admin Panel > Calendars date', type: :system, authenticated: true, time_zone: 'America/Sao_Paulo' do
|
||||||
|
# https://github.com/zammad/zammad/issues/2229
|
||||||
|
it 'Show festivities dates correctly far away from UTC' do
|
||||||
|
visit '/#manage/calendars'
|
||||||
|
|
||||||
|
click '.js-new'
|
||||||
|
|
||||||
|
modal_ready
|
||||||
|
|
||||||
|
within '.modal-dialog' do
|
||||||
|
fill_in 'name', with: 'test calendar'
|
||||||
|
|
||||||
|
click '.dropdown-toggle'
|
||||||
|
click '.dropdown-menu [data-value="America/Sao_Paulo"]'
|
||||||
|
|
||||||
|
find('.ical_feed select').select 'Brazil'
|
||||||
|
|
||||||
|
click '.js-submit'
|
||||||
|
end
|
||||||
|
|
||||||
|
modal_disappear
|
||||||
|
|
||||||
|
container = find('.action') { |elem| elem.find('.action-row h2').text == 'test calendar' }
|
||||||
|
|
||||||
|
container.find('.js-edit').click
|
||||||
|
|
||||||
|
modal_ready
|
||||||
|
|
||||||
|
within '.modal-dialog' do
|
||||||
|
scroll_to(css: '.modal-dialog', vertical: 'end')
|
||||||
|
|
||||||
|
rows = find_all('.holiday_selector tr') { |elem| elem.has_css?('input.js-summary') && elem.find('input.js-summary').value.starts_with?('Christmas Eve') }
|
||||||
|
row = rows[0]
|
||||||
|
|
||||||
|
expect(row).to have_text('24')
|
||||||
|
expect(row).to have_text('12')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue