overviews_spec.rb 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Profile > Overviews', type: :system do
  4. def overview_names
  5. page.all('.overview-header .js-tabsHolder span.tab-name', visible: :all).map { |e| e.text(:all) }
  6. end
  7. def move_assigned_tickets_overview
  8. visit 'profile/overviews'
  9. overview_from = page.find('tr.item', text: 'My Assigned Tickets')
  10. overview_to = page.find('tr.item', text: 'Escalated Tickets')
  11. overview_from.drag_to overview_to
  12. await_empty_ajax_queue
  13. wait.until { User::OverviewSorting.where(user: current_user)&.last&.overview_id == Overview.find_by(name: 'My Assigned Tickets').id }
  14. end
  15. def expect_user_ticket_overview
  16. visit 'ticket/view'
  17. wait.until { overview_names.index('My Assigned Tickets') > overview_names.index('Escalated Tickets') }
  18. end
  19. def expect_default_ticket_overview
  20. visit 'ticket/view'
  21. wait.until { overview_names.index('My Assigned Tickets') < overview_names.index('Escalated Tickets') }
  22. end
  23. def reset_overview_order
  24. visit 'profile/overviews'
  25. page.find('a[data-type=reset]').click
  26. wait.until { User::OverviewSorting.where(user: current_user).count.zero? }
  27. end
  28. it 'does provide drag and drop and reorder functionality' do
  29. # move "My Assigned Tickets" after "Escalated Tickets"
  30. move_assigned_tickets_overview
  31. # go to ticket overviews and verify
  32. expect_user_ticket_overview
  33. # go back and reset order
  34. reset_overview_order
  35. # go to ticket overviews and verify
  36. expect_default_ticket_overview
  37. end
  38. end