|
@@ -3,58 +3,89 @@
|
|
|
require 'rails_helper'
|
|
|
|
|
|
RSpec.describe 'Ticket zoom > Sidebar', authenticated_as: :user, type: :system do
|
|
|
- let(:ticket) { create(:ticket, customer: user, group: group, state: Ticket::State.find_by(name: 'closed')) }
|
|
|
- let(:user) { create(:customer, organization: create(:organization)) }
|
|
|
- let(:group) { create(:group, follow_up_possible: 'yes') }
|
|
|
+ let(:ticket) do
|
|
|
+ ticket = create(:ticket, customer: customer, group: group)
|
|
|
|
|
|
- context 'when login as customer' do
|
|
|
+ travel_to close_time do
|
|
|
+ ticket.update! state: Ticket::State.find_by(name: 'closed')
|
|
|
+ end
|
|
|
+
|
|
|
+ ticket
|
|
|
+ end
|
|
|
+
|
|
|
+ let(:customer) { create(:customer, organization: create(:organization)) }
|
|
|
+ let(:close_time) { Time.current }
|
|
|
+
|
|
|
+ describe 're-openability of a closed ticket' do
|
|
|
before do
|
|
|
- travel(-4.days)
|
|
|
visit "#ticket/zoom/#{ticket.id}"
|
|
|
- travel_back
|
|
|
end
|
|
|
|
|
|
- context 'when ticket is closed and groups.follow_up_possible is "yes"' do
|
|
|
- let(:group) { create(:group, follow_up_possible: 'yes') }
|
|
|
+ let(:state_elem) { find('.sidebar [name=state_id]') }
|
|
|
|
|
|
- it 'show sidebar not as read only' do
|
|
|
+ shared_examples 'shows sidebar as read only' do
|
|
|
+ it 'shows sidebar as read only' do
|
|
|
within(:active_content) do
|
|
|
- expect(page).to have_css('.sidebar [name=state_id]')
|
|
|
- expect(page).to have_no_css('.sidebar [name=state_id]:disabled')
|
|
|
+ expect(state_elem).to match_css(':disabled')
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
- context 'when ticket is closed and groups.follow_up_possible is "new_ticket"' do
|
|
|
- let(:group) { create(:group, follow_up_possible: 'new_ticket') }
|
|
|
-
|
|
|
- it 'show sidebar as read only' do
|
|
|
+ shared_examples 'shows sidebar as updatable' do
|
|
|
+ it 'shows sidebar as updatable' do
|
|
|
within(:active_content) do
|
|
|
- expect(page).to have_css('.sidebar [name=state_id]:disabled')
|
|
|
+ expect(state_elem).to match_css(':enabled')
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
- context 'when ticket is closed and groups.follow_up_possible is "new_ticket_after_certain_time" but reopen is possible' do
|
|
|
- let(:group) { create(:group, follow_up_possible: 'new_ticket_after_certain_time', reopen_time_in_days: 5) }
|
|
|
+ shared_examples 'check roles' do |customer:, agent:, agent_customer:|
|
|
|
+ context 'when user is customer' do
|
|
|
+ let(:user) { ticket.customer }
|
|
|
|
|
|
- it 'show sidebar not as read only' do
|
|
|
- within(:active_content) do
|
|
|
- expect(page).to have_css('.sidebar [name=state_id]')
|
|
|
- expect(page).to have_no_css('.sidebar [name=state_id]:disabled')
|
|
|
- end
|
|
|
+ include_examples customer ? 'shows sidebar as updatable' : 'shows sidebar as read only'
|
|
|
+ end
|
|
|
+
|
|
|
+ context 'when user is agent' do
|
|
|
+ let(:user) { create(:agent, groups: [ticket.group]) }
|
|
|
+
|
|
|
+ include_examples agent ? 'shows sidebar as updatable' : 'shows sidebar as read only'
|
|
|
+ end
|
|
|
+
|
|
|
+ context 'when user is agent-customer' do
|
|
|
+ let(:user) { create(:agent_and_customer) }
|
|
|
+ let(:customer) { user }
|
|
|
+
|
|
|
+ include_examples agent_customer ? 'shows sidebar as updatable' : 'shows sidebar as read only'
|
|
|
end
|
|
|
end
|
|
|
|
|
|
- context 'when ticket is closed and groups.follow_up_possible is "new_ticket_after_certain_time" reopen is not possible' do
|
|
|
- let(:group) { create(:group, follow_up_possible: 'new_ticket_after_certain_time', reopen_time_in_days: 4) }
|
|
|
+ context 'when ticket is closed and groups.follow_up_possible is "yes"' do
|
|
|
+ let(:group) { create(:group, follow_up_possible: 'yes') }
|
|
|
|
|
|
- it 'show sidebar as read only' do
|
|
|
- within(:active_content) do
|
|
|
- expect(page).to have_css('.sidebar [name=state_id]:disabled')
|
|
|
- end
|
|
|
+ include_examples 'check roles', customer: true, agent: true, agent_customer: true
|
|
|
+ end
|
|
|
+
|
|
|
+ context 'when ticket is closed and groups.follow_up_possible is "new_ticket"' do
|
|
|
+ let(:group) { create(:group, follow_up_possible: 'new_ticket') }
|
|
|
+
|
|
|
+ include_examples 'check roles', customer: false, agent: true, agent_customer: false
|
|
|
+ end
|
|
|
+
|
|
|
+ context 'when ticket is closed and groups.follow_up_possible is "new_ticket_after_certain_time"' do
|
|
|
+ let(:group) { create(:group, follow_up_possible: 'new_ticket_after_certain_time', reopen_time_in_days: 5) }
|
|
|
+
|
|
|
+ context 'when ticket was closed within the timeframe' do
|
|
|
+ let(:close_time) { 3.days.ago }
|
|
|
+
|
|
|
+ include_examples 'check roles', customer: true, agent: true, agent_customer: true
|
|
|
+ end
|
|
|
+
|
|
|
+ context 'when ticket was closed outside of the timeframe' do
|
|
|
+ let(:close_time) { 1.month.ago }
|
|
|
+
|
|
|
+ include_examples 'check roles', customer: false, agent: true, agent_customer: false
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
-
|
|
|
end
|