<commit_before>require 'acceptance_helper'

feature "adding factlinks to a fact", type: :request do
  include Acceptance
  include Acceptance::FactHelper
  include Acceptance::CommentHelper

  background do
    @user = sign_in_user create :active_user
  end

  let(:factlink) { create :fact, created_by: @user.graph_user }

  scenario "initially the evidence list should be empty" do
    go_to_discussion_page_of factlink

    within :css, ".relation-tabs-view" do
      page.should have_content "This Factlink is not supported by other Factlinks."
    end
  end

  scenario "after adding a piece of evidence, evidence list should contain that item" do
    go_to_discussion_page_of factlink

    supporting_factlink = backend_create_fact

    within ".relation-tabs-view" do
      add_existing_factlink supporting_factlink
      sleep 2
      within "li.evidence-item" do
        page.should have_content supporting_factlink.to_s
      end
    end
  end

  scenario "we can click on evidence to go to the page of that factlink" do
    go_to_discussion_page_of factlink

    supporting_factlink = backend_create_fact

    within ".relation-tabs-view" do
      add_existing_factlink supporting_factlink

      within "li.evidence-item" do
        page.find('span', text: supporting_factlink.to_s).click
      end
    end

    page.find('.fact-view .fact-body .js-displaystring', text: supporting_factlink.to_s)
  end

  scenario "we can click on the discussion link to go to the page of that factlink" do
    go_to_discussion_page_of factlink

    supporting_factlink = backend_create_fact

    within ".relation-tabs-view" do
      add_existing_factlink supporting_factlink

      within "li.evidence-item" do
        click_link 'Arguments'
      end
    end

    page.find('.fact-view .fact-body .js-displaystring', text: supporting_factlink.to_s)
  end

  scenario "factlink should show Arguments (1) on profile page" do
    go_to_discussion_page_of factlink

    supporting_factlink = backend_create_fact

    within ".relation-tabs-view" do
      add_existing_factlink supporting_factlink
    end

    visit user_path(@user)

    page.should have_content 'Arguments (1)'
  end
end<commit_msg>Add test<commit_after>require 'acceptance_helper'

feature "adding factlinks to a fact", type: :request do
  include Acceptance
  include Acceptance::FactHelper
  include Acceptance::CommentHelper

  background do
    @user = sign_in_user create :active_user
  end

  let(:factlink) { create :fact, created_by: @user.graph_user }

  scenario "initially the evidence list should be empty" do
    go_to_discussion_page_of factlink

    within :css, ".relation-tabs-view" do
      page.should have_content "This Factlink is not supported by other Factlinks."
    end
  end

  scenario "after adding a piece of evidence, evidence list should contain that item" do
    go_to_discussion_page_of factlink

    supporting_factlink = backend_create_fact

    within ".relation-tabs-view" do
      add_existing_factlink supporting_factlink
      sleep 2
      within "li.evidence-item" do
        page.should have_content supporting_factlink.to_s
      end
    end
  end

  scenario "we can click on evidence to go to the page of that factlink" do
    go_to_discussion_page_of factlink

    supporting_factlink = backend_create_fact

    within ".relation-tabs-view" do
      add_existing_factlink supporting_factlink

      within "li.evidence-item" do
        page.find('span', text: supporting_factlink.to_s).click
      end
    end

    page.find('.fact-view .fact-body .js-displaystring', text: supporting_factlink.to_s)
  end

  scenario "we can click on the discussion link to go to the page of that factlink" do
    go_to_discussion_page_of factlink

    supporting_factlink = backend_create_fact

    within ".relation-tabs-view" do
      add_existing_factlink supporting_factlink

      within "li.evidence-item" do
        click_link 'Arguments'
      end
    end

    page.find('.fact-view .fact-body .js-displaystring', text: supporting_factlink.to_s)
  end

  scenario "factlink should show Arguments (1) on profile page" do
    go_to_discussion_page_of factlink

    supporting_factlink = backend_create_fact

    within ".relation-tabs-view" do
      add_existing_factlink supporting_factlink
    end

    visit user_path(@user)

    page.should have_content 'Arguments (1)'
  end

  scenario "unsetting relevance" do
    go_to_discussion_page_of factlink

    supporting_factlink = backend_create_fact

    within ".relation-tabs-view" do
      add_existing_factlink supporting_factlink

      within "li.evidence-item" do
        page.should have_content supporting_factlink.to_s

        within '.total-authority-evidence' do
          page.should have_content '1.0'
        end

        find('.supporting').click
        find('.js-fact-relation-believe').set false
        page.find('a', text: 'Done').click

        within '.total-authority-evidence' do
          page.should have_content '0.0'
        end

      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06526482840706209, 'fraction_numerical': 0.0019837333862328904, 'mean_word_length': 3.24053826745164, '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': '2131960', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1472, 'n_words': 432}