data_privacy_spec.rb 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Data Privacy', authenticated_as: :authenticate, type: :system do
  4. let(:customer) { create(:customer, firstname: 'Frank1') }
  5. let(:ticket) { create(:ticket, customer: customer, group: Group.find_by(name: 'Users')) }
  6. def authenticate
  7. customer
  8. ticket
  9. true
  10. end
  11. context 'when data privacy admin interface' do
  12. it 'deletes customer' do
  13. visit 'system/data_privacy'
  14. click '.js-new'
  15. find(:css, '.js-input').send_keys(customer.firstname)
  16. expect(page).to have_css('.searchableSelect-option-text')
  17. click '.searchableSelect-option-text'
  18. fill_in 'Are you sure?', with: 'DELETE'
  19. expect(page).to have_no_text('DELETE ORGANIZATION?')
  20. click '.js-submit'
  21. expect(page).to have_text('in process')
  22. DataPrivacyTaskJob.perform_now
  23. expect(page).to have_text('completed')
  24. end
  25. context 'when customer is the single user of the organization' do
  26. let(:organization) { create(:organization) }
  27. let(:customer) { create(:customer, firstname: 'Frank2', organization: organization) }
  28. def authenticate
  29. organization
  30. customer
  31. ticket
  32. true
  33. end
  34. it 'deletes customer' do
  35. visit 'system/data_privacy'
  36. click '.js-new'
  37. find(:css, '.js-input').send_keys(customer.firstname)
  38. expect(page).to have_css('.searchableSelect-option-text')
  39. click '.searchableSelect-option-text'
  40. fill_in 'Are you sure?', with: 'DELETE'
  41. expect(page).to have_text('DELETE ORGANIZATION?')
  42. click '.js-submit'
  43. expect(page).to have_text('in process')
  44. DataPrivacyTaskJob.perform_now
  45. expect(page).to have_text('completed')
  46. end
  47. it 'deletes customer by email' do
  48. visit 'system/data_privacy'
  49. click '.js-new'
  50. find(:css, '.js-input').send_keys(customer.email)
  51. expect(page).to have_css('.searchableSelect-option-text')
  52. click '.searchableSelect-option-text'
  53. fill_in 'Are you sure?', with: 'DELETE'
  54. expect(page).to have_text('DELETE ORGANIZATION?')
  55. click '.js-submit'
  56. expect(page).to have_text('in process')
  57. DataPrivacyTaskJob.perform_now
  58. expect(page).to have_text('completed')
  59. end
  60. end
  61. end
  62. context 'when user profile' do
  63. it 'deletes customer' do
  64. visit "user/profile/#{customer.id}"
  65. click '.dropdown--actions'
  66. click_on 'Delete'
  67. fill_in 'Are you sure?', with: 'DELETE'
  68. click '.js-submit'
  69. expect(page).to have_text('in process')
  70. DataPrivacyTaskJob.perform_now
  71. expect(page).to have_text('completed')
  72. end
  73. end
  74. context 'when ticket zoom' do
  75. it 'deletes customer' do
  76. visit "ticket/zoom/#{ticket.id}"
  77. click '.tabsSidebar-tab[data-tab=customer]'
  78. click 'h2.js-headline'
  79. click_on 'Delete Customer'
  80. fill_in 'Are you sure?', with: 'DELETE'
  81. click '.js-submit'
  82. expect(page).to have_text('in process')
  83. DataPrivacyTaskJob.perform_now
  84. expect(page).to have_text('completed')
  85. end
  86. end
  87. end