data_privacy_spec.rb 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Data Privacy', type: :system, searchindex: true, authenticated_as: :authenticate do
  4. before do
  5. configure_elasticsearch(rebuild: true)
  6. end
  7. let(:customer) { create(:customer, firstname: 'Frank1') }
  8. let(:ticket) { create(:ticket, customer: customer, group: Group.find_by(name: 'Users')) }
  9. def authenticate
  10. customer
  11. ticket
  12. true
  13. end
  14. context 'when data privacy admin interface' do
  15. it 'deletes customer' do
  16. visit 'system/data_privacy'
  17. click '.js-new'
  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. visit 'system/data_privacy'
  39. click '.js-new'
  40. find(:css, '.js-input').send_keys(customer.firstname)
  41. expect(page).to have_css('.searchableSelect-option-text')
  42. click '.searchableSelect-option-text'
  43. fill_in 'Are you sure?', with: 'DELETE'
  44. expect(page).to have_text('DELETE ORGANIZATION?')
  45. click '.js-submit'
  46. expect(page).to have_text('in process')
  47. DataPrivacyTaskJob.perform_now
  48. expect(page).to have_text('completed')
  49. end
  50. it 'deletes customer by email' do
  51. visit 'system/data_privacy'
  52. click '.js-new'
  53. find(:css, '.js-input').send_keys(customer.email)
  54. expect(page).to have_css('.searchableSelect-option-text')
  55. click '.searchableSelect-option-text'
  56. fill_in 'Are you sure?', with: 'DELETE'
  57. expect(page).to have_text('DELETE ORGANIZATION?')
  58. click '.js-submit'
  59. expect(page).to have_text('in process')
  60. DataPrivacyTaskJob.perform_now
  61. expect(page).to have_text('completed')
  62. end
  63. end
  64. end
  65. context 'when user profile' do
  66. it 'deletes customer' do
  67. visit "user/profile/#{customer.id}"
  68. click '.dropdown--actions'
  69. click_on 'Delete'
  70. fill_in 'Are you sure?', with: 'DELETE'
  71. click '.js-submit'
  72. expect(page).to have_text('in process')
  73. DataPrivacyTaskJob.perform_now
  74. expect(page).to have_text('completed')
  75. end
  76. end
  77. context 'when ticket zoom' do
  78. it 'deletes customer' do
  79. visit "ticket/zoom/#{ticket.id}"
  80. click '.tabsSidebar-tab[data-tab=customer]'
  81. click 'h2.js-headline'
  82. click_on 'Delete Customer'
  83. fill_in 'Are you sure?', with: 'DELETE'
  84. click '.js-submit'
  85. expect(page).to have_text('in process')
  86. DataPrivacyTaskJob.perform_now
  87. expect(page).to have_text('completed')
  88. end
  89. end
  90. end