<commit_before>// Copyright 2014 The Oppia Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Minor general functional components for end-to-end testing
 * with protractor.
 */

var _ = require('lodash');

var ExplorationEditorPage = require(
  '../protractor_utils/ExplorationEditorPage.js');
var waitFor = require('./waitFor.js');
var dragAndDropScript = require('html-dnd').code;
var action = require('../protractor_utils/action.js');

var dragAndDrop = async function(fromElement, toElement) {
  await waitFor.visibilityOf(
    fromElement,
    'fromElement taking too long to load');
  await waitFor.visibilityOf(
    toElement,
    'toElement taking too long to load');
  await browser.executeScript(dragAndDropScript, fromElement, toElement);
};

var scrollToTop = async function() {
  await browser.executeScript('window.scrollTo(0,0);');
};

// The minimum log level we will report as an error.
var CONSOLE_LOG_THRESHOLD = 900;
var CONSOLE_ERRORS_TO_IGNORE = [
  // These "localhost:9099" are errors related to communicating with the
  // Firebase emulator, which would never occur in production, so we just ignore
  // them.
  _.escapeRegExp(
    'http://localhost:9099/www.googleapis.com/identitytoolkit/v3/' +
    'relyingparty/getAccountInfo?key=fake-api-key'),
  _.escapeRegExp(
    'http://localhost:9099/www.googleapis.com/identitytoolkit/v3/' +
    'relyingparty/verifyPassword?key=fake-api-key'),
];

var checkForConsoleErrors = async function(errorsToIgnore) {
  errorsToIgnore = errorsToIgnore.concat(CONSOLE_ERRORS_TO_IGNORE);<commit_msg>Resolving "https://pencilcode.net/lib/pencilcodeembed.js - Failed to load resource: net::ERR_CERT_DATE_INVALID" error  (#13455)<commit_after>// Copyright 2014 The Oppia Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Minor general functional components for end-to-end testing
 * with protractor.
 */

var _ = require('lodash');

var ExplorationEditorPage = require(
  '../protractor_utils/ExplorationEditorPage.js');
var waitFor = require('./waitFor.js');
var dragAndDropScript = require('html-dnd').code;
var action = require('../protractor_utils/action.js');

var dragAndDrop = async function(fromElement, toElement) {
  await waitFor.visibilityOf(
    fromElement,
    'fromElement taking too long to load');
  await waitFor.visibilityOf(
    toElement,
    'toElement taking too long to load');
  await browser.executeScript(dragAndDropScript, fromElement, toElement);
};

var scrollToTop = async function() {
  await browser.executeScript('window.scrollTo(0,0);');
};

// The minimum log level we will report as an error.
var CONSOLE_LOG_THRESHOLD = 900;
var CONSOLE_ERRORS_TO_IGNORE = [
  // These "localhost:9099" are errors related to communicating with the
  // Firebase emulator, which would never occur in production, so we just ignore
  // them.
  _.escapeRegExp(
    'http://localhost:9099/www.googleapis.com/identitytoolkit/v3/' +
    'relyingparty/getAccountInfo?key=fake-api-key'),
  _.escapeRegExp(
    'http://localhost:9099/www.googleapis.com/identitytoolkit/v3/' +
    'relyingparty/verifyPassword?key=fake-api-key'),
  // This error covers the case when the PencilCode site uses an
  // invalid SSL certificate (which can happen when it expires).
  // In such cases, we ignore the error since it is out of our control.
  _.escapeRegExp(
    'https://pencilcode.net/lib/pencilcodeembed.js - Failed to ' +
    'load resource: net::ERR_CERT_DATE_INVALID'),
];

var checkForConsoleErrors = async function(errorsToIgnore) {
  errorsToIgnore = errorsToIgnore.concat(CONSOLE_ERRORS_TO_IGNORE);
{'fraction_non_alphanumeric': 0.10983152058008104, 'fraction_numerical': 0.012582640221795692, 'mean_word_length': 4.1937984496124034, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, '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': '3816758', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1349, 'n_words': 434}