2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2020-08-17 13:37:55 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2021-09-22 06:53:16 +00:00
|
|
|
RSpec.describe 'Caller log', type: %i[system request] do
|
2020-08-17 13:37:55 +00:00
|
|
|
let(:admin) do
|
|
|
|
create(:admin, groups: Group.all)
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:customer) { create(:customer, phone: '0190333') }
|
|
|
|
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
direction: 'in',
|
|
|
|
from: '0190333',
|
|
|
|
to: '0190111',
|
|
|
|
callId: '111',
|
|
|
|
cause: 'busy'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def prepare
|
|
|
|
Setting.set('cti_integration', true)
|
|
|
|
Setting.set('cti_token', 'token1234')
|
|
|
|
current_user.update(phone: '0190111')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without active tickets' do
|
|
|
|
it 'checks opening of the ticket creation screen after phone call inbound' do
|
|
|
|
prepare
|
|
|
|
|
|
|
|
travel(-2.months)
|
|
|
|
create(:ticket, customer: customer)
|
|
|
|
travel_back
|
|
|
|
|
|
|
|
visit 'cti'
|
|
|
|
|
|
|
|
post "#{Capybara.app_host}/api/v1/cti/token1234", params: params.merge(event: 'newCall'), as: :json
|
2021-07-16 13:38:01 +00:00
|
|
|
post "#{Capybara.app_host}/api/v1/cti/token1234", params: params.merge(event: 'answer', answeringNumber: '0190111'), as: :json
|
2020-08-17 13:37:55 +00:00
|
|
|
|
|
|
|
within(:active_content) do
|
|
|
|
expect(page).to have_text('New Ticket', wait: 5)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with active tickets' do
|
|
|
|
it 'checks opening of the user profile screen after phone call inbound with tickets in the last month' do
|
|
|
|
prepare
|
|
|
|
|
|
|
|
create(:ticket, customer: customer)
|
|
|
|
|
|
|
|
visit 'cti'
|
|
|
|
|
|
|
|
post "#{Capybara.app_host}/api/v1/cti/token1234", params: params.merge(event: 'newCall'), as: :json
|
2021-07-16 13:38:01 +00:00
|
|
|
post "#{Capybara.app_host}/api/v1/cti/token1234", params: params.merge(event: 'answer', answeringNumber: '0190111'), as: :json
|
2020-08-17 13:37:55 +00:00
|
|
|
|
|
|
|
within(:active_content) do
|
|
|
|
expect(page).to have_text(customer.fullname, wait: 5)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|