search_spec.rb 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Search', type: :system, searchindex: true do
  4. before do
  5. configure_elasticsearch(required: true, rebuild: true)
  6. end
  7. it 'shows default widgets' do
  8. fill_in id: 'global-search', with: '"Welcome"'
  9. click_on 'Show Search Details'
  10. within '#navigation .tasks a[data-key=Search]' do
  11. expect(page).to have_text '"Welcome"'
  12. end
  13. end
  14. context 'Organization members', authenticated_as: :authenticate do
  15. let(:organization) { create(:organization) }
  16. let(:members) { organization.members.order(id: :asc) }
  17. def authenticate
  18. create_list(:customer, 50, organization: organization)
  19. true
  20. end
  21. before do
  22. sleep 3 # wait for popover killer to pass
  23. fill_in id: 'global-search', with: organization.name.to_s
  24. end
  25. it 'shows only first 10 members' do
  26. expect(page).to have_text(organization.name)
  27. popover_on_hover(first('a.nav-tab.organization'))
  28. expect(page).to have_text(members[9].fullname, wait: 30)
  29. expect(page).to have_no_text(members[10].fullname)
  30. end
  31. end
  32. context 'inactive user and organizations' do
  33. before do
  34. create(:organization, name: 'Example Inc.', active: true)
  35. create(:organization, name: 'Example Inactive Inc.', active: false)
  36. create(:customer, firstname: 'Firstname', lastname: 'Active', active: true)
  37. create(:customer, firstname: 'Firstname', lastname: 'Inactive', active: false)
  38. configure_elasticsearch(rebuild: true)
  39. end
  40. it 'check that inactive organizations are marked correctly' do
  41. fill_in id: 'global-search', with: '"Example"'
  42. expect(page).to have_css('.nav-tab--search.organization', minimum: 2)
  43. expect(page).to have_css('.nav-tab--search.organization.is-inactive', count: 1)
  44. end
  45. it 'check that inactive users are marked correctly' do
  46. fill_in id: 'global-search', with: '"Firstname"'
  47. expect(page).to have_css('.nav-tab--search.user', minimum: 2)
  48. expect(page).to have_css('.nav-tab--search.user.is-inactive', count: 1)
  49. end
  50. it 'check that inactive users are also marked in the popover for the quick search result' do
  51. fill_in id: 'global-search', with: '"Firstname"'
  52. popover_on_hover(find('.nav-tab--search.user.is-inactive'))
  53. expect(page).to have_css('.popover-title .is-inactive', count: 1)
  54. end
  55. end
  56. end