report_spec.rb 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Report', type: :system, searchindex: true do
  4. before do
  5. configure_elasticsearch(required: true, rebuild: true)
  6. end
  7. context 'with ticket search result' do
  8. let(:label) { find('.content ul.checkbox-list') }
  9. before do
  10. create(:report_profile, name: report_profile_name, active: active)
  11. visit 'report'
  12. end
  13. context 'with an active report profile' do
  14. let(:report_profile_name) { 'active report profile' }
  15. let(:active) { true }
  16. it 'shows active report profile' do
  17. expect(label).to have_text(report_profile_name)
  18. end
  19. end
  20. context 'with an inactive report profile' do
  21. let(:report_profile_name) { 'inactive report profile' }
  22. let(:active) { false }
  23. it 'does not show inactive report profile' do
  24. expect(label).to have_no_text(report_profile_name)
  25. end
  26. end
  27. end
  28. context 'report profiles are displayed' do
  29. let!(:report_profile_active) { create(:report_profile) }
  30. let!(:report_profile_inactive) { create(:report_profile, active: false) }
  31. it 'shows report profiles' do
  32. visit 'report'
  33. expect(page)
  34. .to have_css('ul.checkbox-list .label-text', text: report_profile_active.name)
  35. .and have_no_css('ul.checkbox-list .label-text', text: report_profile_inactive.name)
  36. end
  37. end
  38. context 'with report profiles with date-based conditions' do
  39. let(:report_profile) { create(:report_profile, :condition_created_at, ticket_created_at: 1.year.ago) }
  40. before do
  41. freeze_time
  42. report_profile
  43. visit 'report'
  44. end
  45. it 'shows previous year for a profile with matching conditions' do
  46. click '.js-timePickerYear', text: Time.zone.now.year - 1
  47. click '.label-text', text: report_profile.name
  48. expect(page).to have_no_css('.modal')
  49. end
  50. it 'throws error for a profile when showing a different year than described in the profile' do
  51. click '.label-text', text: report_profile.name
  52. in_modal disappears: false do
  53. expect(page).to have_text 'Conflicting date ranges'
  54. end
  55. end
  56. end
  57. end