ticket_articles_spec.rb 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Mobile > Ticket > Articles', app: :mobile, authenticated_as: :agent, type: :system do
  4. let(:group) { create(:group) }
  5. let(:agent) { create(:agent, groups: [group]) }
  6. let(:cid) { "#{SecureRandom.uuid}@zammad.example.com" }
  7. let(:ticket) { create(:ticket, title: 'Ticket Title', group: group) }
  8. let(:article) do
  9. create(:ticket_article, :outbound_email, ticket: ticket, to: 'Zammad CI <ci@zammad.org>', content_type: 'text/html', body: "<img src=\"cid:#{cid}\"> some text").tap do |article|
  10. create(
  11. :store,
  12. object: 'Ticket::Article',
  13. o_id: article.id,
  14. data: 'fake',
  15. filename: 'inline_image.jpg',
  16. preferences: {
  17. 'Content-Type' => 'image/jpeg',
  18. 'Mime-Type' => 'image/jpeg',
  19. 'Content-ID' => "<#{cid}>",
  20. 'Content-Disposition' => 'inline',
  21. }
  22. )
  23. create(
  24. :store,
  25. object: 'Ticket::Article',
  26. o_id: article.id,
  27. data: 'fake',
  28. filename: 'attached_image.jpg',
  29. preferences: {
  30. 'Content-Type' => 'image/jpeg',
  31. 'Mime-Type' => 'image/jpeg',
  32. 'Content-ID' => "<#{cid}.not.referenced>",
  33. 'Content-Disposition' => 'inline',
  34. }
  35. )
  36. end
  37. end
  38. context 'when looking at a ticket' do
  39. it 'shows inline images and attachments correctly' do
  40. visit "/tickets/#{article.ticket_id}"
  41. wait_for_gql 'apps/mobile/entities/ticket/graphql/queries/ticketWithMentionLimit.graphql'
  42. expect(page).to have_text('Ticket Title')
  43. # Inline image is present with cid: replaced by REST API URL.
  44. expect(page).to have_css('img[src^="/api/v1/ticket_attachment"]')
  45. # Inline image does not show in attachments list.
  46. expect(page).to have_no_text('inline_image')
  47. # Attached image does show in attachments list.
  48. expect(page).to have_text('attached_image')
  49. end
  50. end
  51. end