avatar_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Profile > Avatar', type: :system do
  4. let(:image) { Rails.root.join('spec/fixtures/files/image/squares.png') }
  5. before do
  6. visit '#profile/avatar'
  7. end
  8. it 'can re-upload the same image afterwards (#5456)' do
  9. within :active_content do
  10. # Upload an image.
  11. find('input.js-upload', visible: :all).set(image)
  12. end
  13. in_modal do
  14. click_on 'Save'
  15. end
  16. within :active_content do
  17. # Simulate hover to make the delete button visible and click on it.
  18. page.execute_script("$('.avatar-delete').css('visibility', 'visible').click()")
  19. prompt = page.driver.browser.switch_to.alert
  20. prompt.accept
  21. await_empty_ajax_queue
  22. # The input should be empty now.
  23. expect(find('input.js-upload', visible: :all).value).to be_empty
  24. # Re-upload the same image.
  25. find('input.js-upload', visible: :all).set(image)
  26. end
  27. in_modal do
  28. click_on 'Save'
  29. end
  30. within :active_content do
  31. expect(page).to have_css('.avatar-holder .avatar')
  32. end
  33. end
  34. end