report_spec.rb 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Copyright (C) 2012-2025 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. describe 'delete reporting profile with id=1 #5463' do
  49. context 'when report profiles are not present', authenticated_as: :authenticate do
  50. def authenticate
  51. Report::Profile.destroy_all
  52. true
  53. end
  54. it 'does show a message that no report profiles are given' do
  55. visit 'report'
  56. expect(page).to have_text('There are currently no report profiles configured.')
  57. end
  58. end
  59. context 'when selected report profile is replaced with a new one' do
  60. it 'does clear the session storage cache and selects the new report profile' do
  61. visit 'report'
  62. expect(page).to have_text(Report::Profile.first.name)
  63. click ".js-dataDownloadBackendSelector[data-backend='count::closed']"
  64. Report::Profile.first.destroy
  65. new_report_profile = create(:report_profile)
  66. refresh
  67. expect(page).to have_text(new_report_profile.name)
  68. expect(page).to have_no_text('The report could not be generated')
  69. end
  70. end
  71. end
  72. end