ticket_state_spec.rb 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Manage > Ticket States', type: :system do
  4. describe 'create new state' do
  5. let(:new_state_name) { Faker::Lorem.unique.word.capitalize }
  6. before do
  7. visit 'manage/ticket_states'
  8. click_on 'New Ticket State'
  9. end
  10. it 'creates a new state' do
  11. fill_in 'Name', with: new_state_name
  12. find('[name=state_type_id]').select('pending reminder')
  13. scroll_into_view('button.js-submit', position: :bottom)
  14. click_on 'Submit'
  15. within :active_content do
  16. expect(find("tr[data-id='#{Ticket::State.last.id}']")).to have_text(new_state_name)
  17. end
  18. end
  19. it 'does not allow to select merged type' do
  20. expect(page).to have_no_css('option', text: 'merged')
  21. end
  22. end
  23. describe 'managing existing states' do
  24. let(:state) { Ticket::State.find_by name: state_name }
  25. let(:state_row) { find("tr[data-id='#{state.id}']") }
  26. before do
  27. visit 'manage/ticket_states'
  28. end
  29. context 'when state is merged' do
  30. let(:state_name) { 'merged' }
  31. it 'does not open edit dialog' do
  32. state_row.click
  33. expect(page).to have_no_text('Edit:')
  34. end
  35. it 'has no additional actions' do
  36. expect(state_row).to have_no_css('[data-table-action]', visible: :all)
  37. end
  38. end
  39. context 'when state is non-merged' do
  40. let(:state_name) { 'pending close' }
  41. it 'allows to edit the state' do
  42. new_state_name = Faker::Lorem.unique.word
  43. state_row.click
  44. in_modal do
  45. fill_in 'Name', with: new_state_name
  46. click_on 'Submit'
  47. end
  48. expect(page).to have_text new_state_name
  49. end
  50. it 'has additional actions' do
  51. expect(state_row).to have_css('[data-table-action]', count: 3, visible: :all)
  52. end
  53. end
  54. end
  55. end