account_spec.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Mobile > App Account Page', app: :mobile, type: :system do
  4. describe 'language selection' do
  5. before do
  6. visit '/account'
  7. end
  8. it 'user can change language' do
  9. locale = find_treeselect('Language')
  10. locale.select_option('Deutsch')
  11. expect(page).to have_text('Sprache')
  12. end
  13. end
  14. describe 'avatar handling', authenticated_as: :agent do
  15. let(:agent) { create(:agent, firstname: 'Jane', lastname: 'Doe') }
  16. before do
  17. visit '/account/avatar'
  18. end
  19. it 'user can upload avatar' do
  20. expect(page).to have_text('JD')
  21. find('input[data-test-id="fileGalleryInput"]', visible: :all).set(Rails.root.join('test/data/image/1000x1000.png'))
  22. expect(page).to have_css('.vue-advanced-cropper')
  23. click_on 'Save'
  24. wait.until { Avatar.last.present? }
  25. store = Store.find(Avatar.last.store_resize_id)
  26. img_url = "data:#{store.preferences['Mime-Type']};base64,#{Base64.strict_encode64(store.content)}"
  27. avatar_element_style = find('[data-test-id="common-avatar"]').style('background-image')
  28. expect(avatar_element_style['background-image']).to eq("url(\"#{img_url}\")")
  29. end
  30. end
  31. end