<commit_before># frozen_string_literal: true

require 'rails_helper'

describe "Conversations", :js do
  let(:sender)    { create :member                        }
  let(:recipient) { create :member, login_name: 'beyonce' }

  before do
    sender.send_message(recipient, "this is the body", "something i want to say")
    login_as recipient
  end

  describe "Read conversations list" do
    before do
      visit root_path
      click_link 'Your Stuff'
      click_link 'Inbox'
    end
    it { expect(page).to have_content 'something i want to say' }
    it { Percy.snapshot(page, name: 'conversations#index') }

    describe 'deleting' do
      before do
        check 'conversation_ids[]'
        click_button 'Delete Selected'
      end

      describe 'view trash' do
        before { click_link 'trash' }
        it { expect(page).to have_content 'something i want to say' }
        describe 'restore conversation' do
          before { click_link class: 'restore' }
          it { expect(page).not_to have_content 'something i want to say' }

          describe 'conversation was restored' do
            before { click_link 'inbox' }
            it { expect(page).to have_content 'something i want to say' }
          end
        end
      end
    end
  end

  describe 'deleting conversations' do
    it 'deletes multiple conversations from the inbox' do
      sender.send_message(recipient, 'this is a message', 'message 1')
      sender.send_message(recipient, 'this is another message', 'follow up message')

      visit root_path
      click_link 'Your Stuff'
      click_link 'Inbox'

      all('input[type=checkbox]').each(&:click)
      click_button 'Delete Selected'

      expect(page).not_to have_content 'this is a message'
      expect(page).not_to have_content 'this is another message'
    end

    it 'deletes multiple conversations from the sentbox' do
      sender.send_message(recipient, 'this is a message', 'message 1')
      sender.send_message(recipient, 'this is another message', 'follow up message')

      visit root_path
      click_link 'Your Stuff'<commit_msg>Fix menu link label in spec<commit_after># frozen_string_literal: true

require 'rails_helper'

describe "Conversations", :js do
  let(:sender)    { create :member                        }
  let(:recipient) { create :member, login_name: 'beyonce' }

  before do
    sender.send_message(recipient, "this is the body", "something i want to say")
    login_as recipient
  end

  describe "Read conversations list" do
    before do
      visit root_path
      click_link recipient.login_name
      click_link 'Inbox'
    end
    it { expect(page).to have_content 'something i want to say' }
    it { Percy.snapshot(page, name: 'conversations#index') }

    describe 'deleting' do
      before do
        check 'conversation_ids[]'
        click_button 'Delete Selected'
      end

      describe 'view trash' do
        before { click_link 'trash' }
        it { expect(page).to have_content 'something i want to say' }
        describe 'restore conversation' do
          before { click_link class: 'restore' }
          it { expect(page).not_to have_content 'something i want to say' }

          describe 'conversation was restored' do
            before { click_link 'inbox' }
            it { expect(page).to have_content 'something i want to say' }
          end
        end
      end
    end
  end

  describe 'deleting conversations' do
    it 'deletes multiple conversations from the inbox' do
      sender.send_message(recipient, 'this is a message', 'message 1')
      sender.send_message(recipient, 'this is another message', 'follow up message')

      visit root_path
      click_link recipient.login_name
      click_link 'Inbox'

      all('input[type=checkbox]').each(&:click)
      click_button 'Delete Selected'

      expect(page).not_to have_content 'this is a message'
      expect(page).not_to have_content 'this is another message'
    end

    it 'deletes multiple conversations from the sentbox' do
      sender.send_message(recipient, 'this is a message', 'message 1')
      sender.send_message(recipient, 'this is another message', 'follow up message')

      visit root_path
      click_link recipient.login_name
{'fraction_non_alphanumeric': 0.08380547686496695, 'fraction_numerical': 0.0009442870632672333, 'mean_word_length': 2.7495575221238937, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6601495', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1189, 'n_words': 403}