sla_spec.rb 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://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.first('.js-updateTypeSelector', visible: false).click
  14. page.find('input#solution_time', visible: false).find(:xpath, './/..').click
  15. # check if required
  16. expect(page.find('input[name=first_response_time_in_text]')[:required]).to eq('true')
  17. expect(page.find('input[name=update_time_in_text]')[:required]).to eq('true')
  18. expect(page.find('input[name=solution_time_in_text]')[:required]).to eq('true')
  19. # drop all checkboxes
  20. page.find('input#first_response_time', visible: false).find(:xpath, './/..').click
  21. page.find('input#update_time', visible: false).find(:xpath, './/..').click
  22. page.find('input#solution_time', visible: false).find(:xpath, './/..').click
  23. # check if optional
  24. expect(page.find('input[name=first_response_time_in_text]')[:required]).not_to eq('true')
  25. expect(page.find('input[name=update_time_in_text]')[:required]).not_to eq('true')
  26. expect(page.find('input[name=solution_time_in_text]')[:required]).not_to eq('true')
  27. end
  28. describe 'for saved entry', authenticated_as: :authenticate do
  29. def authenticate
  30. create(:sla, name: 'special sla', first_response_time: 3600, update_time: 3600, solution_time: 3600)
  31. true
  32. end
  33. it 'shows correct required behaviour for checkboxes' do
  34. page.find('.js-edit').click
  35. # check if required
  36. expect(page.find('input[name=first_response_time_in_text]')[:required]).to eq('true')
  37. expect(page.find('input[name=update_time_in_text]')[:required]).to eq('true')
  38. expect(page.find('input[name=solution_time_in_text]')[:required]).to eq('true')
  39. # drop all checkboxes
  40. page.find('input#first_response_time', visible: false).find(:xpath, './/..').click
  41. page.find('input#update_time', visible: false).find(:xpath, './/..').click
  42. page.find('input#solution_time', visible: false).find(:xpath, './/..').click
  43. # check if optional
  44. expect(page.find('input[name=first_response_time_in_text]')[:required]).not_to eq('true')
  45. expect(page.find('input[name=update_time_in_text]')[:required]).not_to eq('true')
  46. expect(page.find('input[name=solution_time_in_text]')[:required]).not_to eq('true')
  47. end
  48. end
  49. context 'when using custom calendars' do
  50. let(:calendar) { create(:calendar) }
  51. it 'allows to select custom calendars' do
  52. calendar
  53. page.refresh
  54. click '.js-new'
  55. in_modal do
  56. fill_in :name, with: 'SLA with custom calendar'
  57. select calendar.name, from: :calendar_id
  58. click '.js-submit'
  59. end
  60. expect(page).to have_text(calendar.name)
  61. end
  62. end
  63. end