report_interface_spec.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'report interface', :attachment_processing, :js, :streaming do
  4. include ProfileStories
  5. let(:email) { 'admin@example.com' }
  6. let(:password) { 'password' }
  7. let(:confirmed_at) { Time.zone.now }
  8. let(:finished_onboarding) { true }
  9. let(:reported_account) { Fabricate(:account) }
  10. let(:reported_status) { Fabricate(:status, account: reported_account) }
  11. let(:media_attachment) { Fabricate(:media_attachment, account: reported_account, status: reported_status, file: attachment_fixture('attachment.jpg')) }
  12. let!(:report) { Fabricate(:report, target_account: reported_account, status_ids: [media_attachment.status.id]) }
  13. before do
  14. as_a_logged_in_admin
  15. visit admin_report_path(report)
  16. end
  17. it 'displays the report interface, including the javascript bits' do
  18. # The report category selector React component is properly rendered
  19. expect(page).to have_css('.report-reason-selector')
  20. # The media React component is properly rendered
  21. page.scroll_to(page.find('.batch-table__row'))
  22. expect(page).to have_css('.spoiler-button__overlay__label')
  23. end
  24. it 'marks a report resolved from the show page actions area' do
  25. visit admin_report_path(report)
  26. expect { resolve_report }
  27. .to change { report.reload.action_taken_at }.to(be_present).from(nil)
  28. end
  29. def resolve_report
  30. within '.report-actions' do
  31. click_on I18n.t('admin.reports.mark_as_resolved')
  32. end
  33. end
  34. end