history_spec.rb 3.2 KB

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