<commit_before>require 'spec_helper'

feature "Event streaming", js: true do
  let!(:author) { FactoryGirl.create :user, :admin }
  let!(:journal) { FactoryGirl.create :journal }
  let!(:paper) { FactoryGirl.create :paper, :with_tasks, user: author, journal: journal }
  let(:upload_task) { paper.tasks_for_type(UploadManuscript::Task).first }

  before do
    sign_in_page = SignInPage.visit
    sign_in_page.sign_in author
  end

  scenario "On the dashboard page" do
    expect(page).to have_css(".dashboard-header")
    expect(page).to have_no_selector(".completed")
    upload_task.completed = true
    upload_task.save
    expect(page).to have_css(".card-completed", count: 1)
  end

  describe "manuscript manager" do
    before do
      edit_paper = EditPaperPage.visit paper
      edit_paper.visit_task_manager
    end

    let(:submission_phase) { paper.phases.find_by_name("Submission Data") }

    scenario "creating a new message task" do
      mt = submission_phase.tasks.new title: "Wicked Message Card", type: "MessageTask", body: "Hi there!", role: "user"
      mt.participants << author
      mt.save!

      phase = all('.column').detect {|p| p.find('h2').text == "Submission Data" }
      within phase do
        expect(page).to have_content "Wicked Message Card"
      end
    end

    scenario "creating a new task" do
      submission_phase.tasks.create title: "Wicked Awesome Card", type: "Task", body: "Hi there!", role: "admin"

      phase = all('.column').detect {|p| p.find('h2').text == "Submission Data" }
      within phase do
        expect(page).to have_content "Wicked Awesome Card"
      end
    end

    scenario "deleting a task" do
      submission_phase.tasks.where(title: 'Add Authors').first.destroy!

      phase = all('.column').detect { |p| p.find('h2').text == "Submission Data" }
      within phase do
        expect(page).to_not have_content "Add Authors"
      end
    end
  end

  describe "message tasks" do
    before do
      edit_paper = EditPaperPage.visit paper
      edit_paper.visit_task_manager
      submission_phase = paper.phases.find_by_name("Submission Data")
      @mt = submission_phase.tasks.new title: "Wicked Message Card", type: "MessageTask", body: "Hi there!", role: "user"
      @mt.participants << author
      @mt.save!
      find('.card-content', text: "Wicked Message Card").click
      expect(page).to have_css(".overlay-content")
    end

    scenario "adding new comments" do
      @mt.comments.create body: "Hey-o", commenter_id: create(:user).id
      within '.message-comments' do
        expect(page).to have_content "Hey-o"
      end
    end
<commit_msg>Failing test.<commit_after>require 'spec_helper'

feature "Event streaming", js: true do
  let!(:author) { FactoryGirl.create :user, :admin }
  let!(:journal) { FactoryGirl.create :journal }
  let!(:paper) { FactoryGirl.create :paper, :with_tasks, user: author, journal: journal }
  let(:upload_task) { paper.tasks_for_type(UploadManuscript::Task).first }

  before do
    sign_in_page = SignInPage.visit
    sign_in_page.sign_in author
  end

  scenario "On the dashboard page" do
    expect(page).to have_css(".dashboard-header")
    expect(page).to have_no_selector(".completed")
    upload_task.completed = true
    upload_task.save
    expect(page).to have_css(".card-completed", count: 1)
  end

  describe "manuscript manager" do
    before do
      edit_paper = EditPaperPage.visit paper
      edit_paper.visit_task_manager
    end

    let(:submission_phase) { paper.phases.find_by_name("Submission Data") }

    scenario "creating a new message task" do
      mt = submission_phase.tasks.new title: "Wicked Message Card", type: "MessageTask", body: "Hi there!", role: "user"
      mt.participants << author
      mt.save!

      phase = all('.column').detect {|p| p.find('h2').text == "Submission Data" }
      within phase do
        expect(page).to have_content "Wicked Message Card"
      end
    end

    scenario "creating a new task" do
      submission_phase.tasks.create title: "Wicked Awesome Card", type: "Task", body: "Hi there!", role: "admin"

      phase = all('.column').detect {|p| p.find('h2').text == "Submission Data" }
      within phase do
        expect(page).to have_content "Wicked Awesome Card"
      end
    end

    scenario "deleting a task" do
      submission_phase.tasks.where(title: 'Add Authors').first.destroy!

      phase = all('.column').detect { |p| p.find('h2').text == "Submission Data" }
      within phase do
        expect(page).to_not have_content "Add Authors"
      end
    end
  end

  describe "message tasks" do
    before do
      TaskManagerPage.visit paper
      submission_phase = paper.phases.find_by_name("Submission Data")
      @mt = submission_phase.tasks.new title: "Wicked Message Card", type: "MessageTask", body: "Hi there!", role: "user"
      @mt.participants << author
      @mt.save!
      find('.card-content', text: "Wicked Message Card").click
      expect(page).to have_css(".overlay-content")
    end

    scenario "adding new comments" do
      @mt.comments.create body: "Hey-o", commenter_id: create(:user).id
      within '.message-comments' do
        expect(page).to have_css('.message-comment.unread', text: "Hey-o")
      end
    end

{'fraction_non_alphanumeric': 0.12469112336057783, 'fraction_numerical': 0.001520623455616803, 'mean_word_length': 3.2401289282836423, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1989699', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1621, 'n_words': 432}