autosave_spec.rb 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Ticket zoom > Autosave', type: :system do
  4. before do
  5. visit "ticket/zoom/#{Ticket.first.id}"
  6. click '.attachmentPlaceholder'
  7. end
  8. context 'with content added' do
  9. before do
  10. find(:richtext).send_keys('sample text')
  11. end
  12. it 'autosaves visibility change for the default type' do
  13. click '.js-toggleVisibility'
  14. expect(page).to have_css('.js-reset')
  15. wait_for_autosave_and_reload
  16. within '.article-new' do
  17. expect(page)
  18. .to have_css('.editControls-icon.icon-public')
  19. .and have_css('.js-selectableTypes[data-type="note"]')
  20. end
  21. end
  22. it 'autosaves visibility change back to default for the default type' do
  23. click '.js-toggleVisibility'
  24. click '.js-toggleVisibility'
  25. wait_for_autosave_and_reload
  26. within '.article-new' do
  27. expect(page)
  28. .to have_css('.editControls-icon.icon-internal')
  29. .and have_css('.js-selectableTypes[data-type="note"]')
  30. end
  31. end
  32. it 'autosaves non-default type' do
  33. click '.js-selectableTypes'
  34. click '.js-articleTypeItem[data-value=phone]'
  35. wait_for_autosave_and_reload
  36. within '.article-new' do
  37. expect(page)
  38. .to have_css('.editControls-icon.icon-public')
  39. .and have_css('.js-selectableTypes[data-type="phone"]')
  40. end
  41. end
  42. it 'autosaves non-default type with non-default visibility' do
  43. click '.js-selectableTypes'
  44. click '.js-articleTypeItem[data-value=phone]'
  45. click '.js-toggleVisibility'
  46. wait_for_autosave_and_reload
  47. within '.article-new' do
  48. expect(page)
  49. .to have_css('.editControls-icon.icon-internal')
  50. .and have_css('.js-selectableTypes[data-type="phone"]')
  51. end
  52. end
  53. end
  54. context 'without content' do
  55. it 'ignores visibility change' do
  56. click '.js-toggleVisibility'
  57. expect(page).to have_no_css('.js-reset')
  58. end
  59. it 'ignores type change' do
  60. click '.js-selectableTypes'
  61. click '.js-articleTypeItem[data-value=phone]'
  62. expect(page).to have_no_css('.js-reset')
  63. end
  64. end
  65. def wait_for_autosave_and_reload
  66. time = Time.current
  67. wait.until do
  68. Taskbar.exists?(['updated_at > ?', time])
  69. end
  70. refresh
  71. click '.attachmentPlaceholder'
  72. end
  73. end