Added test for model binding after relogin.

This commit is contained in:
Martin Edenhofer 2018-04-25 12:04:10 +02:00
parent 5aee0b7d4b
commit 11639e2d33
5 changed files with 80 additions and 2 deletions

View file

@ -869,5 +869,7 @@ set new attributes of model (remove already available attributes)
@configure_attributes = $.extend(true, [], @org_configure_attributes) @configure_attributes = $.extend(true, [], @org_configure_attributes)
@resetCallbacks: -> @resetCallbacks: ->
@SUBSCRIPTION_ITEM = {} if @SUBSCRIPTION_ITEM
@SUBSCRIPTION_COLLECTION = {} @SUBSCRIPTION_ITEM = {}
if @SUBSCRIPTION_COLLECTION
@SUBSCRIPTION_COLLECTION = {}

View file

@ -0,0 +1,16 @@
<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
<script src="/assets/tests/qunit-1.21.0.js"></script>
<script src="/assets/tests/model_binding.js"></script>
<style type="text/css">
body {
padding-top: 0px;
}
</style>
<script type="text/javascript">
</script>
<div id="qunit" class="u-dontfold"></div>

View file

@ -3,6 +3,7 @@ Zammad::Application.routes.draw do
match '/tests_core', to: 'tests#core', via: :get match '/tests_core', to: 'tests#core', via: :get
match '/tests_ui', to: 'tests#ui', via: :get match '/tests_ui', to: 'tests#ui', via: :get
match '/tests_model', to: 'tests#model', via: :get match '/tests_model', to: 'tests#model', via: :get
match '/tests_model_binding', to: 'tests#model_binding', via: :get
match '/tests_model_ui', to: 'tests#model_ui', via: :get match '/tests_model_ui', to: 'tests#model_ui', via: :get
match '/tests_form', to: 'tests#form', via: :get match '/tests_form', to: 'tests#form', via: :get
match '/tests_form_tree_select', to: 'tests#form_tree_select', via: :get match '/tests_form_tree_select', to: 'tests#form_tree_select', via: :get

View file

@ -0,0 +1,52 @@
window.onload = function() {
test("model bindings and rebinding", function() {
var callback_count1 = 0
var callbacks = App.Template._callbacks
Object.keys(callbacks).forEach(function(key) {
callback_count1 = callback_count1 + callbacks[key].length
});
equal(callback_count1, 2)
equal(App.Template.SUBSCRIPTION_COLLECTION, undefined)
App.Template.clearInMemory()
equal(App.Template.SUBSCRIPTION_COLLECTION, undefined)
var callback_count2 = 0
callbacks = App.Template._callbacks
Object.keys(callbacks).forEach(function(key) {
callback_count2 = callback_count2 + callbacks[key].length
});
equal(callback_count2, callback_count1)
var render = function() {}
var subscribe_id = App.Template.subscribe(render, {initFetch: true})
ok(_.isObject(App.Template.SUBSCRIPTION_COLLECTION))
ok(!_.isEmpty(App.Template.SUBSCRIPTION_COLLECTION))
var callback_count3 = 0
callbacks = App.Template._callbacks
Object.keys(callbacks).forEach(function(key) {
callback_count3 = callback_count3 + callbacks[key].length
});
equal(callback_count3, 6)
App.Template.clearInMemory()
ok(_.isObject(App.Template.SUBSCRIPTION_COLLECTION))
ok(_.isEmpty(App.Template.SUBSCRIPTION_COLLECTION))
var callback_count4 = 0
callbacks = App.Template._callbacks
Object.keys(callbacks).forEach(function(key) {
callback_count4 = callback_count4 + callbacks[key].length
});
equal(callback_count4, callback_count3)
});
}

View file

@ -28,6 +28,13 @@ class AAbUnitTest < TestCase
value: '0', value: '0',
) )
location(url: browser_url + '/tests_model_binding')
sleep 8
match(
css: '.result .failed',
value: '0',
)
location(url: browser_url + '/tests_model_ui') location(url: browser_url + '/tests_model_ui')
sleep 8 sleep 8
match( match(