Fixes #3331 - Direct Article URL / Link in Zoom.

This commit is contained in:
Thorsten Eckel 2020-12-10 10:21:34 +01:00
parent 24e46c9ddf
commit f75e18ab36
2 changed files with 58 additions and 39 deletions

View file

@ -125,4 +125,5 @@
<div class="js-article-actions"></div> <div class="js-article-actions"></div>
<small class="task-subline"><%- @humanTime(@article.created_at) %></small> <a href="<%- @C('http_type') %>://<%- @C('fqdn') %>/#ticket/zoom/<%- @article.ticket_id %>/<%- @article.id %>"><small class="task-subline"><%- @humanTime(@article.created_at) %></small></a>

View file

@ -1266,56 +1266,74 @@ RSpec.describe 'Ticket zoom', type: :system do
end end
end end
describe 'Article ID in URL' do describe 'Article ID URL / link' do
let(:ticket) { create(:ticket, group: Group.first) } let(:ticket) { create(:ticket, group: Group.first) }
let(:article_count) { 20 } let!(:article) { create(:'ticket/article', ticket: ticket) }
let(:article_at_the_top) { ticket.articles.first } let(:url) { "#{Setting.get('http_type')}://#{Setting.get('fqdn')}/#ticket/zoom/#{ticket.id}/#{article.id}" }
let(:article_in_the_middle) { ticket.articles[ article_count / 2 ] }
let(:article_at_the_bottom) { ticket.articles.last }
before do it 'shows Article direct link' do
article_count.times do
create(:'ticket/article', ticket: ticket, body: SecureRandom.uuid) ensure_websocket do
visit "ticket/zoom/#{ticket.id}"
await_empty_ajax_queue
within :active_ticket_article, article do
expect(page).to have_css(%(a[href="#{url}"]))
end
end end
end end
it 'scrolls to given Article ID' do context 'when multiple Articles are present' do
ensure_websocket do
visit "ticket/zoom/#{ticket.id}/#{article_in_the_middle.id}"
await_empty_ajax_queue
# workaround because browser scrolls in test initially to the bottom
# maybe because the articles are not present?!
refresh
# scroll to article in the middle of the page let(:article_count) { 20 }
within :active_content do let(:article_at_the_top) { ticket.articles.first }
find("div#article-content-#{article_in_the_middle.id}").in_fixed_position(wait: 0.5) let(:article_in_the_middle) { ticket.articles[ article_count / 2 ] }
let(:article_at_the_bottom) { ticket.articles.last }
expect(find("div#article-content-#{article_at_the_top.id}")).to be_obscured before do
expect(find("div#article-content-#{article_in_the_middle.id}")).not_to be_obscured article_count.times do
expect(find("div#article-content-#{article_at_the_bottom.id}")).to be_obscured create(:'ticket/article', ticket: ticket, body: SecureRandom.uuid)
end end
end
# scroll to article at the top of the page it 'scrolls to given Article ID' do
visit "ticket/zoom/#{ticket.id}/#{article_at_the_top.id}" ensure_websocket do
await_empty_ajax_queue visit "ticket/zoom/#{ticket.id}/#{article_in_the_middle.id}"
within :active_content do await_empty_ajax_queue
find("div#article-content-#{article_in_the_middle.id}").in_fixed_position(wait: 0.5) # workaround because browser scrolls in test initially to the bottom
# maybe because the articles are not present?!
refresh
expect(find("div#article-content-#{article_at_the_top.id}")).not_to be_obscured # scroll to article in the middle of the page
expect(find("div#article-content-#{article_in_the_middle.id}")).to be_obscured within :active_content do
expect(find("div#article-content-#{article_at_the_bottom.id}")).to be_obscured find("div#article-content-#{article_in_the_middle.id}").in_fixed_position(wait: 0.5)
end
# scroll to article at the bottom of the page expect(find("div#article-content-#{article_at_the_top.id}")).to be_obscured
visit "ticket/zoom/#{ticket.id}/#{article_at_the_bottom.id}" expect(find("div#article-content-#{article_in_the_middle.id}")).not_to be_obscured
await_empty_ajax_queue expect(find("div#article-content-#{article_at_the_bottom.id}")).to be_obscured
within :active_content do end
find("div#article-content-#{article_in_the_middle.id}").in_fixed_position(wait: 0.5)
expect(find("div#article-content-#{article_at_the_top.id}")).to be_obscured # scroll to article at the top of the page
expect(find("div#article-content-#{article_in_the_middle.id}")).to be_obscured visit "ticket/zoom/#{ticket.id}/#{article_at_the_top.id}"
expect(find("div#article-content-#{article_at_the_bottom.id}")).not_to be_obscured await_empty_ajax_queue
within :active_content do
find("div#article-content-#{article_in_the_middle.id}").in_fixed_position(wait: 0.5)
expect(find("div#article-content-#{article_at_the_top.id}")).not_to be_obscured
expect(find("div#article-content-#{article_in_the_middle.id}")).to be_obscured
expect(find("div#article-content-#{article_at_the_bottom.id}")).to be_obscured
end
# scroll to article at the bottom of the page
visit "ticket/zoom/#{ticket.id}/#{article_at_the_bottom.id}"
await_empty_ajax_queue
within :active_content do
find("div#article-content-#{article_in_the_middle.id}").in_fixed_position(wait: 0.5)
expect(find("div#article-content-#{article_at_the_top.id}")).to be_obscured
expect(find("div#article-content-#{article_in_the_middle.id}")).to be_obscured
expect(find("div#article-content-#{article_at_the_bottom.id}")).not_to be_obscured
end
end end
end end
end end