diff --git a/app/assets/javascripts/app/lib/app_post/z_searchable_ajax_select.coffee b/app/assets/javascripts/app/lib/app_post/z_searchable_ajax_select.coffee
index 117dc6694..4f2067d0c 100644
--- a/app/assets/javascripts/app/lib/app_post/z_searchable_ajax_select.coffee
+++ b/app/assets/javascripts/app/lib/app_post/z_searchable_ajax_select.coffee
@@ -75,9 +75,6 @@ class App.SearchableAjaxSelect extends App.SearchableSelect
# refresh elements
@refreshElements()
- # execute filter
- @filterByQuery originalQuery
-
renderResponseItemAjax: (elem, data) ->
result = _.find(data.details, (detailElem) -> detailElem.type == elem.type and detailElem.id == elem.id)
diff --git a/app/views/tests/form_autocompletion_ajax.html.erb b/app/views/tests/form_autocompletion_ajax.html.erb
new file mode 100644
index 000000000..b0d71a826
--- /dev/null
+++ b/app/views/tests/form_autocompletion_ajax.html.erb
@@ -0,0 +1,21 @@
+
+
+<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/form_autocompletion_ajax.js", nonce: true %>
+
+
+
+<%= javascript_tag nonce: true do -%>
+<% end -%>
+
+
+
+
diff --git a/config/routes/test.rb b/config/routes/test.rb
index 69f380570..18c8bb1d6 100644
--- a/config/routes/test.rb
+++ b/config/routes/test.rb
@@ -19,6 +19,7 @@ Zammad::Application.routes.draw do
match '/tests_form_validation', to: 'tests#form_validation', via: :get
match '/tests_form_column_select', to: 'tests#form_column_select', via: :get
match '/tests_form_searchable_select', to: 'tests#form_searchable_select', via: :get
+ match '/tests_form_autocompletion_ajax', to: 'tests#form_autocompletion_ajax', via: :get
match '/tests_form_ticket_perform_action', to: 'tests#form_ticket_perform_action', via: :get
match '/tests_form_sla_times', to: 'tests#form_sla_times', via: :get
match '/tests_form_skip_rendering', to: 'tests#form_skip_rendering', via: :get
diff --git a/public/assets/tests/form_autocompletion_ajax.js b/public/assets/tests/form_autocompletion_ajax.js
new file mode 100644
index 000000000..d7738e6ad
--- /dev/null
+++ b/public/assets/tests/form_autocompletion_ajax.js
@@ -0,0 +1,71 @@
+function check_ajax_field(field, value, count, callback, 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) {
+ equal(entries, count, 'search result found for email address ' + value)
+ callback()
+ return
+ }
+
+ wait += 100
+ if (wait % 3000 == 0) {
+ ok(true, 'check_ajax_field for ' + field + ' waiting ' + wait)
+ }
+
+ setTimeout(function() {
+ check_ajax_field(field, value, count, callback, waitTotal, wait)
+ }, 100)
+}
+
+test( "autocompletion_ajax check", function(assert) {
+ var done = assert.async(1)
+
+ $('#forms').append('
autocompletion_ajax check
')
+ var el = $('#form1')
+
+ new App.ControllerForm({
+ el: el,
+ model: {
+ configure_attributes: [
+ {
+ name: 'autocompletion_ajax1',
+ display: 'AutocompletionAjax1',
+ tag: 'autocompletion_ajax',
+ relation: 'User'
+ },
+ ]
+ },
+ autofocus: true
+ })
+
+ new Promise( (resolve, reject) => {
+ App.Auth.login({
+ data: {
+ username: 'master@example.com',
+ password: 'test',
+ },
+ success: resolve,
+ error: resolve
+ });
+ })
+ .then( function() {
+ return new Promise( (resolve, reject) => {
+ notEqual(App.Session.get(), undefined, 'User is logged in so the api requests will work')
+
+ check_ajax_field('autocompletion_ajax1', 'master@example.com', 1, resolve)
+ })
+ })
+ .then( function() {
+ return new Promise( (resolve, reject) => {
+ check_ajax_field('autocompletion_ajax1', 'xxx@example.com', 0, resolve)
+ })
+ })
+ .finally(done)
+})
diff --git a/spec/system/data_privacy_spec.rb b/spec/system/data_privacy_spec.rb
index 1d53d3d3a..7049ea42f 100644
--- a/spec/system/data_privacy_spec.rb
+++ b/spec/system/data_privacy_spec.rb
@@ -57,6 +57,22 @@ RSpec.describe 'Data Privacy', type: :system, searchindex: true, authenticated_a
DataPrivacyTaskJob.perform_now
expect(page).to have_text('completed', wait: 5)
end
+
+ it 'deletes customer by email' do
+ visit 'system/data_privacy'
+ click '.js-new'
+
+ find(:css, '.js-input').send_keys(customer.email)
+ expect(page).to have_css('.searchableSelect-option-text', wait: 5)
+ click '.searchableSelect-option-text'
+ fill_in 'Are you sure?', with: 'DELETE'
+ expect(page).to have_text('DELETE ORGANIZATION?', wait: 5)
+ click '.js-submit'
+
+ expect(page).to have_text('in process', wait: 5)
+ DataPrivacyTaskJob.perform_now
+ expect(page).to have_text('completed', wait: 5)
+ end
end
end
diff --git a/spec/system/js/q_unit_spec.rb b/spec/system/js/q_unit_spec.rb
index 0f675c183..45be92d62 100644
--- a/spec/system/js/q_unit_spec.rb
+++ b/spec/system/js/q_unit_spec.rb
@@ -14,8 +14,8 @@ RSpec.describe 'QUnit', type: :system, authenticated_as: false, set_up: true, we
def async_q_unit_tests(*args)
q_unit_tests(*args) do
- wait(10, interval: 4).until_constant do
- find('.total').text
+ wait(120, interval: 3).until_constant do
+ page.has_css?('.total', wait: 0) ? find('.total').text : nil
end
end
end
@@ -131,6 +131,17 @@ RSpec.describe 'QUnit', type: :system, authenticated_as: false, set_up: true, we
end
end
+ context 'Form AJAX', searchindex: true do
+ before do
+ configure_elasticsearch
+ rebuild_searchindex
+ end
+
+ it 'autocompletion ajax' do
+ async_q_unit_tests('form_autocompletion_ajax')
+ end
+ end
+
context 'Table' do
it 'Base' do