Fixes #5456 - Uploading an avatar is not possible if it was deleted in between.

Co-authored-by: Dusan Vuckovic <dv@zammad.com>
This commit is contained in:
Florian Liebe 2025-01-09 11:02:14 +01:00
parent 2f1d5c7f9e
commit 56f9ce78d9
2 changed files with 48 additions and 0 deletions

View file

@ -145,6 +145,8 @@ class ProfileAvatar extends App.ControllerSubContent
reader.readAsDataURL(@)
@fileInput.val('')
App.Config.set('Avatar', { prio: 1100, name: __('Avatar'), parent: '#profile', target: '#profile/avatar', controller: ProfileAvatar, permission: ['user_preferences.avatar'] }, 'NavBarProfile')
class ImageCropper extends App.ControllerModal

View file

@ -0,0 +1,46 @@
# Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
require 'rails_helper'
RSpec.describe 'Profile > Avatar', type: :system do
let(:image) { Rails.root.join('spec/fixtures/files/image/squares.png') }
before do
visit '#profile/avatar'
end
it 'can re-upload the same image afterwards (#5456)' do
within :active_content do
# Upload an image.
find('input.js-upload', visible: :all).set(image)
end
in_modal do
click_on 'Save'
end
within :active_content do
# Simulate hover to make the delete button visible and click on it.
page.execute_script("$('.avatar-delete').css('visibility', 'visible').click()")
prompt = page.driver.browser.switch_to.alert
prompt.accept
await_empty_ajax_queue
# The input should be empty now.
expect(find('input.js-upload', visible: :all).value).to be_empty
# Re-upload the same image.
find('input.js-upload', visible: :all).set(image)
end
in_modal do
click_on 'Save'
end
within :active_content do
expect(page).to have_css('.avatar-holder .avatar')
end
end
end