ticket_article_subscription_spec.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Mobile > Ticket > Articles > Update', app: :mobile, authenticated_as: :agent, type: :system do
  4. let(:group) { Group.find_by(name: 'Users') }
  5. let(:agent) { create(:agent, groups: [group]) }
  6. let(:ticket) { create(:ticket, title: 'Ticket Title', group: group) }
  7. context 'when subscription is triggered' do
  8. let!(:article) { create(:ticket_article, body: 'Hello, World!', ticket: ticket, internal: false) }
  9. before do
  10. visit "/tickets/#{ticket.id}"
  11. wait_for_subscription_start('ticketArticleUpdates')
  12. end
  13. it 'updates article on the frontend' do
  14. expect(page).to have_text(article.body)
  15. expect(page).to have_no_css("#article-#{article.id}.Internal")
  16. article.update!(internal: true)
  17. wait_for_subscription_update('ticketArticleUpdates')
  18. expect(page).to have_css("#article-#{article.id}.Internal")
  19. end
  20. it 'removes article on the frontend' do
  21. expect(page).to have_css("#article-#{article.id}")
  22. article.destroy!
  23. wait_for_subscription_update('ticketArticleUpdates')
  24. expect(page).to have_no_css("#article-#{article.id}")
  25. end
  26. it 'adds new article on the frontend' do
  27. expect(page).to have_css("#article-#{article.id}")
  28. new_article = create(:ticket_article, ticket: ticket, internal: false)
  29. wait_for_subscription_update('ticketArticleUpdates')
  30. expect(page).to have_css("#article-#{article.id}")
  31. expect(page).to have_css("#article-#{new_article.id}")
  32. end
  33. end
  34. end