2019-01-24 08:58:58 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2020-06-18 11:51:25 +00:00
|
|
|
RSpec.describe 'Dashboard', type: :system, authenticated_as: true do
|
2019-01-24 08:58:58 +00:00
|
|
|
|
|
|
|
it 'shows default widgets' do
|
|
|
|
visit 'dashboard'
|
|
|
|
|
|
|
|
expect(page).to have_css('.stat-widgets')
|
|
|
|
expect(page).to have_css('.ticket_waiting_time > div > div.stat-title', text: /∅ Waiting time today/i)
|
|
|
|
expect(page).to have_css('.ticket_escalation > div > div.stat-title', text: /Mood/i)
|
|
|
|
expect(page).to have_css('.ticket_channel_distribution > div > div.stat-title', text: /Channel Distribution/i)
|
|
|
|
expect(page).to have_css('.ticket_load_measure > div > div.stat-title', text: /Assigned/i)
|
|
|
|
expect(page).to have_css('.ticket_in_process > div > div.stat-title', text: /Your tickets in process/i)
|
|
|
|
expect(page).to have_css('.ticket_reopen > div > div.stat-title', text: /Reopening rate/i)
|
|
|
|
end
|
2020-12-07 08:29:54 +00:00
|
|
|
|
|
|
|
context 'when customer role is named different', authenticated_as: :authenticate do
|
|
|
|
def authenticate
|
|
|
|
Role.find_by(name: 'Customer').update(name: 'Public')
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'invites a customer user' do
|
|
|
|
visit 'dashboard'
|
|
|
|
find('div.tab[data-area=first-steps-widgets]').click
|
|
|
|
find('.js-inviteCustomer').click
|
|
|
|
fill_in 'Firstname', with: 'Nick'
|
|
|
|
fill_in 'Lastname', with: 'Braun'
|
|
|
|
fill_in 'Email', with: 'nick.braun@zammad.org'
|
|
|
|
click_on 'Invite'
|
|
|
|
await_empty_ajax_queue
|
|
|
|
expect(User.find_by(firstname: 'Nick').roles).to eq([Role.find_by(name: 'Public')])
|
|
|
|
end
|
|
|
|
end
|
2021-04-22 07:17:01 +00:00
|
|
|
|
|
|
|
context 'Session Timeout' do
|
|
|
|
let(:admin) { create(:admin) }
|
|
|
|
let(:agent) { create(:agent) }
|
|
|
|
let(:customer) { create(:customer) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
ensure_websocket(check_if_pinged: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Logout by frontend plugin - Default', authenticated_as: :authenticate do
|
|
|
|
def authenticate
|
|
|
|
Setting.set('session_timeout', { default: '1' })
|
|
|
|
admin
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does logout user' do
|
2021-04-26 12:17:44 +00:00
|
|
|
expect(page).to have_text('Sign in', wait: 20)
|
2021-04-22 07:17:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not logout user', authenticated_as: :admin do
|
|
|
|
sleep 1.5
|
|
|
|
expect(page).to have_no_text('Sign in', wait: 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Logout by frontend plugin - Setting change', authenticated_as: :admin do
|
|
|
|
it 'does logout user' do
|
|
|
|
expect(page).to have_no_text('Sign in')
|
|
|
|
Setting.set('session_timeout', { default: '1' })
|
2021-04-26 12:17:44 +00:00
|
|
|
expect(page).to have_text('Sign in', wait: 20)
|
2021-04-22 07:17:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Logout by frontend plugin - Admin', authenticated_as: :authenticate do
|
|
|
|
def authenticate
|
|
|
|
Setting.set('session_timeout', { admin: '1', default: '1000' })
|
|
|
|
admin
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does logout user' do
|
2021-04-26 12:17:44 +00:00
|
|
|
expect(page).to have_text('Sign in', wait: 20)
|
2021-04-22 07:17:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Logout by frontend plugin - Agent', authenticated_as: :authenticate do
|
|
|
|
def authenticate
|
|
|
|
Setting.set('session_timeout', { 'ticket.agent': '1', default: '1000' })
|
|
|
|
agent
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does logout user' do
|
2021-04-26 12:17:44 +00:00
|
|
|
expect(page).to have_text('Sign in', wait: 20)
|
2021-04-22 07:17:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Logout by frontend plugin - Customer', authenticated_as: :authenticate do
|
|
|
|
def authenticate
|
|
|
|
Setting.set('session_timeout', { 'ticket.customer': '1', default: '1000' })
|
|
|
|
customer
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does logout user' do
|
2021-04-26 12:17:44 +00:00
|
|
|
expect(page).to have_text('Sign in', wait: 20)
|
2021-04-22 07:17:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Logout by SessionTimeoutJob - destroy_session' do
|
|
|
|
it 'does logout user', authenticated_as: :admin do
|
|
|
|
|
|
|
|
# because of the websocket server running in the same
|
|
|
|
# process and the checks in the frontend it is really
|
|
|
|
# hard test the SessionTimeoutJob.perform_now here
|
|
|
|
# so we only check the session killing code and use
|
|
|
|
# backend tests for the rest
|
|
|
|
session = ActiveRecord::SessionStore::Session.all.detect { |s| s.data['user_id'] == admin.id }
|
|
|
|
SessionTimeoutJob.destroy_session(admin, session)
|
2021-04-26 12:17:44 +00:00
|
|
|
expect(page).to have_text('Sign in', wait: 20)
|
2021-04-22 07:17:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-01-24 08:58:58 +00:00
|
|
|
end
|