2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-10-12 14:16:59 +00:00
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2021-11-16 07:51:17 +00:00
|
|
|
RSpec.describe 'Caller log', type: :system, authenticated_as: :authenticate do
|
2021-10-12 14:16:59 +00:00
|
|
|
let(:agent_phone) { '0190111' }
|
|
|
|
let(:customer_phone) { '0190333' }
|
|
|
|
let(:agent) { create(:agent, phone: agent_phone) }
|
|
|
|
let(:customer) { create(:customer, phone: customer_phone) }
|
|
|
|
let(:sipgate_on) { true }
|
|
|
|
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
direction: 'in',
|
|
|
|
from: customer.phone,
|
|
|
|
to: agent_phone,
|
|
|
|
callId: '111',
|
|
|
|
cause: 'busy',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:first_params) { params.merge(event: 'newCall') }
|
|
|
|
let(:second_params) { params.merge(event: 'hangup') }
|
|
|
|
|
|
|
|
let(:place_call) do
|
|
|
|
post "#{Capybara.app_host}/api/v1/sipgate/in", params: first_params
|
|
|
|
post "#{Capybara.app_host}/api/v1/sipgate/in", params: second_params
|
|
|
|
end
|
|
|
|
|
2021-11-16 07:51:17 +00:00
|
|
|
def authenticate
|
2021-10-12 14:16:59 +00:00
|
|
|
Setting.set('sipgate_integration', sipgate_on)
|
2021-11-16 07:51:17 +00:00
|
|
|
agent
|
2021-10-12 14:16:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when sipgate integration is on' do
|
|
|
|
it 'shows the phone menu in nav bar' do
|
|
|
|
|
|
|
|
within '#navigation .menu' do
|
|
|
|
expect(page).to have_link('Phone', href: '#cti')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when sipgate integration is not on' do
|
|
|
|
let(:sipgate_on) { false }
|
|
|
|
|
|
|
|
it 'does not show the phone menu in nav bar' do
|
|
|
|
|
|
|
|
within '#navigation .menu' do
|
|
|
|
expect(page).to have_no_link('Phone', href: '#cti')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with incoming call' do
|
|
|
|
before do
|
|
|
|
visit 'cti'
|
|
|
|
place_call
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'increments the call counter notification badge' do
|
|
|
|
within '[href="#cti"].js-phoneMenuItem' do
|
|
|
|
counter = find('.counter')
|
|
|
|
expect(counter).to have_content 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when incoming call is checked' do
|
|
|
|
before do
|
|
|
|
visit 'cti'
|
|
|
|
place_call
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'clears the call counter notification badge' do
|
|
|
|
within :active_content do
|
|
|
|
find('.table-checkbox input.js-check', visible: :all).check allow_label_click: true
|
|
|
|
end
|
|
|
|
|
|
|
|
within '[href="#cti"].js-phoneMenuItem' do
|
|
|
|
expect(page).to have_no_selector('.counter')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|