<commit_before>require 'rails_helper'

describe 'Login and logout', type: :feature, js: true do

  def fill_in_form
    fill_in "Email address", with: user.email
    fill_in "Password",      with: user.identity.password
  end

  context 'Login with correct data' do

    let!(:circle) { submit_form(:circle_create_form).result }
    let!(:user) do
      user = create(:user, primary_circle: circle)
      circle.roles.send('circle.volunteer').create user: user
      user
    end

    it 'works (as well as logout)' do
      visit root_path
      fill_in_form
      click_on "Sign in"
      expect(page).to have_content(t('circles.show..dashboard_title', name: circle.name))

      find('.user-name').click
      click_on t('layouts.internal.header.sign-out')
      expect(page).to have_content(t('sessions.new.sign-in-phrase'))
    end
  end


  context 'Login with incorrect data' do

    let!(:user) do 
      user = create(:user)
      user.identity.password = "<PASSWORD>"
      user
    end
<commit_msg>Add some finders to delay the test until items are visible<commit_after>require 'rails_helper'

describe 'Login and logout', type: :feature, js: true do

  def fill_in_form
    fill_in "Email address", with: user.email
    fill_in "Password",      with: <PASSWORD>
  end

  context 'Login with correct data', :ci_ignore do

    let!(:circle) { submit_form(:circle_create_form).result }
    let!(:user) do
      user = create(:user, primary_circle: circle)
      circle.roles.send('circle.volunteer').create user: user
      user
    end

    it 'works (as well as logout)' do
      visit root_path
      fill_in_form
      click_on "Sign in"
      expect(page).to have_content(t('circles.show..dashboard_title', name: circle.name))

      find('.user-name').click
      find('.user-dropdown') # #find waits until the selector becomes available
      click_on t('layouts.internal.header.sign-out')
      find('body.public h2') # #find waits until the selector becomes available
      expect(page).to have_content(t('sessions.new.sign-in-phrase'))
    end
  end


  context 'Login with incorrect data' do

    let!(:user) do 
      user = create(:user)
      user.identity.password = "<PASSWORD>"
      user
    end

{'fraction_non_alphanumeric': 0.11560953666216824, 'fraction_numerical': 0.000449842555105713, 'mean_word_length': 3.0732600732600734, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '5420492', 'n_tokens_mistral': 705, 'n_tokens_neox': 682, 'n_words': 188}