form_spec.rb 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Manage > Channels > Form', type: :system do
  4. before do
  5. visit '/#channels/form'
  6. end
  7. context 'when looking at the default screen' do
  8. it 'has correct default settings' do
  9. within :active_content, 'table.settings-list' do
  10. # Enable debugging for implementation.
  11. expect(page).to have_unchecked_field(name: 'debug', visible: :all, disabled: :all)
  12. # Show title in form.
  13. expect(page).to have_unchecked_field(name: 'showTitle', visible: :all, disabled: :all)
  14. # Start modal dialog for form.
  15. expect(page).to have_checked_field(name: 'modal', visible: :all, disabled: :all)
  16. # Don't load CSS for form. You need to generate your own CSS for the form.
  17. expect(page).to have_unchecked_field(name: 'noCSS', visible: :all, disabled: :all)
  18. # Add attachment option to upload.
  19. expect(page).to have_unchecked_field(name: 'attachmentSupport', visible: :all, disabled: :all)
  20. # Add agreement text before submit.
  21. expect(page).to have_unchecked_field(id: 'agreementSupport', visible: :all, disabled: :all)
  22. end
  23. end
  24. end
  25. context 'when adding agreement text' do
  26. context 'when agreement text is checked' do
  27. let(:default_agreement_text) { 'Accept Data Privacy Policy & Acceptable Use Policy' }
  28. before do
  29. check 'Add agreement text before submit.', allow_label_click: true
  30. end
  31. shared_examples 'showing agreement text' do
  32. it 'shows the agreement text' do
  33. within :active_content, 'table.settings-list' do
  34. expect(page).to have_text agreement_text
  35. end
  36. within :active_content, 'code.js-paramsBlock' do
  37. expect(page).to have_text agreement_text
  38. end
  39. end
  40. it 'shows the agreement text on the modal form' do
  41. within :active_content, '.browser.js-browser' do
  42. find('.js-formBtn').click
  43. end
  44. within '.zammad-form-modal .js-zammad-form-modal-body' do
  45. within '.zammad-form' do
  46. expect(page).to have_text %r{#{agreement_text}}i
  47. end
  48. end
  49. end
  50. it 'shows the agreement text on the inline form' do
  51. within :active_content, 'table.settings-list' do
  52. uncheck 'modal', allow_label_click: true
  53. end
  54. scroll_into_view('.zammad-form')
  55. within '.js-formInline.browser-inline-form' do
  56. expect(page).to have_text %r{#{agreement_text}}i
  57. end
  58. end
  59. end
  60. context 'with default agreement text' do
  61. let(:agreement_text) { default_agreement_text }
  62. it_behaves_like 'showing agreement text'
  63. end
  64. context 'when agreement text is changed' do
  65. let(:agreement_text) { 'New agreement text' }
  66. before do
  67. within :active_content, 'table.settings-list' do
  68. # The click is needed to get the focus back to the field for chrome.
  69. find(:richtext, 'agreementMessage').click
  70. find(:richtext, 'agreementMessage').send_keys agreement_text
  71. end
  72. end
  73. it_behaves_like 'showing agreement text'
  74. end
  75. end
  76. end
  77. end