<commit_before>require 'acceptance_helper'

feature "adding factlinks to a fact", type: :feature 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_evidence_list do
      expect(all '.evidence-votable', visible: false).to be_empty
    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

    add_existing_factlink :supporting, supporting_factlink
    sleep 2
    within ".evidence-votable", visible: false do
      page.should have_content supporting_factlink.to_s
    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

    add_existing_factlink :supporting, supporting_factlink

    within ".evidence-votable", visible: false do
      page.find('span', text: supporting_factlink.to_s).click
    end

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

  scenario "after clicking the factwheel, the impact and percentages should update" do
    go_to_discussion_page_of factlink

    supporting_factlink = backend_create_fact
<commit_msg>Fixed add_fact_relation test<commit_after>require 'acceptance_helper'

feature "adding factlinks to a fact", type: :feature 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_evidence_list do
      expect(all '.evidence-votable', visible: false).to be_empty
    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

    add_existing_factlink :supporting, supporting_factlink
    sleep 2
    within ".evidence-votable", visible: false do
      page.should have_content supporting_factlink.to_s
    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

    add_existing_factlink :supporting, supporting_factlink

    find('.evidence-impact-text', text: "0.0") # wait until request has finished

    find('.evidence-votable span', text: supporting_factlink.to_s).click

    find('.top-fact-text', text: supporting_factlink.to_s)
  end

  scenario "after clicking the factwheel, the impact and percentages should update" do
    go_to_discussion_page_of factlink

    supporting_factlink = backend_create_fact

{'fraction_non_alphanumeric': 0.05987634233647901, 'fraction_numerical': 0.0013016596160104132, 'mean_word_length': 4.23679727427598, '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': '6978365', 'n_tokens_mistral': 929, 'n_tokens_neox': 888, 'n_words': 273}