function check_ajax_field(field, value, count, callback, assert, waitTotal = 30000, wait = 0) { $elementInput = $('[name="' + field + '"].js-shadow + .js-input') if ($elementInput.val() != value) { $elementInput.focus().val(value).trigger('input') } var $element = $('[name="' + field + '"]').closest('.searchableSelect').find('.js-optionsList') var entries = $element.find('li:not(.is-hidden)').length var match = entries == count if (match || wait >= waitTotal) { assert.equal(entries, count, 'search result found for email address ' + value) callback() return } wait += 100 if (wait % 3000 == 0) { assert.ok(true, 'check_ajax_field for ' + field + ' waiting ' + wait) } setTimeout(function() { check_ajax_field(field, value, count, callback, assert, waitTotal, wait) }, 100) } QUnit.test( "autocompletion_ajax check", assert => { var done = assert.async(1) $('#forms').append('