report_spec.rb 1.8 KB

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