<commit_before>import {sampleSize} from 'lodash'
import landingPage from './pages/landing.page'
import {generateToken} from './jwt_helper'

export {landingPage}

export const getRandomString = length => sampleSize('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', length).join('')

export const startCensusQuestionnaire = (schema, sexualIdentity = false, region = 'GB-ENG', language = 'en') => {
  generateToken(schema, getRandomString(10), getRandomString(10), null, null, region, language, sexualIdentity)
    .then(function(token) {
      return browser.url('/session?token=' + token)
    })

  browser.pause(1000) // Shudder!!!
}

export function openQuestionnaire(schema, userId = getRandomString(10), collectionId = getRandomString(10), periodId = '201605', periodStr = 'May 2016') {
  generateToken(schema, userId, collectionId, periodId, periodStr)
    .then(function(token) {
      return browser.url('/session?token=' + token)
    })

  browser.pause(1000) // Shudder!!!
}

export function startQuestionnaire(schema, userId = getRandomString(10), collectionId = getRandomString(10)) {
  openQuestionnaire(schema, userId, collectionId)

  browser.pause(1000) // Shudder!!!

  landingPage.getStarted()
}

export function getElementId(element) {
  return browser.elementIdAttribute(element.value.ELEMENT, 'id').value
}

export const getBlockId = () => {
  return getLocation().blockId
}

export const getRepeatedGroup = () => {
  return getLocation().repeatedGroup
}

export const getLocation = () => {
  // Matches: /(groupId)/(blockId)<commit_msg>Investigate Travis Functional Test Failures<commit_after>import {sampleSize} from 'lodash'
import landingPage from './pages/landing.page'
import {generateToken} from './jwt_helper'

export {landingPage}

export const getRandomString = length => sampleSize('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', length).join('')

export const startCensusQuestionnaire = (schema, sexualIdentity = false, region = 'GB-ENG', language = 'en') => {
  generateToken(schema, getRandomString(10), getRandomString(10), null, null, region, language, sexualIdentity)
    .then(function(token) {
      return browser.url('/session?token=' + token)
    })

  browser.pause(2000) // Double Shudder!!!
}

export function openQuestionnaire(schema, userId = getRandomString(10), collectionId = getRandomString(10), periodId = '201605', periodStr = 'May 2016') {
  generateToken(schema, userId, collectionId, periodId, periodStr)
    .then(function(token) {
      return browser.url('/session?token=' + token)
    })

  browser.pause(2000) // Double Shudder!!!
}

export function startQuestionnaire(schema, userId = getRandomString(10), collectionId = getRandomString(10)) {
  openQuestionnaire(schema, userId, collectionId)

  landingPage.getStarted()
}

export function getElementId(element) {
  return browser.elementIdAttribute(element.value.ELEMENT, 'id').value
}

export const getBlockId = () => {
  return getLocation().blockId
}

export const getRepeatedGroup = () => {
  return getLocation().repeatedGroup
}

export const getLocation = () => {
  // Matches: /(groupId)/(blockId)
{'fraction_non_alphanumeric': 0.1355275895450145, 'fraction_numerical': 0.027105517909002903, 'mean_word_length': 5.431535269709544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3598748', 'n_tokens_mistral': 986, 'n_tokens_neox': 923, 'n_words': 205}