2021-08-16 14:17:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Overview', type: :system do
|
|
|
|
context 'when logged in as customer', authenticated_as: :customer do
|
|
|
|
let!(:customer) { create(:customer) }
|
|
|
|
let!(:main_overview) { create(:overview) }
|
|
|
|
let!(:other_overview) do
|
|
|
|
create(:overview, condition: {
|
|
|
|
'ticket.state_id' => {
|
|
|
|
operator: 'is',
|
|
|
|
value: Ticket::State.where(name: %w[merged]).pluck(:id),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows create button when customer has no tickets' do
|
|
|
|
visit "ticket/view/#{main_overview.link}"
|
|
|
|
|
|
|
|
within :active_content do
|
|
|
|
expect(page).to have_text 'Create your first ticket'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-30 07:25:13 +00:00
|
|
|
def authenticate
|
|
|
|
Setting.set('customer_ticket_create', false)
|
|
|
|
customer
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show create button when ticket creation via web is disabled', authenticated_as: :authenticate do
|
|
|
|
visit "ticket/view/#{main_overview.link}"
|
|
|
|
|
|
|
|
within :active_content do
|
|
|
|
expect(page).to have_text 'You currently don\'t have any tickets.'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-08-16 14:17:20 +00:00
|
|
|
it 'shows overview-specific message if customer has tickets in other overview', performs_jobs: true do
|
|
|
|
perform_enqueued_jobs only: TicketUserTicketCounterJob do
|
|
|
|
create(:ticket, customer: customer)
|
|
|
|
end
|
|
|
|
|
|
|
|
visit "ticket/view/#{other_overview.link}"
|
|
|
|
|
|
|
|
within :active_content do
|
|
|
|
expect(page).to have_text 'You have no tickets'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'replaces button with overview-specific message when customer creates a ticket', performs_jobs: true do
|
|
|
|
visit "ticket/view/#{other_overview.link}"
|
|
|
|
visit 'customer_ticket_new'
|
|
|
|
|
|
|
|
find('[name=title]').fill_in with: 'Title'
|
|
|
|
find(:richtext).send_keys 'content'
|
|
|
|
find('[name=group_id]').select Group.first.name
|
|
|
|
click '.js-submit'
|
|
|
|
|
|
|
|
perform_enqueued_jobs only: TicketUserTicketCounterJob
|
|
|
|
|
|
|
|
visit "ticket/view/#{other_overview.link}"
|
|
|
|
within :active_content do
|
|
|
|
expect(page).to have_text 'You have no tickets'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|