data_privacy_spec.rb 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # Copyright (C) 2012-2024 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. before do
  13. visit 'system/data_privacy'
  14. ensure_websocket
  15. click '.js-new'
  16. end
  17. it 'deletes customer' do
  18. find(:css, '.js-input').send_keys(customer.firstname)
  19. expect(page).to have_css('.searchableSelect-option-text')
  20. click '.searchableSelect-option-text'
  21. fill_in 'Are you sure?', with: 'DELETE'
  22. expect(page).to have_no_text('DELETE ORGANIZATION?')
  23. click '.js-submit'
  24. expect(page).to have_text('in process')
  25. DataPrivacyTaskJob.perform_now
  26. expect(page).to have_text('completed')
  27. end
  28. context 'when customer is the single user of the organization' do
  29. let(:organization) { create(:organization) }
  30. let(:customer) { create(:customer, firstname: 'Frank2', organization: organization) }
  31. def authenticate
  32. organization
  33. customer
  34. ticket
  35. true
  36. end
  37. it 'deletes customer' do
  38. find(:css, '.js-input').send_keys(customer.firstname)
  39. expect(page).to have_css('.searchableSelect-option-text')
  40. click '.searchableSelect-option-text'
  41. fill_in 'Are you sure?', with: 'DELETE'
  42. expect(page).to have_text('DELETE ORGANIZATION?')
  43. click '.js-submit'
  44. expect(page).to have_text('in process')
  45. DataPrivacyTaskJob.perform_now
  46. expect(page).to have_text('completed')
  47. end
  48. it 'deletes customer by email' do
  49. find(:css, '.js-input').send_keys(customer.email)
  50. expect(page).to have_css('.searchableSelect-option-text')
  51. click '.searchableSelect-option-text'
  52. fill_in 'Are you sure?', with: 'DELETE'
  53. expect(page).to have_text('DELETE ORGANIZATION?')
  54. click '.js-submit'
  55. expect(page).to have_text('in process')
  56. DataPrivacyTaskJob.perform_now
  57. expect(page).to have_text('completed')
  58. end
  59. end
  60. end
  61. context 'when user profile' do
  62. it 'deletes customer' do
  63. visit "user/profile/#{customer.id}"
  64. ensure_websocket
  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. ensure_websocket
  78. click '.tabsSidebar-tab[data-tab=customer]'
  79. click 'h2.js-headline'
  80. click_on 'Delete Customer'
  81. fill_in 'Are you sure?', with: 'DELETE'
  82. click '.js-submit'
  83. expect(page).to have_text('in process')
  84. DataPrivacyTaskJob.perform_now
  85. expect(page).to have_text('completed')
  86. end
  87. end
  88. end