<commit_before>/* eslint-env jquery */
/* global chai */
/* eslint-disable no-unused-vars */
const {expect} = chai
chai.should()
chai.config.truncateThreshold = 0

const eventTimeout = 15000

function loadPage(path, predicate) {
  if (!predicate) {
    throw new Error('No predicate defined')
  }
  const newTestFrame = $('<iframe/>').attr({src: path, width: 1200, height: 800, id: 'testframe'})
  $('#testframe').replaceWith(newTestFrame)
  return waitUntil(predicate, eventTimeout)()
}

function testFrame() {
  return $('#testframe').get(0).contentWindow
}

function S(selector) {
  return Array.prototype.slice.call(testFrame().document.querySelectorAll(selector))
}

function waitUntil(predicate, timeout) {
  const wait = timeout ? timeout : 3000
  return function () {
    const started = Date.now()
    return (function loop() {
      return Promise.resolve(predicate()).then((result) => {
        if (result) {
          return result
        } else if (Date.now() - started < wait) {
          return Promise.delay(1000).then(loop)
        } else {
          throw new Error(`Couldn't fill predicate in ${wait / 1000} seconds`)
        }
      })
    })()
  }
}

function getWindowUrl() {
  return testFrame().location.href
}

function getSelectedCoursesFromUrl() {
  return getWindowUrl()
    .replace(/[\w\/:]+\?courses=/, '')<commit_msg>Fix linter issue<commit_after>/* eslint-env jquery */
/* global chai */
/* eslint-disable no-unused-vars */
const {expect} = chai
chai.should()
chai.config.truncateThreshold = 0

const eventTimeout = 15000

function loadPage(path, predicate) {
  if (!predicate) {
    throw new Error('No predicate defined')
  }
  const newTestFrame = $('<iframe/>').attr({src: path, width: 1200, height: 800, id: 'testframe'})
  $('#testframe').replaceWith(newTestFrame)
  return waitUntil(predicate, eventTimeout)()
}

function testFrame() {
  return $('#testframe').get(0).contentWindow
}

function S(selector) {
  return Array.prototype.slice.call(testFrame().document.querySelectorAll(selector))
}

function waitUntil(predicate, timeout) {
  const waitValue = timeout ? timeout : 3000
  return function () {
    const started = Date.now()
    return (function loop() {
      return Promise.resolve(predicate()).then((result) => {
        if (result) {
          return result
        } else if (Date.now() - started < waitValue) {
          return Promise.delay(1000).then(loop)
        } else {
          throw new Error(`Couldn't fill predicate in ${waitValue / 1000} seconds`)
        }
      })
    })()
  }
}

function getWindowUrl() {
  return testFrame().location.href
}

function getSelectedCoursesFromUrl() {
  return getWindowUrl()
    .replace(/[\w\/:]+\?courses=/, '')
{'fraction_non_alphanumeric': 0.15305371596762327, 'fraction_numerical': 0.01913171449595291, 'mean_word_length': 3.4500818330605565, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7187698', 'n_tokens_mistral': 879, 'n_tokens_neox': 822, 'n_words': 194}