organization_profile_spec.rb 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Organization Profile', type: :system do
  4. let(:organization) { create(:organization) }
  5. it 'does show the edit link' do
  6. visit "#organization/profile/#{organization.id}"
  7. click '#userAction label'
  8. click_on 'Edit'
  9. modal_ready
  10. end
  11. context 'with active attribute' do
  12. it 'shows regular building icon if organization is active' do
  13. organization = create(:organization, active: true)
  14. visit "#organization/profile/#{organization.id}"
  15. within '.avatar--organization' do
  16. expect(page).to have_css('.icon-organization')
  17. end
  18. end
  19. it 'shows crossed out building icon if organization is inactive' do
  20. visit "#organization/profile/#{organization.id}"
  21. within '.avatar--organization' do
  22. expect(page).to have_no_css('.icon-inactive')
  23. end
  24. end
  25. end
  26. context 'with vip attribute' do
  27. it 'shows vip crown if organization is vip' do
  28. organization = create(:organization, vip: true)
  29. visit "#organization/profile/#{organization.id}"
  30. within '.avatar--organization' do
  31. expect(page).to have_css('.icon-crown-silver')
  32. end
  33. end
  34. it 'does not show vip crown if organization is not vip' do
  35. visit "#organization/profile/#{organization.id}"
  36. within '.avatar--organization' do
  37. expect(page).to have_no_css('.icon-crown-silver')
  38. end
  39. end
  40. end
  41. context 'with members section' do
  42. let(:members) { organization.members.reorder(id: :asc) }
  43. before do
  44. create_list(:customer, 50, organization: organization)
  45. visit "#organization/profile/#{organization.id}"
  46. end
  47. it 'shows first 10 members and loads more on demand' do
  48. expect(page).to have_text(members[9].fullname)
  49. expect(page).to have_no_text(members[10].fullname)
  50. click '.js-showMoreMembers'
  51. expect(page).to have_text(members[10].fullname)
  52. end
  53. end
  54. context 'when ticket changes in organization profile', authenticated_as: :authenticate do
  55. let(:ticket) { create(:ticket, title: SecureRandom.uuid, customer: create(:customer, :with_org), group: Group.first) }
  56. def authenticate
  57. ticket
  58. true
  59. end
  60. before do
  61. visit "#organization/profile/#{ticket.customer.organization.id}"
  62. end
  63. it 'does update when ticket changes' do
  64. expect(page).to have_text(ticket.title)
  65. ticket.update(title: SecureRandom.uuid)
  66. expect(page).to have_text(ticket.title)
  67. end
  68. end
  69. end