history_spec.rb 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Ticket history', time_zone: 'Europe/London', type: :system do
  4. let(:group) { create(:group) }
  5. let(:subgroup) { create(:group, parent: group) }
  6. let(:ticket) { create(:ticket, group: group) }
  7. context 'with German locale', authenticated_as: :authenticate do
  8. let(:admin_de) { create(:admin, :groupable, preferences: { locale: 'de-de' }, group: [group, subgroup]) }
  9. def authenticate
  10. Time.use_zone('UTC') do
  11. freeze_time
  12. travel_to DateTime.parse('2021-01-22 13:40: UTC')
  13. current_time = Time.current
  14. ticket_article = create(:ticket_article, ticket: ticket, internal: true)
  15. ticket.update!(
  16. title: 'New Ticket Title',
  17. state: Ticket::State.lookup(name: 'open'),
  18. last_owner_update_at: current_time,
  19. priority: Ticket::Priority.lookup(name: '1 low'),
  20. group: subgroup,
  21. last_contact_at: current_time,
  22. last_contact_customer_at: current_time,
  23. last_contact_agent_at: current_time,
  24. )
  25. ticket_article.update! internal: false
  26. travel_to DateTime.parse('2021-04-06 23:30:00 UTC')
  27. current_time = Time.current
  28. ticket.update!(
  29. state: Ticket::State.lookup(name: 'pending close'),
  30. priority: Ticket::Priority.lookup(name: '3 high'),
  31. last_contact_at: current_time,
  32. last_contact_customer_at: current_time,
  33. last_contact_agent_at: current_time,
  34. pending_time: current_time,
  35. first_response_escalation_at: current_time,
  36. )
  37. ticket_article.update! internal: true
  38. travel_back
  39. end
  40. admin_de
  41. end
  42. before do
  43. visit '/'
  44. # Suppress the modal dialog that invites to contributions for translations that are < 90% as this breaks the tests for de-de.
  45. page.evaluate_script "App.LocalStorage.set('translation_support_no', true, App.Session.get('id'))"
  46. visit "#ticket/zoom/#{ticket.id}"
  47. find('[data-tab="ticket"] .js-actions').click
  48. click('[data-type="ticket-history"]')
  49. end
  50. it 'shows group name in human readable form' do
  51. expect(page).to have_text("#{group.name_last} › #{subgroup.name_last}")
  52. end
  53. it "translates timestamp when attribute's tag is datetime" do
  54. expect(page).to have_css('li', text: %r{22.01.2021 13:40})
  55. end
  56. it 'does not include time with UTC format' do
  57. expect(page).to have_no_text(%r{ UTC})
  58. end
  59. it 'translates value when attribute is state' do
  60. expect(page).to have_css('li', text: %r{Ticket Status von 'neu'})
  61. end
  62. it 'translates value when attribute is priority' do
  63. expect(page).to have_css('li', text: %r{Ticket Priorität von '1 niedrig'})
  64. end
  65. it 'translates value when attribute is internal' do
  66. expect(page).to have_css('li', text: %r{Artikel intern von 'true'})
  67. end
  68. it 'translates last_contact_at display attribute' do
  69. expect(page).to have_css('li', text: %r{Ticket Letzter Kontakt von '22.01.2021 13:40' → '07.04.2021 00:30'})
  70. end
  71. it 'translates last_contact_customer_at display attribute' do
  72. expect(page).to have_css('li', text: %r{Ticket Letzter Kontakt \(Kunde\) von '22.01.2021 13:40' → '07.04.2021 00:30'})
  73. end
  74. it 'translates last_contact_agent_at display attribute' do
  75. expect(page).to have_css('li', text: %r{Ticket Letzter Kontakt \(Agent\) von '22.01.2021 13:40' → '07.04.2021 00:30'})
  76. end
  77. it 'translates pending_time display attribute' do
  78. expect(page).to have_css('li', text: %r{Ticket Warten bis '07.04.2021 00:30'})
  79. end
  80. end
  81. context 'with time-based trigger' do
  82. let(:group) { Group.first }
  83. let(:trigger) { create(:trigger, activator: 'time') }
  84. before do
  85. UserInfo.ensure_current_user_id do
  86. trigger.performed_on(ticket, activator_type: 'reminder_reached')
  87. end
  88. visit "#ticket/zoom/#{ticket.id}"
  89. find('[data-tab="ticket"] .js-actions').click
  90. click('[data-type="ticket-history"]')
  91. end
  92. it 'shows information that trigger was performed' do
  93. text = "trigger '#{trigger.name}' was performed because pending reminder was reached"
  94. expect(page).to have_css('li', text: Regexp.new(text))
  95. end
  96. end
  97. end