history_spec.rb 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Ticket history', authenticated_as: :admin_de, time_zone: 'Europe/London', type: :system do
  4. let(:group) { create(:group) }
  5. let(:ticket) { create(:ticket, group: group) }
  6. let(:admin_de) { create(:admin, :groupable, preferences: { locale: 'de-de' }, group: group) }
  7. before do
  8. Time.use_zone('UTC') do
  9. freeze_time
  10. travel_to DateTime.parse('2021-01-22 13:40:00 UTC')
  11. current_time = Time.current
  12. ticket.update(title: 'New Ticket Title')
  13. ticket_article = create(:ticket_article, ticket: ticket, internal: true)
  14. ticket.update! state: Ticket::State.lookup(name: 'open')
  15. ticket.update! last_owner_update_at: current_time
  16. ticket.update! priority: Ticket::Priority.lookup(name: '1 low')
  17. ticket.update! last_contact_at: current_time
  18. ticket.update! last_contact_customer_at: current_time
  19. ticket.update! last_contact_agent_at: current_time
  20. ticket_article.update! internal: false
  21. travel_to DateTime.parse('2021-04-06 23:30:00 UTC')
  22. current_time = Time.current
  23. ticket.update! state: Ticket::State.lookup(name: 'pending close')
  24. ticket.update! priority: Ticket::Priority.lookup(name: '3 high')
  25. ticket_article.update! internal: true
  26. ticket.update! last_contact_at: current_time
  27. ticket.update! last_contact_customer_at: current_time
  28. ticket.update! last_contact_agent_at: current_time
  29. ticket.update! pending_time: current_time
  30. ticket.update! first_response_escalation_at: current_time
  31. travel_back
  32. end
  33. visit '/'
  34. # Suppress the modal dialog that invites to contributions for translations that are < 90% as this breaks the tests for de-de.
  35. page.evaluate_script "App.LocalStorage.set('translation_support_no', true, App.Session.get('id'))"
  36. refresh
  37. visit "#ticket/zoom/#{ticket.id}"
  38. find('[data-tab="ticket"] .js-actions').click
  39. click('[data-type="ticket-history"]')
  40. end
  41. it "translates timestamp when attribute's tag is datetime" do
  42. expect(page).to have_css('li', text: %r{22.01.2021 13:40})
  43. end
  44. it 'does not include time with UTC format' do
  45. expect(page).to have_no_text(%r{ UTC})
  46. end
  47. it 'translates value when attribute is state' do
  48. expect(page).to have_css('li', text: %r{Ticket Status von 'neu'})
  49. end
  50. it 'translates value when attribute is priority' do
  51. expect(page).to have_css('li', text: %r{Ticket Priorität von '1 niedrig'})
  52. end
  53. it 'translates value when attribute is internal' do
  54. expect(page).to have_css('li', text: %r{Artikel intern von 'true'})
  55. end
  56. it 'translates last_contact_at display attribute' do
  57. expect(page).to have_css('li', text: %r{Ticket Letzter Kontakt von '22.01.2021 13:40' → '07.04.2021 00:30'})
  58. end
  59. it 'translates last_contact_customer_at display attribute' do
  60. expect(page).to have_css('li', text: %r{Ticket Letzter Kontakt \(Kunde\) von '22.01.2021 13:40' → '07.04.2021 00:30'})
  61. end
  62. it 'translates last_contact_agent_at display attribute' do
  63. expect(page).to have_css('li', text: %r{Ticket Letzter Kontakt \(Agent\) von '22.01.2021 13:40' → '07.04.2021 00:30'})
  64. end
  65. it 'translates pending_time display attribute' do
  66. expect(page).to have_css('li', text: %r{Ticket Warten bis '07.04.2021 00:30'})
  67. end
  68. end