Performance improvements.
This commit is contained in:
parent
a1dd76ffd6
commit
c85ff7b775
6 changed files with 333 additions and 327 deletions
|
@ -1137,18 +1137,16 @@ class App.ObserverController extends App.Controller
|
||||||
#console.trace()
|
#console.trace()
|
||||||
@log 'debug', 'new', @object_id, @model
|
@log 'debug', 'new', @object_id, @model
|
||||||
|
|
||||||
object = App[@model].fullLocal(@object_id)
|
if App[@model].exists(@object_id)
|
||||||
if !object
|
@maybeRender( App[@model].fullLocal(@object_id) )
|
||||||
App[@model].full(@object_id, @maybeRender)
|
|
||||||
else
|
else
|
||||||
@maybeRender(object)
|
App[@model].full(@object_id, @maybeRender)
|
||||||
|
|
||||||
# rerender, e. g. on language change
|
# rerender, e. g. on language change
|
||||||
if @globalRerender
|
if @globalRerender
|
||||||
@bind('ui:rerender', =>
|
@bind('ui:rerender', =>
|
||||||
@lastAttributres = undefined
|
@lastAttributres = undefined
|
||||||
object = App[@model].fullLocal(@object_id)
|
@maybeRender( App[@model].fullLocal(@object_id) )
|
||||||
@maybeRender(object)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
subscribe: (object, typeOfChange) =>
|
subscribe: (object, typeOfChange) =>
|
||||||
|
|
|
@ -41,7 +41,6 @@ class App.TicketZoomSidebar extends App.ObserverController
|
||||||
organization_id: true
|
organization_id: true
|
||||||
|
|
||||||
render: (ticket) =>
|
render: (ticket) =>
|
||||||
|
|
||||||
editTicket = (el) =>
|
editTicket = (el) =>
|
||||||
el.append('<form><fieldset class="edit"></fieldset></form><div class="tags"></div><div class="links"></div>')
|
el.append('<form><fieldset class="edit"></fieldset></form><div class="tags"></div><div class="links"></div>')
|
||||||
|
|
||||||
|
@ -91,7 +90,7 @@ class App.TicketZoomSidebar extends App.ObserverController
|
||||||
callback: editTicket
|
callback: editTicket
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
if !@permissionCheck('ticket.customer')
|
if @permissionCheck('ticket.agent')
|
||||||
@sidebarItems[0]['actions'] = [
|
@sidebarItems[0]['actions'] = [
|
||||||
{
|
{
|
||||||
name: 'ticket-history'
|
name: 'ticket-history'
|
||||||
|
@ -109,7 +108,7 @@ class App.TicketZoomSidebar extends App.ObserverController
|
||||||
callback: changeCustomer
|
callback: changeCustomer
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
if !@permissionCheck('ticket.customer')
|
if @permissionCheck('ticket.agent')
|
||||||
editCustomer = (e, el) =>
|
editCustomer = (e, el) =>
|
||||||
new App.ControllerGenericEdit(
|
new App.ControllerGenericEdit(
|
||||||
id: ticket.customer_id
|
id: ticket.customer_id
|
||||||
|
|
|
@ -490,7 +490,7 @@ class Model extends Module
|
||||||
|
|
||||||
trigger: ->
|
trigger: ->
|
||||||
Events.trigger.apply this, arguments # fire off the instance event
|
Events.trigger.apply this, arguments # fire off the instance event
|
||||||
return true if arguments[0] is 'refresh' # Don't trigger refresh events, because ... ?
|
#return true if arguments[0] is 'refresh' # Don't trigger refresh events, because ... ?
|
||||||
@constructor.trigger arguments... # fire off the class event
|
@constructor.trigger arguments... # fire off the class event
|
||||||
|
|
||||||
Model::on = Model::bind
|
Model::on = Model::bind
|
||||||
|
|
|
@ -414,8 +414,7 @@ class App.Model extends Spine.Model
|
||||||
App.Log.debug('Model', "local change #{@className}", items)
|
App.Log.debug('Model', "local change #{@className}", items)
|
||||||
for item in items
|
for item in items
|
||||||
for key, callback of App[ @className ].SUBSCRIPTION_ITEM[ item.id ]
|
for key, callback of App[ @className ].SUBSCRIPTION_ITEM[ item.id ]
|
||||||
item = App[ @className ]._fillUp(item)
|
callback(App[ @className ]._fillUp(item), 'change')
|
||||||
callback(item, 'change')
|
|
||||||
)
|
)
|
||||||
@bind(
|
@bind(
|
||||||
'destroy'
|
'destroy'
|
||||||
|
@ -427,8 +426,7 @@ class App.Model extends Spine.Model
|
||||||
App.Log.debug('Model', "local destroy #{@className}", items)
|
App.Log.debug('Model', "local destroy #{@className}", items)
|
||||||
for item in items
|
for item in items
|
||||||
for key, callback of App[ @className ].SUBSCRIPTION_ITEM[ item.id ]
|
for key, callback of App[ @className ].SUBSCRIPTION_ITEM[ item.id ]
|
||||||
item = App[ @className ]._fillUp(item)
|
callback(App[ @className ]._fillUp(item), 'destroy')
|
||||||
callback(item, 'destroy')
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@changeTable = {}
|
@changeTable = {}
|
||||||
|
@ -444,10 +442,9 @@ class App.Model extends Spine.Model
|
||||||
for key, callback of App[ @className ].SUBSCRIPTION_ITEM[ item.id ]
|
for key, callback of App[ @className ].SUBSCRIPTION_ITEM[ item.id ]
|
||||||
|
|
||||||
# only trigger callbacks if object has changed
|
# only trigger callbacks if object has changed
|
||||||
if !@changeTable[key] || @changeTable[key] isnt item.updated_at
|
if !@changeTable[key] || @changeTable[key] < item.updated_at
|
||||||
@changeTable[key] = item.updated_at
|
@changeTable[key] = item.updated_at
|
||||||
item = App[ @className ]._fillUp(item)
|
callback(App[@className]._fillUp(item), 'refresh')
|
||||||
callback(item, 'refresh')
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# subscribe and render data after server change
|
# subscribe and render data after server change
|
||||||
|
|
|
@ -6,14 +6,14 @@ App.Ajax.request({
|
||||||
url: '/assets/tests/ajax-test.json',
|
url: '/assets/tests/ajax-test.json',
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
test( "ajax get 200", function() {
|
test( "ajax get 200", function() {
|
||||||
ok( true, "File found!" );
|
ok( true, "File found!")
|
||||||
equal( data.success, true, "content parsable and ok!" );
|
equal(data.success, true, "content parsable and ok!")
|
||||||
equal( data.success2, undefined, "content parsable and ok!" );
|
equal(data.success2, undefined, "content parsable and ok!")
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function (data) {
|
error: function (data) {
|
||||||
test( "ajax", function() {
|
test( "ajax", function() {
|
||||||
ok( false, "Failed!" );
|
ok( false, "Failed!")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -27,15 +27,15 @@ App.Ajax.request({
|
||||||
test( "ajax - queue - ajax get 200 1/2", function() {
|
test( "ajax - queue - ajax get 200 1/2", function() {
|
||||||
|
|
||||||
// check queue
|
// check queue
|
||||||
ok( !window.testAjax, 'ajax - queue - check queue' );
|
ok( !window.testAjax, 'ajax - queue - check queue')
|
||||||
window.testAjax = true;
|
window.testAjax = true;
|
||||||
equal( data.success, true, "ajax - queue - content parsable and ok!" );
|
equal(data.success, true, "ajax - queue - content parsable and ok!")
|
||||||
equal( data.success2, undefined, "ajax - queue - content parsable and ok!" );
|
equal(data.success2, undefined, "ajax - queue - content parsable and ok!")
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function (data) {
|
error: function (data) {
|
||||||
test( "ajax", function() {
|
test( "ajax", function() {
|
||||||
ok( false, "Failed!" );
|
ok( false, "Failed!")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -46,16 +46,16 @@ App.Ajax.request({
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
test( "ajax - queue - ajax get 200 2/2", function() {
|
test( "ajax - queue - ajax get 200 2/2", function() {
|
||||||
// check queue
|
// check queue
|
||||||
ok( window.testAjax, 'ajax - queue - check queue' )
|
ok( window.testAjax, 'ajax - queue - check queue')
|
||||||
window.testAjax = undefined;
|
window.testAjax = undefined;
|
||||||
|
|
||||||
equal( data.success, true, "content parsable and ok!" );
|
equal(data.success, true, "content parsable and ok!")
|
||||||
equal( data.success2, undefined, "content parsable and ok!" );
|
equal(data.success2, undefined, "content parsable and ok!")
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function (data) {
|
error: function (data) {
|
||||||
test( "ajax", function() {
|
test( "ajax", function() {
|
||||||
ok( false, "Failed!" );
|
ok( false, "Failed!")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -68,15 +68,15 @@ App.Ajax.request({
|
||||||
test( "ajax - parallel - ajax get 200 1/2", function() {
|
test( "ajax - parallel - ajax get 200 1/2", function() {
|
||||||
|
|
||||||
// check queue
|
// check queue
|
||||||
ok( window.testAjaxQ, 'ajax - parallel - check queue' );
|
ok( window.testAjaxQ, 'ajax - parallel - check queue')
|
||||||
window.testAjaxQ = undefined;
|
window.testAjaxQ = undefined;
|
||||||
equal( data.success, true, "ajax - parallel - content parsable and ok!" );
|
equal(data.success, true, "ajax - parallel - content parsable and ok!")
|
||||||
equal( data.success2, undefined, "ajax - parallel - content parsable and ok!" );
|
equal(data.success2, undefined, "ajax - parallel - content parsable and ok!")
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function (data) {
|
error: function (data) {
|
||||||
test( "ajax", function() {
|
test( "ajax", function() {
|
||||||
ok( false, "Failed!" );
|
ok( false, "Failed!")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -86,27 +86,27 @@ App.Ajax.request({
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
test( "ajax - parallel - ajax get 200 2/2", function() {
|
test( "ajax - parallel - ajax get 200 2/2", function() {
|
||||||
// check queue
|
// check queue
|
||||||
ok( !window.testAjaxQ, 'ajax - parallel - check queue' )
|
ok( !window.testAjaxQ, 'ajax - parallel - check queue')
|
||||||
window.testAjaxQ = true;
|
window.testAjaxQ = true;
|
||||||
|
|
||||||
equal( data.success, true, "content parsable and ok!" );
|
equal(data.success, true, "content parsable and ok!")
|
||||||
equal( data.success2, undefined, "content parsable and ok!" );
|
equal(data.success2, undefined, "content parsable and ok!")
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function (data) {
|
error: function (data) {
|
||||||
test( "ajax", function() {
|
test( "ajax", function() {
|
||||||
ok( false, "Failed!" );
|
ok( false, "Failed!")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// delay
|
// delay
|
||||||
window.testDelay1 = false
|
window.testDelay1 = false
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "delay - test 1 - 1/3 - should not be executed, will be reset by next set()", function() {
|
test('delay - test 1 - 1/3 - should not be executed, will be reset by next set()', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
ok( false, 'delay - test 1 - 1/3 - should not be executed, will be reset by next set()' );
|
ok(false, 'delay - test 1 - 1/3 - should not be executed, will be reset by next set()')
|
||||||
window.testDelay1 = true;
|
window.testDelay1 = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -114,11 +114,11 @@ App.Delay.set( function() {
|
||||||
'delay-test1',
|
'delay-test1',
|
||||||
'level'
|
'level'
|
||||||
);
|
);
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "delay - test 1 - 2/3", function() {
|
test('delay - test 1 - 2/3', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
ok( !window.testDelay1, 'delay - test 1 - 2/3' );
|
ok(!window.testDelay1, 'delay - test 1 - 2/3')
|
||||||
window.testDelay1 = 1;
|
window.testDelay1 = 1;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -126,11 +126,11 @@ App.Delay.set( function() {
|
||||||
'delay-test1',
|
'delay-test1',
|
||||||
'level'
|
'level'
|
||||||
);
|
);
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "delay - test 1 - 2/3", function() {
|
test('delay - test 1 - 2/3', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
ok( window.testDelay1, 'delay - test 1 - 2/3' );
|
ok(window.testDelay1, 'delay - test 1 - 2/3')
|
||||||
window.testDelay1 = false;
|
window.testDelay1 = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -139,41 +139,41 @@ App.Delay.set( function() {
|
||||||
'level'
|
'level'
|
||||||
);
|
);
|
||||||
|
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "delay - test 2 - 1/3", function() {
|
test('delay - test 2 - 1/3', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
ok( !window.testDelay2, 'delay - test 2 - 1/3' );
|
ok(!window.testDelay2, 'delay - test 2 - 1/3')
|
||||||
window.testDelay2 = 1;
|
window.testDelay2 = 1;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
2000
|
2000
|
||||||
);
|
);
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "delay - test 2 - 2/3", function() {
|
test('delay - test 2 - 2/3', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
ok( !window.testDelay2, 'delay - test 2 - 2/3' );
|
ok(!window.testDelay2, 'delay - test 2 - 2/3')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
1000
|
1000
|
||||||
);
|
);
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "delay - test 2 - 3/3", function() {
|
test('delay - test 2 - 3/3', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
ok( window.testDelay2, 'delay - test 2 - 3/3' );
|
ok(window.testDelay2, 'delay - test 2 - 3/3')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
3000
|
3000
|
||||||
);
|
);
|
||||||
|
|
||||||
window.testDelay3 = 1;
|
window.testDelay3 = 1;
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "delay - test 3 - 1/1", function() {
|
test('delay - test 3 - 1/1', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
ok( false, 'delay - test 3 - 1/1' );
|
ok(false, 'delay - test 3 - 1/1')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
1000,
|
1000,
|
||||||
|
@ -181,11 +181,11 @@ App.Delay.set( function() {
|
||||||
);
|
);
|
||||||
App.Delay.clear('delay3')
|
App.Delay.clear('delay3')
|
||||||
|
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "delay - test 4 - 1/1", function() {
|
test('delay - test 4 - 1/1', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
ok( false, 'delay - test 4 - 1/1' );
|
ok(false, 'delay - test 4 - 1/1')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
1000,
|
1000,
|
||||||
|
@ -197,27 +197,27 @@ App.Delay.clearLevel('Page')
|
||||||
|
|
||||||
// interval 1
|
// interval 1
|
||||||
window.testInterval1 = 1
|
window.testInterval1 = 1
|
||||||
App.Interval.set( function() {
|
App.Interval.set(function() {
|
||||||
window.testInterval1 += 1;
|
window.testInterval1 += 1;
|
||||||
},
|
},
|
||||||
2000,
|
2000,
|
||||||
'interval-test1'
|
'interval-test1'
|
||||||
);
|
);
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "interval - test 1 - 1/2", function() {
|
test('interval - test 1 - 1/2', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
equal( window.testInterval1, 4, 'interval - test 1' );
|
equal(window.testInterval1, 4, 'interval - test 1')
|
||||||
App.Interval.clear('interval-test1')
|
App.Interval.clear('interval-test1')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
5200
|
5200
|
||||||
);
|
);
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "interval - test 1 - 2/2", function() {
|
test('interval - test 1 - 2/2', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
equal( window.testInterval1, 4, 'interval - test after clear' );
|
equal(window.testInterval1, 4, 'interval - test after clear')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
6500
|
6500
|
||||||
|
@ -226,28 +226,28 @@ App.Delay.set( function() {
|
||||||
|
|
||||||
// interval 2
|
// interval 2
|
||||||
window.testInterval2 = 1
|
window.testInterval2 = 1
|
||||||
App.Interval.set( function() {
|
App.Interval.set(function() {
|
||||||
window.testInterval2 += 1;
|
window.testInterval2 += 1;
|
||||||
},
|
},
|
||||||
2000,
|
2000,
|
||||||
undefined,
|
undefined,
|
||||||
'someLevel'
|
'someLevel'
|
||||||
);
|
);
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "interval - test 2 - 1/2", function() {
|
test('interval - test 2 - 1/2', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
equal( window.testInterval2, 4, 'interval - test 2' );
|
equal(window.testInterval2, 4, 'interval - test 2')
|
||||||
App.Interval.clearLevel('someLevel')
|
App.Interval.clearLevel('someLevel')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
5200
|
5200
|
||||||
);
|
);
|
||||||
App.Delay.set( function() {
|
App.Delay.set(function() {
|
||||||
test( "interval - test 2 - 2/2", function() {
|
test('interval - test 2 - 2/2', function() {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
equal( window.testInterval2, 4, 'interval - test 2 - after clear' );
|
equal(window.testInterval2, 4, 'interval - test 2 - after clear')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
6900
|
6900
|
||||||
|
@ -255,190 +255,190 @@ App.Delay.set( function() {
|
||||||
|
|
||||||
|
|
||||||
// i18n
|
// i18n
|
||||||
test( "i18n", function() {
|
test('i18n', function() {
|
||||||
|
|
||||||
// de
|
// de
|
||||||
App.i18n.set('de-de');
|
App.i18n.set('de-de')
|
||||||
var translated = App.i18n.translateContent('yes');
|
var translated = App.i18n.translateContent('yes')
|
||||||
equal( translated, 'ja', 'de-de - yes / ja translated correctly' );
|
equal(translated, 'ja', 'de-de - yes / ja translated correctly')
|
||||||
|
|
||||||
translated = App.i18n.translatePlain('yes');
|
translated = App.i18n.translatePlain('yes')
|
||||||
equal( translated, 'ja', 'de-de - yes / ja translated correctly' );
|
equal(translated, 'ja', 'de-de - yes / ja translated correctly')
|
||||||
|
|
||||||
translated = App.i18n.translateInline('yes');
|
translated = App.i18n.translateInline('yes')
|
||||||
equal( translated, 'ja', 'de-de - yes / ja translated correctly' );
|
equal(translated, 'ja', 'de-de - yes / ja translated correctly')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('%s ago', 123);
|
translated = App.i18n.translateContent('%s ago', 123);
|
||||||
equal( translated, 'vor 123', 'de-de - %s' );
|
equal(translated, 'vor 123', 'de-de - %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('%s ago', '<b>quote</b>');
|
translated = App.i18n.translateContent('%s ago', '<b>quote</b>')
|
||||||
equal( translated, 'vor <b>quote</b>', 'de-de - %s - quote' );
|
equal(translated, 'vor <b>quote</b>', 'de-de - %s - quote')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('%s %s test', 123, 'xxx |B|');
|
translated = App.i18n.translateContent('%s %s test', 123, 'xxx |B|')
|
||||||
equal( translated, '123 xxx |B| test', 'de-de - %s %s' );
|
equal(translated, '123 xxx |B| test', 'de-de - %s %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx')
|
||||||
equal( translated, '<b>123</b> xxx test', 'de-de - *%s* %s' );
|
equal(translated, '<b>123</b> xxx test', 'de-de - *%s* %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('||%s|| %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('||%s|| %s test', 123, 'xxx')
|
||||||
equal( translated, '<i>123</i> xxx test', 'de-de - *%s* %s' );
|
equal(translated, '<i>123</i> xxx test', 'de-de - *%s* %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx')
|
||||||
equal( translated, '<u>123</u> xxx test', 'de-de - _%s_ %s' );
|
equal(translated, '<u>123</u> xxx test', 'de-de - _%s_ %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('§%s§ %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('§%s§ %s test', 123, 'xxx')
|
||||||
equal( translated, '<kbd>123</kbd> xxx test', 'de-de - §%s§ %s' );
|
equal(translated, '<kbd>123</kbd> xxx test', 'de-de - §%s§ %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('//%s// %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('//%s// %s test', 123, 'xxx')
|
||||||
equal( translated, '<del>123</del> xxx test', 'de-de - //%s// %s' );
|
equal(translated, '<del>123</del> xxx test', 'de-de - //%s// %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('\'%s\' %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('\'%s\' %s test', 123, 'xxx')
|
||||||
equal( translated, ''123' xxx test', 'de-de - \'%s\' %s' );
|
equal(translated, ''123' xxx test', 'de-de - \'%s\' %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('<test&now>//*äöüß');
|
translated = App.i18n.translateContent('<test&now>//*äöüß')
|
||||||
equal( translated, '<test&now>//*äöüß', 'de - <test&now>//*äöüß' );
|
equal(translated, '<test&now>//*äöüß', 'de - <test&now>//*äöüß')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('some link [to what ever](http://lalala)');
|
translated = App.i18n.translateContent('some link [to what ever](http://lalala)')
|
||||||
equal( translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'de-de - link' );
|
equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'de-de - link')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('some link [to what ever](%s)', 'http://lalala');
|
translated = App.i18n.translateContent('some link [to what ever](%s)', 'http://lalala')
|
||||||
equal( translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'de-de - link' );
|
equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'de-de - link')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('Enables user authentication via %s. Register your app first at [%s](%s).', 'XXX', 'YYY', 'http://lalala');
|
translated = App.i18n.translateContent('Enables user authentication via %s. Register your app first at [%s](%s).', 'XXX', 'YYY', 'http://lalala')
|
||||||
equal( translated, 'Aktivieren der Benutzeranmeldung über XXX. Registriere Deine Anwendung zuerst über <a href="http://lalala" target="_blank">YYY</a>.', 'en-us - link' );
|
equal(translated, 'Aktivieren der Benutzeranmeldung über XXX. Registriere Deine Anwendung zuerst über <a href="http://lalala" target="_blank">YYY</a>.', 'en-us - link')
|
||||||
|
|
||||||
var time_local = new Date();
|
var time_local = new Date();
|
||||||
var offset = time_local.getTimezoneOffset();
|
var offset = time_local.getTimezoneOffset();
|
||||||
var timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset);
|
var timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset);
|
||||||
equal( timestamp, '06.11.2012 21:07', 'de-de - timestamp translated correctly' );
|
equal(timestamp, '06.11.2012 21:07', 'de-de - timestamp translated correctly')
|
||||||
|
|
||||||
// en
|
// en
|
||||||
App.i18n.set('en-us');
|
App.i18n.set('en-us')
|
||||||
translated = App.i18n.translateContent('yes');
|
translated = App.i18n.translateContent('yes')
|
||||||
equal( translated, 'yes', 'en-us - yes translated correctly' );
|
equal(translated, 'yes', 'en-us - yes translated correctly')
|
||||||
|
|
||||||
translated = App.i18n.translatePlain('yes');
|
translated = App.i18n.translatePlain('yes')
|
||||||
equal( translated, 'yes', 'en-us - yes translated correctly' );
|
equal(translated, 'yes', 'en-us - yes translated correctly')
|
||||||
|
|
||||||
translated = App.i18n.translateInline('yes');
|
translated = App.i18n.translateInline('yes')
|
||||||
equal( translated, 'yes', 'en-us - yes translated correctly' );
|
equal(translated, 'yes', 'en-us - yes translated correctly')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('%s ago', 123);
|
translated = App.i18n.translateContent('%s ago', 123);
|
||||||
equal( translated, '123 ago', 'en-us - %s' );
|
equal(translated, '123 ago', 'en-us - %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('%s ago', '<b>quote</b>');
|
translated = App.i18n.translateContent('%s ago', '<b>quote</b>')
|
||||||
equal( translated, '<b>quote</b> ago', 'en-us - %s - qupte' );
|
equal(translated, '<b>quote</b> ago', 'en-us - %s - qupte')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('%s %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('%s %s test', 123, 'xxx')
|
||||||
equal( translated, '123 xxx test', 'en-us - %s %s' );
|
equal(translated, '123 xxx test', 'en-us - %s %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx |B|');
|
translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx |B|')
|
||||||
equal( translated, '<b>123</b> xxx |B| test', 'en-us - *%s* %s' );
|
equal(translated, '<b>123</b> xxx |B| test', 'en-us - *%s* %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('||%s|| %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('||%s|| %s test', 123, 'xxx')
|
||||||
equal( translated, '<i>123</i> xxx test', 'en-us - *%s* %s' );
|
equal(translated, '<i>123</i> xxx test', 'en-us - *%s* %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx')
|
||||||
equal( translated, '<u>123</u> xxx test', 'en-us - _%s_ %s' );
|
equal(translated, '<u>123</u> xxx test', 'en-us - _%s_ %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('§%s§ %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('§%s§ %s test', 123, 'xxx')
|
||||||
equal( translated, '<kbd>123</kbd> xxx test', 'en-us - §%s§ %s' );
|
equal(translated, '<kbd>123</kbd> xxx test', 'en-us - §%s§ %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('Here you can search for ticket, customers and organizations. Use the wildcard §*§ to find everything. E. g. §smi*§ or §rosent*l§. You also can use ||double quotes|| for searching phrases §"some phrase"§.');
|
translated = App.i18n.translateContent('Here you can search for ticket, customers and organizations. Use the wildcard §*§ to find everything. E. g. §smi*§ or §rosent*l§. You also can use ||double quotes|| for searching phrases §"some phrase"§.')
|
||||||
equal( translated, 'Here you can search for ticket, customers and organizations. Use the wildcard <kbd>*</kbd> to find everything. E. g. <kbd>smi*</kbd> or <kbd>rosent*l</kbd>. You also can use <i>double quotes</i> for searching phrases <kbd>"some phrase"</kbd>.', 'en-us - §§ §§ §§ || §§' );
|
equal(translated, 'Here you can search for ticket, customers and organizations. Use the wildcard <kbd>*</kbd> to find everything. E. g. <kbd>smi*</kbd> or <kbd>rosent*l</kbd>. You also can use <i>double quotes</i> for searching phrases <kbd>"some phrase"</kbd>.', 'en-us - §§ §§ §§ || §§')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('//%s// %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('//%s// %s test', 123, 'xxx')
|
||||||
equal( translated, '<del>123</del> xxx test', 'en-us - //%s// %s' );
|
equal(translated, '<del>123</del> xxx test', 'en-us - //%s// %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('\'%s\' %s test', 123, 'xxx');
|
translated = App.i18n.translateContent('\'%s\' %s test', 123, 'xxx')
|
||||||
equal( translated, ''123' xxx test', 'en-us - \'%s\' %s' );
|
equal(translated, ''123' xxx test', 'en-us - \'%s\' %s')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('<test&now>');
|
translated = App.i18n.translateContent('<test&now>')
|
||||||
equal( translated, '<test&now>', 'en-us - <test&now>' );
|
equal(translated, '<test&now>', 'en-us - <test&now>')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('some link [to what ever](http://lalala)');
|
translated = App.i18n.translateContent('some link [to what ever](http://lalala)')
|
||||||
equal( translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'en-us - link' );
|
equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'en-us - link')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('some link [to what ever](%s)', 'http://lalala');
|
translated = App.i18n.translateContent('some link [to what ever](%s)', 'http://lalala')
|
||||||
equal( translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'en-us - link' );
|
equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'en-us - link')
|
||||||
|
|
||||||
translated = App.i18n.translateContent('Enables user authentication via %s. Register your app first at [%s](%s).', 'XXX', 'YYY', 'http://lalala');
|
translated = App.i18n.translateContent('Enables user authentication via %s. Register your app first at [%s](%s).', 'XXX', 'YYY', 'http://lalala')
|
||||||
equal( translated, 'Enables user authentication via XXX. Register your app first at <a href="http://lalala" target="_blank">YYY</a>.', 'en-us - link' );
|
equal(translated, 'Enables user authentication via XXX. Register your app first at <a href="http://lalala" target="_blank">YYY</a>.', 'en-us - link')
|
||||||
|
|
||||||
timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset);
|
timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset)
|
||||||
equal( timestamp, '11/06/2012 21:07', 'en - timestamp translated correctly' );
|
equal(timestamp, '11/06/2012 21:07', 'en - timestamp translated correctly')
|
||||||
|
|
||||||
// locale alias test
|
// locale alias test
|
||||||
// de
|
// de
|
||||||
App.i18n.set('de');
|
App.i18n.set('de')
|
||||||
var translated = App.i18n.translateContent('yes');
|
var translated = App.i18n.translateContent('yes')
|
||||||
equal( translated, 'ja', 'de - yes / ja translated correctly' );
|
equal(translated, 'ja', 'de - yes / ja translated correctly')
|
||||||
|
|
||||||
// locale detection test
|
// locale detection test
|
||||||
// de-ch
|
// de-ch
|
||||||
App.i18n.set('de-ch');
|
App.i18n.set('de-ch')
|
||||||
var translated = App.i18n.translateContent('yes');
|
var translated = App.i18n.translateContent('yes')
|
||||||
equal( translated, 'ja', 'de - yes / ja translated correctly' );
|
equal(translated, 'ja', 'de - yes / ja translated correctly')
|
||||||
});
|
});
|
||||||
|
|
||||||
// events
|
// events
|
||||||
test( "events simple", function() {
|
test('events simple', function() {
|
||||||
|
|
||||||
// single bind
|
// single bind
|
||||||
App.Event.bind( 'test1', function(data) {
|
App.Event.bind('test1', function(data) {
|
||||||
ok( true, 'event received - single bind');
|
ok(true, 'event received - single bind')
|
||||||
equal( data.success, true, 'event received - data ok - single bind');
|
equal(data.success, true, 'event received - data ok - single bind')
|
||||||
});
|
});
|
||||||
App.Event.bind( 'test2', function(data) {
|
App.Event.bind('test2', function(data) {
|
||||||
ok( false, 'should not be triggered - single bind');
|
ok(false, 'should not be triggered - single bind')
|
||||||
});
|
});
|
||||||
App.Event.trigger( 'test1', { success: true } );
|
App.Event.trigger('test1', { success: true })
|
||||||
|
|
||||||
App.Event.unbind( 'test1')
|
App.Event.unbind('test1')
|
||||||
App.Event.bind( 'test1', function(data) {
|
App.Event.bind('test1', function(data) {
|
||||||
ok( false, 'should not be triggered - single bind');
|
ok(false, 'should not be triggered - single bind')
|
||||||
});
|
});
|
||||||
App.Event.unbind( 'test1');
|
App.Event.unbind('test1')
|
||||||
App.Event.trigger( 'test1', { success: true } );
|
App.Event.trigger('test1', { success: true })
|
||||||
|
|
||||||
// multi bind
|
// multi bind
|
||||||
App.Event.bind( 'test1-1 test1-2', function(data) {
|
App.Event.bind('test1-1 test1-2', function(data) {
|
||||||
ok( true, 'event received - multi bind');
|
ok(true, 'event received - multi bind')
|
||||||
equal( data.success, true, 'event received - data ok - multi bind');
|
equal(data.success, true, 'event received - data ok - multi bind')
|
||||||
});
|
});
|
||||||
App.Event.bind( 'test1-3', function(data) {
|
App.Event.bind('test1-3', function(data) {
|
||||||
ok( false, 'should not be triggered - multi bind');
|
ok(false, 'should not be triggered - multi bind')
|
||||||
});
|
});
|
||||||
App.Event.trigger( 'test1-2', { success: true } );
|
App.Event.trigger('test1-2', { success: true })
|
||||||
|
|
||||||
App.Event.unbind( 'test1-1')
|
App.Event.unbind('test1-1')
|
||||||
App.Event.bind( 'test1-1', function(data) {
|
App.Event.bind('test1-1', function(data) {
|
||||||
ok( false, 'should not be triggered - multi bind');
|
ok(false, 'should not be triggered - multi bind')
|
||||||
});
|
});
|
||||||
App.Event.trigger( 'test1-2', { success: true } );
|
App.Event.trigger('test1-2', { success: true })
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "events level", function() {
|
test('events level', function() {
|
||||||
|
|
||||||
// bind with level
|
// bind with level
|
||||||
App.Event.bind( 'test3', function(data) {
|
App.Event.bind('test3', function(data) {
|
||||||
ok( false, 'should not be triggered!');
|
ok(false, 'should not be triggered!')
|
||||||
}, 'test-level' );
|
}, 'test-level')
|
||||||
|
|
||||||
// unbind with level
|
// unbind with level
|
||||||
App.Event.unbindLevel( 'test-level' );
|
App.Event.unbindLevel( 'test-level')
|
||||||
|
|
||||||
// bind with level
|
// bind with level
|
||||||
App.Event.bind( 'test3', function(data) {
|
App.Event.bind('test3', function(data) {
|
||||||
ok( true, 'event received');
|
ok(true, 'event received')
|
||||||
equal( data.success, true, 'event received - data ok - level bind');
|
equal(data.success, true, 'event received - data ok - level bind')
|
||||||
}, 'test-level' );
|
}, 'test-level')
|
||||||
App.Event.trigger( 'test3', { success: true} );
|
App.Event.trigger('test3', { success: true})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// session store
|
// session store
|
||||||
test( "session store", function() {
|
test('session store', function() {
|
||||||
|
|
||||||
var tests = [
|
var tests = [
|
||||||
'some 123äöüßadajsdaiosjdiaoidj',
|
'some 123äöüßadajsdaiosjdiaoidj',
|
||||||
|
@ -449,16 +449,16 @@ test( "session store", function() {
|
||||||
// write/get
|
// write/get
|
||||||
App.SessionStorage.clear()
|
App.SessionStorage.clear()
|
||||||
_.each(tests, function(test) {
|
_.each(tests, function(test) {
|
||||||
App.SessionStorage.set( 'test1', test );
|
App.SessionStorage.set('test1', test)
|
||||||
var item = App.SessionStorage.get( 'test1' );
|
var item = App.SessionStorage.get('test1')
|
||||||
deepEqual( test, item, 'write/get - compare stored and actual data' )
|
deepEqual(test, item, 'write/get - compare stored and actual data')
|
||||||
});
|
});
|
||||||
|
|
||||||
// undefined/get
|
// undefined/get
|
||||||
App.SessionStorage.clear()
|
App.SessionStorage.clear()
|
||||||
_.each(tests, function(test) {
|
_.each(tests, function(test) {
|
||||||
var item = App.SessionStorage.get( 'test1' );
|
var item = App.SessionStorage.get('test1')
|
||||||
deepEqual( undefined, item, 'undefined/get - compare not existing data and actual data' )
|
deepEqual(undefined, item, 'undefined/get - compare not existing data and actual data')
|
||||||
});
|
});
|
||||||
|
|
||||||
// write/get/delete
|
// write/get/delete
|
||||||
|
@ -470,21 +470,21 @@ test( "session store", function() {
|
||||||
|
|
||||||
App.SessionStorage.clear()
|
App.SessionStorage.clear()
|
||||||
_.each(tests, function(test) {
|
_.each(tests, function(test) {
|
||||||
App.SessionStorage.set( test.key, test.value );
|
App.SessionStorage.set(test.key, test.value)
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(tests, function(test) {
|
_.each(tests, function(test) {
|
||||||
var item = App.SessionStorage.get( test.key );
|
var item = App.SessionStorage.get(test.key)
|
||||||
deepEqual( test.value, item, 'write/get/delete - compare stored and actual data' );
|
deepEqual(test.value, item, 'write/get/delete - compare stored and actual data')
|
||||||
App.SessionStorage.delete( test.key );
|
App.SessionStorage.delete( test.key)
|
||||||
item = App.SessionStorage.get( test.key );
|
item = App.SessionStorage.get(test.key)
|
||||||
deepEqual( undefined, item, 'write/get/delete - compare deleted data' );
|
deepEqual(undefined, item, 'write/get/delete - compare deleted data')
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// config
|
// config
|
||||||
test( "config", function() {
|
test('config', function() {
|
||||||
|
|
||||||
// simple
|
// simple
|
||||||
var tests = [
|
var tests = [
|
||||||
|
@ -494,12 +494,12 @@ test( "config", function() {
|
||||||
];
|
];
|
||||||
|
|
||||||
_.each(tests, function(test) {
|
_.each(tests, function(test) {
|
||||||
App.Config.set( test.key, test.value )
|
App.Config.set(test.key, test.value )
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(tests, function(test) {
|
_.each(tests, function(test) {
|
||||||
var item = App.Config.get( test.key )
|
var item = App.Config.get(test.key )
|
||||||
deepEqual( item, test.value, 'set/get tests' );
|
deepEqual(item, test.value, 'set/get tests')
|
||||||
});
|
});
|
||||||
|
|
||||||
// group
|
// group
|
||||||
|
@ -510,24 +510,24 @@ test( "config", function() {
|
||||||
];
|
];
|
||||||
var group = {};
|
var group = {};
|
||||||
_.each(test_groups, function(test) {
|
_.each(test_groups, function(test) {
|
||||||
App.Config.set( test.key, test.value, 'group1' );
|
App.Config.set(test.key, test.value, 'group1')
|
||||||
group[test.key] = test.value
|
group[test.key] = test.value
|
||||||
});
|
});
|
||||||
|
|
||||||
// verify whole group
|
// verify whole group
|
||||||
var item = App.Config.get( 'group1' );
|
var item = App.Config.get('group1')
|
||||||
deepEqual( item, group, 'group - verify group hash');
|
deepEqual(item, group, 'group - verify group hash')
|
||||||
|
|
||||||
// verify each setting
|
// verify each setting
|
||||||
_.each(test_groups, function(test) {
|
_.each(test_groups, function(test) {
|
||||||
var item = App.Config.get( test.key, 'group1' );
|
var item = App.Config.get(test.key, 'group1')
|
||||||
deepEqual( item, test.value, 'group set/get tests' );
|
deepEqual(item, test.value, 'group set/get tests')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// clone
|
// clone
|
||||||
test( "clone", function() {
|
test('clone', function() {
|
||||||
|
|
||||||
// simple
|
// simple
|
||||||
var tests = [
|
var tests = [
|
||||||
|
@ -578,7 +578,7 @@ test( "clone", function() {
|
||||||
|
|
||||||
_.each(tests, function(test) {
|
_.each(tests, function(test) {
|
||||||
var item = clone( test )
|
var item = clone( test )
|
||||||
deepEqual( item, test, 'clone' );
|
deepEqual(item, test, 'clone')
|
||||||
});
|
});
|
||||||
|
|
||||||
// complex test
|
// complex test
|
||||||
|
@ -597,8 +597,7 @@ test( "clone", function() {
|
||||||
// modify source later, should not have any result
|
// modify source later, should not have any result
|
||||||
source[0].name = 'some new name'
|
source[0].name = 'some new name'
|
||||||
|
|
||||||
deepEqual( result, reference, 'clone' );
|
deepEqual(result, reference, 'clone')
|
||||||
|
|
||||||
|
|
||||||
// full test
|
// full test
|
||||||
var source = [
|
var source = [
|
||||||
|
@ -617,97 +616,110 @@ test( "clone", function() {
|
||||||
source[0].name = 'some new name'
|
source[0].name = 'some new name'
|
||||||
source[2].fn = 'some new name'
|
source[2].fn = 'some new name'
|
||||||
|
|
||||||
deepEqual( result[0], reference[0], 'clone full' );
|
deepEqual(result[0], reference[0], 'clone full')
|
||||||
deepEqual( result[1], reference[1], 'clone full' );
|
deepEqual(result[1], reference[1], 'clone full')
|
||||||
|
|
||||||
equal( typeof reference[2].fn, 'function')
|
equal(typeof reference[2].fn, 'function')
|
||||||
equal( typeof result[2].fn, 'function')
|
equal(typeof result[2].fn, 'function')
|
||||||
|
|
||||||
equal( reference[2].fn(), 'test')
|
equal(reference[2].fn(), 'test')
|
||||||
equal( result[2].fn(), 'test')
|
equal(result[2].fn(), 'test')
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// diff
|
// diff
|
||||||
test( "diff", function() {
|
test('difference', function() {
|
||||||
|
|
||||||
// simple
|
// simple
|
||||||
var tests = [
|
var object1 = {
|
||||||
{
|
key1: 123,
|
||||||
object1: {
|
key2: 1234
|
||||||
key1: 123,
|
}
|
||||||
key2: 1234
|
var object2 = {
|
||||||
},
|
key1: 123,
|
||||||
object2: {
|
key2: 1235
|
||||||
key1: 123,
|
}
|
||||||
key2: 1235
|
var result = {
|
||||||
},
|
key2: 1235
|
||||||
result: {
|
}
|
||||||
key2: 1235
|
var item = difference(object1, object2)
|
||||||
}
|
deepEqual(item, result)
|
||||||
},
|
|
||||||
{
|
|
||||||
object1: {
|
|
||||||
key1: 123,
|
|
||||||
key2: 123
|
|
||||||
},
|
|
||||||
object2: {
|
|
||||||
key1: 123,
|
|
||||||
key2: 123
|
|
||||||
},
|
|
||||||
result: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
object1: {
|
|
||||||
key1: 123,
|
|
||||||
key2: 123
|
|
||||||
},
|
|
||||||
object2: {
|
|
||||||
key1: 123,
|
|
||||||
key2: 123
|
|
||||||
},
|
|
||||||
result: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
object1: {
|
|
||||||
key1: 123,
|
|
||||||
key2: [1,3,5]
|
|
||||||
},
|
|
||||||
object2: {
|
|
||||||
key1: 123,
|
|
||||||
key2: 123
|
|
||||||
},
|
|
||||||
result: {
|
|
||||||
key2: 123
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
object1: {
|
|
||||||
key1: 123,
|
|
||||||
key2: [1,3,5]
|
|
||||||
},
|
|
||||||
object2: {
|
|
||||||
key1: 123,
|
|
||||||
},
|
|
||||||
result: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
object1: {
|
|
||||||
key1: 123,
|
|
||||||
},
|
|
||||||
object2: {
|
|
||||||
key1: 123,
|
|
||||||
key2: 124
|
|
||||||
},
|
|
||||||
result: {}
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
_.each(tests, function(test) {
|
object1 = {
|
||||||
var item = difference( test.object1, test.object2 )
|
key1: 123,
|
||||||
deepEqual( item, test.result, 'tests simple' );
|
key2: 123
|
||||||
});
|
}
|
||||||
|
object2 = {
|
||||||
|
key1: 123,
|
||||||
|
key2: 123
|
||||||
|
}
|
||||||
|
result = {}
|
||||||
|
item = difference(object1, object2)
|
||||||
|
deepEqual(item, result)
|
||||||
|
|
||||||
|
object1 = {
|
||||||
|
key1: 123,
|
||||||
|
key2: [1,3,5]
|
||||||
|
}
|
||||||
|
object2 = {
|
||||||
|
key1: 123,
|
||||||
|
key2: 123
|
||||||
|
}
|
||||||
|
result = {
|
||||||
|
key2: 123
|
||||||
|
}
|
||||||
|
item = difference(object1, object2)
|
||||||
|
deepEqual(item, result)
|
||||||
|
|
||||||
|
object1 = {
|
||||||
|
key1: 123,
|
||||||
|
key2: [1,3,5]
|
||||||
|
}
|
||||||
|
object2 = {
|
||||||
|
key1: 123,
|
||||||
|
}
|
||||||
|
result = {}
|
||||||
|
item = difference(object1, object2)
|
||||||
|
deepEqual(item, result)
|
||||||
|
|
||||||
|
object1 = {
|
||||||
|
key1: 123,
|
||||||
|
}
|
||||||
|
object2 = {
|
||||||
|
key1: 123,
|
||||||
|
key2: 124
|
||||||
|
}
|
||||||
|
result = {}
|
||||||
|
item = difference(object1, object2)
|
||||||
|
deepEqual(item, result)
|
||||||
|
|
||||||
|
object1 = {
|
||||||
|
customer_id: 1,
|
||||||
|
organization_id: 2,
|
||||||
|
}
|
||||||
|
object2 = {
|
||||||
|
customer_id: 1,
|
||||||
|
organization_id: null,
|
||||||
|
}
|
||||||
|
result = {
|
||||||
|
organization_id: null,
|
||||||
|
}
|
||||||
|
item = difference(object1, object2)
|
||||||
|
deepEqual(item, result)
|
||||||
|
|
||||||
|
object1 = {
|
||||||
|
customer_id: 1,
|
||||||
|
organization_id: null,
|
||||||
|
}
|
||||||
|
object2 = {
|
||||||
|
customer_id: 1,
|
||||||
|
organization_id: 2,
|
||||||
|
}
|
||||||
|
result = {
|
||||||
|
organization_id: 2,
|
||||||
|
}
|
||||||
|
item = difference(object1, object2)
|
||||||
|
deepEqual(item, result)
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -718,14 +730,14 @@ App.Auth.login({
|
||||||
password: 'not_existing',
|
password: 'not_existing',
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
test( "auth - not existing user", function() {
|
test('auth - not existing user', function() {
|
||||||
ok( false, 'ok' )
|
ok(false, 'ok')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
test( "auth - not existing user", function() {
|
test('auth - not existing user', function() {
|
||||||
ok( true, 'ok' )
|
ok(true, 'ok')
|
||||||
authWithSession();
|
authWithSession()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -737,15 +749,15 @@ var authWithSession = function() {
|
||||||
password: 'test',
|
password: 'test',
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
test( "auth - existing user", function() {
|
test('auth - existing user', function() {
|
||||||
ok( true, 'authenticated')
|
ok(true, 'authenticated')
|
||||||
var user = App.Session.get('login');
|
var user = App.Session.get('login')
|
||||||
equal( 'nicole.braun@zammad.org', user, 'session login' )
|
equal('nicole.braun@zammad.org', user, 'session login')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
test( "auth - existing user", function() {
|
test('auth - existing user', function() {
|
||||||
ok( false, 'not authenticated' )
|
ok(false, 'not authenticated')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,7 +40,7 @@ class AgentTicketAttachmentTest < TestCase
|
||||||
|
|
||||||
# add attachment, attachment check should quiet
|
# add attachment, attachment check should quiet
|
||||||
file_upload(
|
file_upload(
|
||||||
css: '.active .attachmentPlaceholder-inputHolder input',
|
css: '.content.active .attachmentPlaceholder-inputHolder input',
|
||||||
files: ['test/fixtures/upload2.jpg', 'test/fixtures/upload1.txt'],
|
files: ['test/fixtures/upload2.jpg', 'test/fixtures/upload1.txt'],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -54,13 +54,13 @@ class AgentTicketAttachmentTest < TestCase
|
||||||
# check if ticket is shown and attachment exists
|
# check if ticket is shown and attachment exists
|
||||||
location_check(url: '#ticket/zoom/')
|
location_check(url: '#ticket/zoom/')
|
||||||
sleep 2
|
sleep 2
|
||||||
ticket_number = @browser.find_elements({ css: '.active .ticketZoom-header .ticket-number' })[0].text
|
ticket_number = @browser.find_elements({ css: '.content.active .ticketZoom-header .ticket-number' })[0].text
|
||||||
match(
|
match(
|
||||||
css: '.active .ticket-article-item:nth-child(1) .attachments',
|
css: '.content.active .ticket-article-item:nth-child(1) .attachments',
|
||||||
value: 'upload2.jpg',
|
value: 'upload2.jpg',
|
||||||
)
|
)
|
||||||
match(
|
match(
|
||||||
css: '.active .ticket-article-item:nth-child(1) .attachments',
|
css: '.content.active .ticket-article-item:nth-child(1) .attachments',
|
||||||
value: 'upload1.txt',
|
value: 'upload1.txt',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class AgentTicketAttachmentTest < TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
# submit form
|
# submit form
|
||||||
click(css: '.active .js-submit')
|
click(css: '.content.active .js-submit')
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# check warning
|
# check warning
|
||||||
|
@ -86,12 +86,12 @@ class AgentTicketAttachmentTest < TestCase
|
||||||
|
|
||||||
# add attachment, attachment check should quiet
|
# add attachment, attachment check should quiet
|
||||||
file_upload(
|
file_upload(
|
||||||
css: '.active .attachmentPlaceholder-inputHolder input',
|
css: '.content.active .attachmentPlaceholder-inputHolder input',
|
||||||
files: ['test/fixtures/upload1.txt'],
|
files: ['test/fixtures/upload1.txt'],
|
||||||
)
|
)
|
||||||
|
|
||||||
# submit form
|
# submit form
|
||||||
click(css: '.active .js-submit')
|
click(css: '.content.active .js-submit')
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# no warning
|
# no warning
|
||||||
|
@ -113,34 +113,34 @@ class AgentTicketAttachmentTest < TestCase
|
||||||
|
|
||||||
# check content and edit screen in instance 1
|
# check content and edit screen in instance 1
|
||||||
match(
|
match(
|
||||||
css: '.active div.ticket-article',
|
css: '.content.active div.ticket-article',
|
||||||
value: 'test 6 - ticket 1-1',
|
value: 'test 6 - ticket 1-1',
|
||||||
)
|
)
|
||||||
match_not(
|
match_not(
|
||||||
css: '.active .ticket-article-item:nth-child(3) .attachments',
|
css: '.content.active .ticket-article-item:nth-child(3) .attachments',
|
||||||
value: 'upload2.jpg',
|
value: 'upload2.jpg',
|
||||||
)
|
)
|
||||||
match(
|
match(
|
||||||
css: '.active .ticket-article-item:nth-child(3) .attachments',
|
css: '.content.active .ticket-article-item:nth-child(3) .attachments',
|
||||||
value: 'upload1.txt',
|
value: 'upload1.txt',
|
||||||
)
|
)
|
||||||
|
|
||||||
# add attachment without body
|
# add attachment without body
|
||||||
file_upload(
|
file_upload(
|
||||||
css: '.active .attachmentPlaceholder-inputHolder input',
|
css: '.content.active .attachmentPlaceholder-inputHolder input',
|
||||||
files: ['test/fixtures/upload2.jpg', 'test/fixtures/upload1.txt'],
|
files: ['test/fixtures/upload2.jpg', 'test/fixtures/upload1.txt'],
|
||||||
)
|
)
|
||||||
|
|
||||||
# submit form
|
# submit form
|
||||||
click(css: '.active .js-submit')
|
click(css: '.content.active .js-submit')
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# check warning
|
# check warning
|
||||||
match(
|
match(
|
||||||
css: '.active .modal',
|
css: '.content.active .modal',
|
||||||
value: 'missing',
|
value: 'missing',
|
||||||
)
|
)
|
||||||
click(css: '.active .modal .js-cancel')
|
click(css: '.content.active .modal .js-cancel')
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
ticket_update(
|
ticket_update(
|
||||||
|
@ -151,7 +151,7 @@ class AgentTicketAttachmentTest < TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
# submit form
|
# submit form
|
||||||
click(css: '.active .js-submit')
|
click(css: '.content.active .js-submit')
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# discard changes should gone away
|
# discard changes should gone away
|
||||||
|
@ -166,11 +166,11 @@ class AgentTicketAttachmentTest < TestCase
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
match(
|
match(
|
||||||
css: '.active .ticket-article-item:nth-child(4) .attachments',
|
css: '.content.active .ticket-article-item:nth-child(4) .attachments',
|
||||||
value: 'upload2.jpg',
|
value: 'upload2.jpg',
|
||||||
)
|
)
|
||||||
match(
|
match(
|
||||||
css: '.active .ticket-article-item:nth-child(4) .attachments',
|
css: '.content.active .ticket-article-item:nth-child(4) .attachments',
|
||||||
value: 'upload1.txt',
|
value: 'upload1.txt',
|
||||||
)
|
)
|
||||||
#
|
#
|
||||||
|
@ -216,10 +216,10 @@ class AgentTicketAttachmentTest < TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
# check if customer has changed in second browser
|
# check if customer has changed in second browser
|
||||||
click(browser: browser1, css: '.active .tabsSidebar-tab[data-tab="customer"]')
|
click(browser: browser1, css: '.content.active .tabsSidebar-tab[data-tab="customer"]')
|
||||||
watch_for(
|
watch_for(
|
||||||
browser: browser1,
|
browser: browser1,
|
||||||
css: '.active .tabsSidebar',
|
css: '.content.active .tabsSidebar',
|
||||||
value: user_email,
|
value: user_email,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -228,17 +228,17 @@ class AgentTicketAttachmentTest < TestCase
|
||||||
#
|
#
|
||||||
|
|
||||||
# modify customer
|
# modify customer
|
||||||
click(browser: browser1, css: '.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
|
click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
|
||||||
click(browser: browser1, css: '.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
|
click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
|
||||||
sleep 2
|
sleep 2
|
||||||
set(browser: browser1, css: '.modal [name="address"]', value: 'some new address')
|
set(browser: browser1, css: '.modal [name="address"]', value: 'some new address')
|
||||||
click(browser: browser1, css: '.modal .js-submit')
|
click(browser: browser1, css: '.modal .js-submit')
|
||||||
|
|
||||||
# verify is customer has chnaged other browser too
|
# verify is customer has chnaged other browser too
|
||||||
click(browser: browser2, css: '.active .tabsSidebar-tab[data-tab="customer"]')
|
click(browser: browser2, css: '.content.active .tabsSidebar-tab[data-tab="customer"]')
|
||||||
watch_for(
|
watch_for(
|
||||||
browser: browser2,
|
browser: browser2,
|
||||||
css: '.active .sidebar[data-tab="customer"]',
|
css: '.content.active .sidebar[data-tab="customer"]',
|
||||||
value: 'some new address',
|
value: 'some new address',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -247,8 +247,8 @@ class AgentTicketAttachmentTest < TestCase
|
||||||
#
|
#
|
||||||
|
|
||||||
# change org of customer, check if org is shown in sidebar
|
# change org of customer, check if org is shown in sidebar
|
||||||
click(browser: browser1, css: '.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
|
click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
|
||||||
click(browser: browser1, css: '.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
|
click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
|
||||||
sleep 2
|
sleep 2
|
||||||
set(browser: browser1, css: '.modal .js-input', value: 'zammad')
|
set(browser: browser1, css: '.modal .js-input', value: 'zammad')
|
||||||
click(browser: browser1, css: '.modal .js-input')
|
click(browser: browser1, css: '.modal .js-input')
|
||||||
|
@ -258,10 +258,10 @@ class AgentTicketAttachmentTest < TestCase
|
||||||
|
|
||||||
# check if org has changed in second browser
|
# check if org has changed in second browser
|
||||||
sleep 3
|
sleep 3
|
||||||
click(browser: browser2, css: '.active .tabsSidebar-tab[data-tab="organization"]')
|
click(browser: browser2, css: '.content.active .tabsSidebar-tab[data-tab="organization"]')
|
||||||
watch_for(
|
watch_for(
|
||||||
browser: browser2,
|
browser: browser2,
|
||||||
css: '.active .sidebar[data-tab="organization"]',
|
css: '.content.active .sidebar[data-tab="organization"]',
|
||||||
value: 'Zammad Foundation',
|
value: 'Zammad Foundation',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue