sla_spec.rb 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Copyright (C) 2012-2024 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 'open', from: 'condition::ticket.state_id::value'
  58. select calendar.name, from: :calendar_id
  59. click '.js-submit'
  60. end
  61. expect(page).to have_text(calendar.name)
  62. end
  63. end
  64. end