clearbit_spec.rb 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Manage > Integration > Clearbit', type: :system do
  4. let(:api_key) { 'some_api_key' }
  5. let(:source) { 'source1' }
  6. let(:destination) { 'destination1' }
  7. before do
  8. visit 'system/integration/clearbit'
  9. # enable clearbit
  10. check 'setting-switch', { allow_label_click: true }
  11. end
  12. context 'for clearbit config' do
  13. before do
  14. within :active_content, '.main' do
  15. fill_in 'api_key', with: api_key
  16. within '.js-userSync .js-new' do
  17. fill_in 'source', with: source
  18. fill_in 'destination', with: destination
  19. click '.js-add'
  20. end
  21. click_button
  22. end
  23. end
  24. shared_examples 'showing set config' do
  25. it 'shows the set api_key' do
  26. within :active_content, '.main' do
  27. expect(page).to have_field('api_key', with: api_key)
  28. end
  29. end
  30. it 'shows the set source' do
  31. within :active_content, '.main .js-userSync' do
  32. expect(page).to have_field('source', with: source)
  33. end
  34. end
  35. it 'shows the set destination' do
  36. within :active_content, '.main .js-userSync' do
  37. expect(page).to have_field('destination', with: destination)
  38. end
  39. end
  40. end
  41. context 'when added' do
  42. it_behaves_like 'showing set config'
  43. end
  44. context 'when page is re-navigated back to integration page' do
  45. before do
  46. visit 'dashboard'
  47. visit 'system/integration/clearbit'
  48. end
  49. it_behaves_like 'showing set config'
  50. end
  51. context 'when page is reloaded' do
  52. before { refresh }
  53. it_behaves_like 'showing set config'
  54. end
  55. context 'when disabled with changed config' do
  56. before do
  57. # disable clearbit
  58. uncheck 'setting-switch', { allow_label_click: true }
  59. end
  60. let(:api_key) { '-empty-' }
  61. it_behaves_like 'showing set config'
  62. it 'does not have the old api key' do
  63. within :active_content, '.main' do
  64. expect(page).to have_no_field('api_key', with: 'some_api_key')
  65. end
  66. end
  67. end
  68. end
  69. end