data_privacy_spec.rb 3.3 KB

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