Fixes #3279 - "Next ticket in overview" is clickable for the last ticket in the overview

This commit is contained in:
Mantas Masalskis 2020-11-16 10:27:35 +01:00 committed by Thorsten Eckel
parent bb26438c1c
commit e85f80aa2c
2 changed files with 56 additions and 3 deletions

View file

@ -3,7 +3,7 @@
</div>
<ul class="pagination">
<li <% if !@previous: %>class="disabled"<% end %> title="<%- @Ti( 'Previous in overview' ) %>">
<a class="centered previous" href="<% if @previous: %><%- @previous.uiUrl() %><% end %>" data-id="<% if @previous: %><%- @previous.id %><% end %>">
<a class="centered previous" href="<% if @previous: %><%- @previous.uiUrl() %><% end %>" <% if @previous: %>data-id="<%- @previous.id %>"<% end %>>
<% if @previous: %>
<%- @Icon('arrow-left') %>
<% else: %>
@ -11,11 +11,11 @@
<% end %>
</a>
<li <% if !@next: %>class="disabled"<% end %> title="<%- @Ti( 'Next in overview' ) %>">
<a class="centered next" href="<% if @next: %><%- @next.uiUrl() %><% end %>" data-id="<% if @next: %><%- @next.id %><% end %>">
<a class="centered next" href="<% if @next: %><%- @next.uiUrl() %><% end %>" <% if @next: %>data-id="<%- @next.id %>"<% end %>>
<% if @next: %>
<%- @Icon('arrow-right') %>
<% else: %>
<%- @Icon('arrow-right', 'arrow--disabled') %>
<% end %>
</a>
</ul>
</ul>

View file

@ -1112,6 +1112,59 @@ RSpec.describe 'Ticket zoom', type: :system do
expect { find(:element_containing, macro.name).click }.to change { current_url }
end
end
# https://github.com/zammad/zammad/issues/3279
describe 'previous/next clickability when at last or first ticket' do
let(:ticket_a) { create(:ticket, title: 'ticket a', group: Group.first) }
let(:ticket_b) { create(:ticket, title: 'ticket b', group: Group.first) }
before do
ticket_a && ticket_b
visit 'ticket/view/all_unassigned'
end
it 'previous is not clickable for the first item' do
open_nth_item(0)
expect { click '.pagination .previous' }.not_to change { current_url }
end
it 'next is clickable for the first item' do
open_nth_item(0)
expect { click '.pagination .next' }.to change { current_url }
end
it 'previous is clickable for the middle item' do
open_nth_item(1)
expect { click '.pagination .previous' }.to change { current_url }
end
it 'next is clickable for the middle item' do
open_nth_item(1)
expect { click '.pagination .next' }.to change { current_url }
end
it 'previous is clickable for the last item' do
open_nth_item(2)
expect { click '.pagination .previous' }.to change { current_url }
end
it 'next is not clickable for the last item' do
open_nth_item(2)
expect { click '.pagination .next' }.not_to change { current_url }
end
def open_nth_item(nth)
within :active_content do
find_all('.table tr.item .user-popover')[nth].click
end
end
end
end