From 56ae3eb8e830262109f4692a85be59e8fdffd336 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Fri, 18 Mar 2022 12:42:19 +0100 Subject: [PATCH] Fixes #3919 - UI is not updated right after importing users csv file. --- .../javascripts/app/controllers/user.coffee | 7 ++++ spec/system/manage/users_spec.rb | 33 ++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/app/controllers/user.coffee b/app/assets/javascripts/app/controllers/user.coffee index 54935948c..53f0dce03 100644 --- a/app/assets/javascripts/app/controllers/user.coffee +++ b/app/assets/javascripts/app/controllers/user.coffee @@ -182,6 +182,9 @@ class User extends App.ControllerSubContent 'click': edit ) + if !@subscribeId + @subscribeId = App.User.subscribe(=> @delay(@search, 220, 'search')) + search: => role_ids = [] @$('.tab.active').each( (i,d) -> @@ -239,4 +242,8 @@ class User extends App.ControllerSubContent container: @el.closest('.content') ) + release: => + if @subscribeId + App.User.unsubscribe(@subscribeId) + App.Config.set( 'User', { prio: 1000, name: __('Users'), parent: '#manage', target: '#manage/users', controller: User, permission: ['admin.user'] }, 'NavBarAdmin' ) diff --git a/spec/system/manage/users_spec.rb b/spec/system/manage/users_spec.rb index ce675c977..0d7947ea8 100644 --- a/spec/system/manage/users_spec.rb +++ b/spec/system/manage/users_spec.rb @@ -3,14 +3,15 @@ require 'rails_helper' RSpec.describe 'Manage > Users', type: :system do - describe 'switching to an alternative user', authentication_type: :form, authenticated_as: -> { original_user } do + describe 'switching to an alternative user', authentication_type: :form, authenticated_as: :authenticate do let(:original_user) { create(:admin) } let(:alternative_one_user) { create(:admin) } let(:alternative_two_user) { create(:admin) } - before do + def authenticate alternative_one_user alternative_two_user + original_user end it 'starts as original user' do @@ -91,9 +92,14 @@ RSpec.describe 'Manage > Users', type: :system do end end - describe 'show/unlock a user', authenticated_as: -> { user } do + describe 'show/unlock a user', authenticated_as: :authenticate do let(:user) { create(:admin) } - let!(:locked_user) { create(:user, login_failed: 6) } + let(:locked_user) { create(:user, login_failed: 6) } + + def authenticate + locked_user + user + end it 'check marked locked user and execute unlock action' do visit '#manage/users' @@ -242,4 +248,23 @@ RSpec.describe 'Manage > Users', type: :system do end end + + describe 'UI is not updated right after importing users csv file #3919' do + before do + visit '#manage/users' + ensure_websocket + User.csv_import( + string: File.read(Rails.root.join('spec/fixtures/csv_import/user/simple.csv')), + parse_params: { + col_sep: ';', + }, + try: false, + delete: false, + ) + end + + it 'does update the user list after import of new users' do + expect(page).to have_text('firstname-simple-import1') + end + end end