profile_spec.rb 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Desktop > Personal Setting > Profile', app: :desktop_view, authenticated_as: :agent, type: :system do
  4. let(:agent) { create(:agent) }
  5. before do
  6. visit '/'
  7. find("[aria-label=\"Avatar (#{agent.fullname})\"]").click
  8. end
  9. describe 'appearance selection' do
  10. it 'user can switch appearance' do
  11. # Switch starts on 'auto'
  12. default_theme = page.execute_script("return matchMedia('(prefers-color-scheme: dark)').matches") ? 'dark' : 'light'
  13. expect(page).to have_css("html[data-theme=#{default_theme}]")
  14. # Switch to 'dark'
  15. click_on 'Appearance'
  16. wait_for_mutation('userCurrentAppearance')
  17. expect(page).to have_css('html[data-theme=dark]')
  18. # Switch to 'light'
  19. click_on 'Appearance'
  20. wait_for_mutation('userCurrentAppearance', number: 2)
  21. expect(page).to have_css('html[data-theme=light]')
  22. end
  23. end
  24. describe 'language selection' do
  25. it 'user can change language' do
  26. click_on 'Profile settings'
  27. click_on 'Language'
  28. find('label', text: 'Your language').click
  29. find('span', text: 'Deutsch').click
  30. expect(page).to have_text('Sprache')
  31. end
  32. end
  33. describe 'overview configuration' do
  34. before do
  35. create(:overview, name: 'Test Overview')
  36. end
  37. it 'user can change overview order' do
  38. click_on 'Profile settings'
  39. click_on 'Overviews'
  40. expect(page).to have_text("Test Overview\nMy Assigned Tickets")
  41. o1 = find('li.draggable', text: 'Test Overview')
  42. o2 = find('li.draggable', text: 'My Assigned Tickets')
  43. o1.drag_to(o2)
  44. expect(page).to have_text('The order of your ticket overviews was updated.')
  45. expect(page).to have_text("My Assigned Tickets\nTest Overview")
  46. # TODO: open overviews section in desktop interface once it's implemented
  47. end
  48. end
  49. describe 'avatar handling', authenticated_as: :agent do
  50. let(:agent) { create(:agent, firstname: 'Jane', lastname: 'Doe') }
  51. it 'user can upload avatar' do
  52. click_on 'Profile settings'
  53. click_on 'Avatar'
  54. expect(page).to have_text('JD')
  55. find('input[data-test-id="fileUploadInput"]', visible: :all).set(Rails.root.join('test/data/image/1000x1000.png'))
  56. expect(page).to have_text('Avatar Preview')
  57. click_on 'Save'
  58. expect(page).to have_text('Your avatar has been uploaded')
  59. avatar_element_style = find("#user-menu span[aria-label=\"Avatar (#{agent.fullname})\"]").style('background-image')
  60. expect(avatar_element_style['background-image']).to include("/api/v1/users/image/#{Avatar.last.store_hash}")
  61. end
  62. end
  63. end