123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- require 'rails_helper'
- RSpec.describe 'Dashboard', type: :system, authenticated_as: true do
- 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
- 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
- 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
- expect(page).to have_text('Sign in', wait: 15)
- 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' })
- expect(page).to have_text('Sign in', wait: 15)
- 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
- expect(page).to have_text('Sign in', wait: 15)
- 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
- expect(page).to have_text('Sign in', wait: 15)
- 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
- expect(page).to have_text('Sign in', wait: 15)
- 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)
- expect(page).to have_text('Sign in', wait: 15)
- end
- end
- end
- end
|