overview_spec.rb 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Overview', type: :system do
  4. context 'when logged in as customer', authenticated_as: :customer do
  5. let!(:customer) { create(:customer) }
  6. let!(:main_overview) { create(:overview) }
  7. let!(:other_overview) do
  8. create(:overview, condition: {
  9. 'ticket.state_id' => {
  10. operator: 'is',
  11. value: Ticket::State.where(name: %w[merged]).pluck(:id),
  12. },
  13. })
  14. end
  15. it 'shows create button when customer has no tickets' do
  16. visit "ticket/view/#{main_overview.link}"
  17. within :active_content do
  18. expect(page).to have_text 'Create your first ticket'
  19. end
  20. end
  21. it 'shows overview-specific message if customer has tickets in other overview', performs_jobs: true do
  22. perform_enqueued_jobs only: TicketUserTicketCounterJob do
  23. create(:ticket, customer: customer)
  24. end
  25. visit "ticket/view/#{other_overview.link}"
  26. within :active_content do
  27. expect(page).to have_text 'You have no tickets'
  28. end
  29. end
  30. it 'replaces button with overview-specific message when customer creates a ticket', performs_jobs: true do
  31. visit "ticket/view/#{other_overview.link}"
  32. visit 'customer_ticket_new'
  33. find('[name=title]').fill_in with: 'Title'
  34. find(:richtext).send_keys 'content'
  35. find('[name=group_id]').select Group.first.name
  36. click '.js-submit'
  37. perform_enqueued_jobs only: TicketUserTicketCounterJob
  38. visit "ticket/view/#{other_overview.link}"
  39. within :active_content do
  40. expect(page).to have_text 'You have no tickets'
  41. end
  42. end
  43. end
  44. end