Maintenance: Applied workaround to Ticket Macro QUnit test to avoid failure leading up to DST switch.

This commit is contained in:
Mantas 2020-10-22 15:52:26 +03:00 committed by Thorsten Eckel
parent 0c15baee7f
commit 2ffa821d65
2 changed files with 16 additions and 5 deletions

View file

@ -11,4 +11,12 @@ body {
<script type="text/javascript"> <script type="text/javascript">
</script> </script>
<%- date = Time.current.in_time_zone('Europe/London') %>
<data
data-offset-5-days=<%= date.utc_offset - (date + 5.days).utc_offset %>
data-offset-3-minutes=<%= date.utc_offset - (date + 3.minutes).utc_offset %>
data-offset-10-hours=<%= date.utc_offset - (date + 10.hours).utc_offset %>
>
<div id="qunit" class="u-dontfold"></div> <div id="qunit" class="u-dontfold"></div>

View file

@ -1,5 +1,5 @@
test( "ticket macro pending time check", function() { test( "ticket macro pending time check", function() {
var test_relative = function(rules, target, description){ var test_relative = function(rules, target, description, offset){
var ticket = new App.Ticket() var ticket = new App.Ticket()
App.Ticket.macro({ App.Ticket.macro({
@ -12,18 +12,21 @@ test( "ticket macro pending time check", function() {
var compare_against = new Date() var compare_against = new Date()
var travel = Math.abs( new Date(ticket.pending_time) - compare_against) var travel = Math.abs( new Date(ticket.pending_time) - compare_against)
var diff = Math.abs(target - travel) var diff = Math.abs(target - travel) - offset*1000
ok(diff < 1000, description) ok(diff < 1000, description)
} }
var data = document.getElementsByTagName('data')[0].dataset
debugger
var rules = { var rules = {
operator: "relative", operator: "relative",
range: "day", range: "day",
value: 5 value: 5
} }
test_relative(rules, 60 * 60 * 24 * 5 * 1000, '5 days') test_relative(rules, 60 * 60 * 24 * 5 * 1000, '5 days', data['offset-5Days'])
var rules = { var rules = {
operator: "relative", operator: "relative",
@ -31,7 +34,7 @@ test( "ticket macro pending time check", function() {
value: 3 value: 3
} }
test_relative(rules, 60 * 3 * 1000, '5 minutes') test_relative(rules, 60 * 3 * 1000, '5 minutes', data['offset-3Minutes'])
var rules = { var rules = {
operator: "relative", operator: "relative",
@ -39,5 +42,5 @@ test( "ticket macro pending time check", function() {
value: 10 value: 10
} }
test_relative(rules, 60 * 60 * 10 * 1000, '10 hours') test_relative(rules, 60 * 60 * 10 * 1000, '10 hours', data['offset-10Hours'])
}) })