sipgate_spec.rb 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Caller log', type: :system, authenticated_as: :agent do
  4. let(:agent_phone) { '0190111' }
  5. let(:customer_phone) { '0190333' }
  6. let(:agent) { create(:agent, phone: agent_phone) }
  7. let(:customer) { create(:customer, phone: customer_phone) }
  8. let(:sipgate_on) { true }
  9. let(:params) do
  10. {
  11. direction: 'in',
  12. from: customer.phone,
  13. to: agent_phone,
  14. callId: '111',
  15. cause: 'busy',
  16. }
  17. end
  18. let(:first_params) { params.merge(event: 'newCall') }
  19. let(:second_params) { params.merge(event: 'hangup') }
  20. let(:place_call) do
  21. post "#{Capybara.app_host}/api/v1/sipgate/in", params: first_params
  22. post "#{Capybara.app_host}/api/v1/sipgate/in", params: second_params
  23. end
  24. let(:prepare) do
  25. Setting.set('sipgate_integration', sipgate_on)
  26. end
  27. before { prepare }
  28. context 'when sipgate integration is on' do
  29. it 'shows the phone menu in nav bar' do
  30. within '#navigation .menu' do
  31. expect(page).to have_link('Phone', href: '#cti')
  32. end
  33. end
  34. end
  35. context 'when sipgate integration is not on' do
  36. let(:sipgate_on) { false }
  37. it 'does not show the phone menu in nav bar' do
  38. within '#navigation .menu' do
  39. expect(page).to have_no_link('Phone', href: '#cti')
  40. end
  41. end
  42. end
  43. context 'with incoming call' do
  44. before do
  45. visit 'cti'
  46. place_call
  47. end
  48. it 'increments the call counter notification badge' do
  49. within '[href="#cti"].js-phoneMenuItem' do
  50. counter = find('.counter')
  51. expect(counter).to have_content 1
  52. end
  53. end
  54. end
  55. context 'when incoming call is checked' do
  56. before do
  57. visit 'cti'
  58. place_call
  59. end
  60. it 'clears the call counter notification badge' do
  61. within :active_content do
  62. find('.table-checkbox input.js-check', visible: :all).check allow_label_click: true
  63. end
  64. within '[href="#cti"].js-phoneMenuItem' do
  65. expect(page).to have_no_selector('.counter')
  66. end
  67. end
  68. end
  69. end