2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2019-01-24 08:58:58 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2021-07-22 14:03:33 +00:00
|
|
|
RSpec.describe 'Dashboard', type: :system do
|
2019-01-24 08:58:58 +00:00
|
|
|
|
|
|
|
it 'shows default widgets' do
|
|
|
|
visit 'dashboard'
|
|
|
|
|
|
|
|
expect(page).to have_css('.stat-widgets')
|
2021-05-12 11:37:44 +00:00
|
|
|
expect(page).to have_css('.ticket_waiting_time > div > div.stat-title', text: %r{∅ Waiting time today}i)
|
|
|
|
expect(page).to have_css('.ticket_escalation > div > div.stat-title', text: %r{Mood}i)
|
|
|
|
expect(page).to have_css('.ticket_channel_distribution > div > div.stat-title', text: %r{Channel Distribution}i)
|
|
|
|
expect(page).to have_css('.ticket_load_measure > div > div.stat-title', text: %r{Assigned}i)
|
2021-12-10 14:00:59 +00:00
|
|
|
expect(page).to have_css('.ticket_in_process > div > div.stat-title', text: %r{My tickets in process}i)
|
2021-05-12 11:37:44 +00:00
|
|
|
expect(page).to have_css('.ticket_reopen > div > div.stat-title', text: %r{Reopening rate}i)
|
2019-01-24 08:58:58 +00:00
|
|
|
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'
|
|
|
|
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)
|
2021-06-15 06:26:52 +00:00
|
|
|
sleep 3 # fast relog causes raise conditions in websocket server
|
2021-04-22 07:17:01 +00:00
|
|
|
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-12-15 21:00:53 +00:00
|
|
|
expect(page).to have_text('Due to inactivity, you will be automatically logged out within the next 30 seconds.', wait: 20)
|
|
|
|
expect(page).to have_text('Due to inactivity, you have been automatically logged out.', wait: 20)
|
2021-04-22 07:17:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not logout user', authenticated_as: :admin do
|
|
|
|
sleep 1.5
|
2021-12-15 21:00:53 +00:00
|
|
|
expect(page).to have_no_text('Due to inactivity, you have been automatically logged out.', wait: 0)
|
2021-04-22 07:17:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Logout by frontend plugin - Setting change', authenticated_as: :admin do
|
|
|
|
it 'does logout user' do
|
2021-12-15 21:00:53 +00:00
|
|
|
expect(page).to have_no_text('Due to inactivity, you have been automatically logged out.')
|
2021-04-22 07:17:01 +00:00
|
|
|
Setting.set('session_timeout', { default: '1' })
|
2021-12-15 21:00:53 +00:00
|
|
|
expect(page).to have_text('Due to inactivity, you have been automatically logged out.', 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-12-15 21:00:53 +00:00
|
|
|
expect(page).to have_text('Due to inactivity, you have been automatically logged out.', 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-12-15 21:00:53 +00:00
|
|
|
expect(page).to have_text('Due to inactivity, you have been automatically logged out.', 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-12-15 21:00:53 +00:00
|
|
|
expect(page).to have_text('Due to inactivity, you have been automatically logged out.', wait: 20)
|
2021-04-22 07:17:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-11 12:17:25 +00:00
|
|
|
context 'Logout by SessionTimeoutJob - frontend_timeout' do
|
2021-04-22 07:17:01 +00:00
|
|
|
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
|
2021-06-11 12:17:25 +00:00
|
|
|
# backend tests for the reset
|
2021-04-22 07:17:01 +00:00
|
|
|
session = ActiveRecord::SessionStore::Session.all.detect { |s| s.data['user_id'] == admin.id }
|
2021-06-11 12:17:25 +00:00
|
|
|
SessionTimeoutJob::Session.new(session).frontend_timeout
|
2021-12-15 21:00:53 +00:00
|
|
|
expect(page).to have_text('Due to inactivity, you have been automatically logged out.', wait: 20)
|
2021-04-22 07:17:01 +00:00
|
|
|
end
|
|
|
|
end
|
2021-06-08 08:31:28 +00:00
|
|
|
|
|
|
|
context 'Logout by frontend plugin - Fallback from admin to default', authenticated_as: :authenticate do
|
|
|
|
def authenticate
|
|
|
|
Setting.set('session_timeout', { admin: '0', default: '1000' })
|
|
|
|
admin
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not logout user', authenticated_as: :admin do
|
|
|
|
sleep 1.5
|
2021-12-15 21:00:53 +00:00
|
|
|
expect(page).to have_no_text('Due to inactivity, you have been automatically logged out.', wait: 0)
|
2021-06-08 08:31:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Logout by frontend plugin - No logout because timeouts are disabled', authenticated_as: :authenticate do
|
|
|
|
def authenticate
|
|
|
|
Setting.set('session_timeout', { admin: '0', default: '0' })
|
|
|
|
admin
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not logout user', authenticated_as: :admin do
|
|
|
|
sleep 1.5
|
2021-12-15 21:00:53 +00:00
|
|
|
expect(page).to have_no_text('Due to inactivity, you have been automatically logged out.', wait: 0)
|
2021-06-08 08:31:28 +00:00
|
|
|
end
|
|
|
|
end
|
2021-04-22 07:17:01 +00:00
|
|
|
end
|
2019-01-24 08:58:58 +00:00
|
|
|
end
|