public_links_spec.rb 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. require 'system/examples/pagination_examples'
  4. RSpec.describe 'Manage > Public Links', type: :system do
  5. context 'when ajax pagination' do
  6. include_examples 'pagination', model: :public_link, klass: PublicLink, path: 'manage/public_links', sort_by: :prio, main_column: :title
  7. end
  8. context 'when creating a new public link' do
  9. it 'successfully creates a new public link' do
  10. visit '/#manage/public_links'
  11. click_on 'New Public Link'
  12. in_modal do
  13. fill_in 'link', with: 'https://zammad.org'
  14. fill_in 'title', with: 'Zammad <3'
  15. click_on 'Submit'
  16. end
  17. expect(page).to have_text('Zammad <3')
  18. end
  19. end
  20. context 'when performing different actions on a public link' do
  21. let(:public_link) { create(:public_link) }
  22. before do
  23. public_link
  24. visit '/#manage/public_links'
  25. end
  26. context 'when updating an existing public link' do
  27. it 'successfully updates an existing public link' do
  28. expect(page).to have_text('Zammad Homepage')
  29. find('td', text: 'Zammad Homepage').click
  30. in_modal do
  31. fill_in 'title', with: 'Zammad <3'
  32. click_on 'Submit'
  33. end
  34. expect(page).to have_text('Zammad <3')
  35. end
  36. end
  37. context 'when cloning an existing public link' do
  38. it 'successfully clones an existing public link' do
  39. expect(page).to have_text('Zammad Homepage')
  40. row = find('tr', text: 'Zammad Homepage')
  41. row.find('.js-action').click
  42. row.find('.js-clone').click
  43. in_modal do
  44. fill_in 'title', with: 'Zammad <3'
  45. fill_in 'link', with: 'https://zammad.org'
  46. click_on 'Submit'
  47. end
  48. expect(page).to have_text('Zammad Homepage')
  49. expect(page).to have_text('Zammad <3')
  50. end
  51. end
  52. context 'when deleting an existing public link' do
  53. it 'successfully deletes an existing public link' do
  54. expect(page).to have_text('Zammad Homepage')
  55. row = find('tr', text: 'Zammad Homepage')
  56. row.find('.js-action').click
  57. row.find('.js-delete').click
  58. in_modal do
  59. click_on 'delete'
  60. end
  61. expect(page).to have_no_text('Zammad Homepage')
  62. end
  63. end
  64. end
  65. end