article_image_view_spec.rb 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Article Image View', type: :system do
  4. describe 'Switching the photos displayed in the preview' do
  5. let(:ticket) { create(:ticket, group: Group.first) }
  6. let(:article) do
  7. create(:ticket_article, ticket: ticket, attachments: [
  8. {
  9. data: Rails.root.join('spec/fixtures/files/image/large.png').read,
  10. filename: 'large.png',
  11. preferences: { 'Content-Type' => 'image/png', 'resizable' => true, 'content_preview' => true },
  12. },
  13. {
  14. data: Rails.root.join('spec/fixtures/files/image/large2.png').read,
  15. filename: 'large2.png',
  16. preferences: { 'Content-Type' => 'image/png', 'resizable' => true, 'content_preview' => true },
  17. },
  18. {
  19. data: Rails.root.join('spec/fixtures/files/image/large3.png').read,
  20. filename: 'large3.png',
  21. preferences: { 'Content-Type' => 'image/png', 'resizable' => true, 'content_preview' => true },
  22. },
  23. ])
  24. end
  25. def current_scroll_position
  26. find('div.modal').evaluate_script('this.scrollTop')
  27. end
  28. before do
  29. visit "#ticket/zoom/#{article.ticket.id}"
  30. end
  31. # https://github.com/zammad/zammad/issues/4030
  32. it 'does switch images via arrow keys' do
  33. first('.ticket-article-item .js-preview').click
  34. images = Store.last(3)
  35. wait.until { page.find('div.imagePreview img')[:src].include?("/#{images[0].id}") }
  36. find('body').send_keys :arrow_right
  37. wait.until { page.find('div.imagePreview img')[:src].include?("/#{images[1].id}") }
  38. find('body').send_keys :arrow_right
  39. wait.until { page.find('div.imagePreview img')[:src].include?("/#{images[2].id}") }
  40. find('body').send_keys :arrow_left
  41. wait.until { page.find('div.imagePreview img')[:src].include?("/#{images[1].id}") }
  42. end
  43. end
  44. end