<commit_before># encoding: utf-8
require 'browser_test_helper'

class FacebookBrowserTest < TestCase
  def test_add_config

    # app config
    if !ENV['FACEBOOK_APP_ID']
      fail "ERROR: Need FACEBOOK_APP_ID - hint FACEBOOK_APP_ID='1234'"
    end
    app_id = ENV['FACEBOOK_APP_ID']
    if !ENV['FACEBOOK_APP_SECRET']
      fail "ERROR: Need FACEBOOK_APP_SECRET - hint FACEBOOK_APP_SECRET='1234'"
    end
    app_secret = ENV['FACEBOOK_APP_SECRET']
    if !ENV['FACEBOOK_USER_LOGIN']
      fail "ERROR: Need FACEBOOK_USER_LOGIN - hint FACEBOOK_USER_LOGIN='1234'"
    end
    user_login = ENV['FACEBOOK_USER_LOGIN']
    if !ENV['FACEBOOK_USER_PW']
      fail "ERROR: Need FACEBOOK_USER_PW - hint FACEBOOK_USER_PW='<PASSWORD>'"
    end
    user_pw = ENV['FACEBOOK_USER_PW']

    @browser = browser_instance
    login(
      username: '<EMAIL>',
      password: '<PASSWORD>',
      url: browser_url,
      auto_wizard: true,
    )
    tasks_close_all()

    click(css: 'a[href="#manage"]')
    click(css: 'a[href="#channels/facebook"]')

    click(css: '#content .js-configApp')
    sleep 2
    set(
      css: '#content .modal [name=application_id]',
      value: app_id,
    )
    set(
      css: '#content .modal [name=application_secret]',
      value: 'wrong',
    )
    click(css: '#content .modal .js-submit')

    watch_for(
      css: '#content .modal .alert',
      value: 'Error',
    )

    set(
      css: '#content .modal [name=application_secret]',
      value: app_secret,
    )
    click(css: '#content .modal .js-submit')

    watch_for_disappear(
      css: '#content .modal .alert',
      value: 'Error',
    )

    watch_for(
      css: '#content .js-new',
      value: 'add account',
    )

    click(css: '#content .js-configApp')

    set(
      css: '#content .modal [name=application_secret]',
      value: 'wrong',
    )
    click(css: '#content .modal .js-submit')

    watch_for(
      css: '#content .modal .alert',
      value: 'Error',
    )

    set(
      css: '#content .modal [name=application_secret]',
      value: app_secret,
    )
    click(css: '#content .modal .js-submit')

    watch_for_disappear(
      css: '#content .modal .alert',
      value: 'Error',
    )

    watch_for(
      css: '#content .js-new',
      value: 'add account',
    )

    click(css: '#content .js-new')

    watch_for(
      css: 'body',
      value: 'Facebook Login',
    )

    set(
      css: '#email',
      value: user_login,
    )
    set(
      css: '#pass',
      value: user_pw,
    )<commit_msg>Improved test.<commit_after># encoding: utf-8
require 'browser_test_helper'

class FacebookBrowserTest < TestCase
  def test_add_config

    # app config
    if !ENV['FACEBOOK_APP_ID']
      fail "ERROR: Need FACEBOOK_APP_ID - hint FACEBOOK_APP_ID='1234'"
    end
    app_id = ENV['FACEBOOK_APP_ID']
    if !ENV['FACEBOOK_APP_SECRET']
      fail "ERROR: Need FACEBOOK_APP_SECRET - hint FACEBOOK_APP_SECRET='1234'"
    end
    app_secret = ENV['FACEBOOK_APP_SECRET']
    if !ENV['FACEBOOK_USER_LOGIN']
      fail "ERROR: Need FACEBOOK_USER_LOGIN - hint FACEBOOK_USER_LOGIN='1234'"
    end
    user_login = ENV['FACEBOOK_USER_LOGIN']
    if !ENV['FACEBOOK_USER_PW']
      fail "ERROR: Need FACEBOOK_USER_PW - hint FACEBOOK_USER_PW='<PASSWORD>'"
    end
    user_pw = ENV['FACEBOOK_USER_PW']

    @browser = browser_instance
    login(
      username: '<EMAIL>',
      password: '<PASSWORD>',
      url: browser_url,
      auto_wizard: true,
    )
    tasks_close_all()

    click(css: 'a[href="#manage"]')
    click(css: 'a[href="#channels/facebook"]')

    click(css: '#content .js-configApp')
    sleep 2
    set(
      css: '#content .modal [name=application_id]',
      value: app_id,
    )
    set(
      css: '#content .modal [name=application_secret]',
      value: 'wrong',
    )
    click(css: '#content .modal .js-submit')

    watch_for(
      css: '#content .modal .alert',
      value: 'Error',
    )

    set(
      css: '#content .modal [name=application_secret]',
      value: app_secret,
    )
    click(css: '#content .modal .js-submit')

    watch_for_disappear(
      css: '#content .modal .alert',
      value: 'Error',
    )

    watch_for(
      css: '#content .js-new',
      value: 'add account',
    )

    click(css: '#content .js-configApp')

    set(
      css: '#content .modal [name=application_secret]',
      value: 'wrong',
    )
    click(css: '#content .modal .js-submit')

    watch_for(
      css: '#content .modal .alert',
      value: 'Error',
    )

    set(
      css: '#content .modal [name=application_secret]',
      value: app_secret,
    )
    click(css: '#content .modal .js-submit')

    watch_for_disappear(
      css: '#content .modal .alert',
      value: 'Error',
    )

    watch_for(
      css: '#content .js-new',
      value: 'add account',
    )

    click(css: '#content .js-new')

    watch_for(
      css: 'body',
      value: '(Facebook Login|Log into Facebook)',
    )

    set(
      css: '#email',
      value: user_login,
    )
    set(
      css: '#pass',
      value: user_pw,
    )
{'fraction_non_alphanumeric': 0.1426600985221675, 'fraction_numerical': 0.005517241379310344, 'mean_word_length': 2.54221912072575, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7138331', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1794, 'n_words': 387}