<commit_before>require 'integration_helper'

feature "sub_comments", type: :request do
  include Acceptance::FactHelper
  include Pavlov::Helpers

  background do
    @user_a = sign_in_user create :approved_confirmed_user
    @user_b = create :approved_confirmed_user

    @factlink_user_a = create :fact, created_by: @user_a.graph_user
  end

  def add_sub_comment(comment)
    fill_in 'text_area_view', with: comment
    find('.evidence-sub-comments-button', text: 'Comment').click
    find('.evidence-sub-comment-content').should have_content comment
  end

  def switch_to_user(user)
    sign_out_user
    sign_in_user @user_b
  end

  scenario "A user can comment on a comment" do
    @comment_user_b = command :create_comment, @factlink_user_a.id.to_i, "believes", "test", @user_b.id.to_s

    sub_comment_text = "Sub Comment 1"

    go_to_discussion_page_of @factlink_user_a

    find('.js-sub-comments-link', text: 'Comments').click

    add_sub_comment(sub_comment_text)

    switch_to_user(@user_b)

    go_to_discussion_page_of @factlink_user_a

    find('.js-sub-comments-link', text: 'Comments').click
    find('.evidence-sub-comment-content').should have_content sub_comment_text
  end

  scenario "A user can comment on a fact relation" do
    @fact_relation_user_b = create :fact, created_by: @user_b.graph_user
    @factlink_user_a.add_evidence("supporting", @fact_relation_user_b, @user_b)

    sub_comment_text = "Sub Comment 1"

    go_to_discussion_page_of @factlink_user_a

    find('.js-sub-comments-link', text: 'Comments').click
<commit_msg>switch_to_user was already present in Acceptance, thanks @janpaul123<commit_after>require 'integration_helper'

feature "sub_comments", type: :request do
  include Acceptance::FactHelper
  include Pavlov::Helpers

  background do
    @user_a = sign_in_user create :approved_confirmed_user
    @user_b = create :approved_confirmed_user

    @factlink_user_a = create :fact, created_by: @user_a.graph_user
  end

  def add_sub_comment(comment)
    fill_in 'text_area_view', with: comment
    find('.evidence-sub-comments-button', text: 'Comment').click
    find('.evidence-sub-comment-content').should have_content comment
  end

  scenario "A user can comment on a comment" do
    @comment_user_b = command :create_comment, @factlink_user_a.id.to_i, "believes", "test", @user_b.id.to_s

    sub_comment_text = "Sub Comment 1"

    go_to_discussion_page_of @factlink_user_a

    find('.js-sub-comments-link', text: 'Comments').click

    add_sub_comment(sub_comment_text)

    switch_to_user(@user_b)

    go_to_discussion_page_of @factlink_user_a

    find('.js-sub-comments-link', text: 'Comments').click
    find('.evidence-sub-comment-content').should have_content sub_comment_text
  end

  scenario "A user can comment on a fact relation" do
    @fact_relation_user_b = create :fact, created_by: @user_b.graph_user
    @factlink_user_a.add_evidence("supporting", @fact_relation_user_b, @user_b)

    sub_comment_text = "Sub Comment 1"

    go_to_discussion_page_of @factlink_user_a

    find('.js-sub-comments-link', text: 'Comments').click

{'fraction_non_alphanumeric': 0.10128617363344052, 'fraction_numerical': 0.0022508038585209, 'mean_word_length': 4.687385740402194, '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': '6529854', 'n_tokens_mistral': 1095, 'n_tokens_neox': 1031, 'n_words': 217}