sla_spec.rb 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Manage > Sla', type: :system do
  4. before do
  5. ensure_websocket do
  6. visit 'manage/slas'
  7. end
  8. end
  9. it 'shows correct required behaviour for checkboxes' do
  10. page.find('.js-new').click
  11. # enable all checkboxes
  12. page.find('input#update_time', visible: false).find(:xpath, './/..').click
  13. page.find('input#solution_time', visible: false).find(:xpath, './/..').click
  14. # check if required
  15. expect(page.find('input[name=first_response_time_in_text]')[:required]).to eq('true')
  16. expect(page.find('input[name=update_time_in_text]')[:required]).to eq('true')
  17. expect(page.find('input[name=solution_time_in_text]')[:required]).to eq('true')
  18. # drop all checkboxes
  19. page.find('input#first_response_time', visible: false).find(:xpath, './/..').click
  20. page.find('input#update_time', visible: false).find(:xpath, './/..').click
  21. page.find('input#solution_time', visible: false).find(:xpath, './/..').click
  22. # check if optional
  23. expect(page.find('input[name=first_response_time_in_text]')[:required]).not_to eq('true')
  24. expect(page.find('input[name=update_time_in_text]')[:required]).not_to eq('true')
  25. expect(page.find('input[name=solution_time_in_text]')[:required]).not_to eq('true')
  26. end
  27. describe 'for saved entry', authenticated_as: :authenticate do
  28. def authenticate
  29. create(:sla, name: 'special sla', first_response_time: 3600, update_time: 3600, solution_time: 3600)
  30. true
  31. end
  32. it 'shows correct required behaviour for checkboxes' do
  33. page.find('.js-edit').click
  34. # check if required
  35. expect(page.find('input[name=first_response_time_in_text]')[:required]).to eq('true')
  36. expect(page.find('input[name=update_time_in_text]')[:required]).to eq('true')
  37. expect(page.find('input[name=solution_time_in_text]')[:required]).to eq('true')
  38. # drop all checkboxes
  39. page.find('input#first_response_time', visible: false).find(:xpath, './/..').click
  40. page.find('input#update_time', visible: false).find(:xpath, './/..').click
  41. page.find('input#solution_time', visible: false).find(:xpath, './/..').click
  42. # check if optional
  43. expect(page.find('input[name=first_response_time_in_text]')[:required]).not_to eq('true')
  44. expect(page.find('input[name=update_time_in_text]')[:required]).not_to eq('true')
  45. expect(page.find('input[name=solution_time_in_text]')[:required]).not_to eq('true')
  46. end
  47. end
  48. end