<commit_before>// this file adds global variables -- not generally a good idea but for
// cucumber tests it's handy
var path = require('path');
global._ = require('lodash');
global.q = require('q');
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
global.expect = chai.expect;

var ptor = require('protractor').getInstance();

var util = require('util');

var pages = {};

var self;
function World (callback) {
  self = this;
  this.pages = pages;
  this.currentPage = null;
  callback(this);
}

var PageBase = require('./page-objects/PageBase');

World.addPage = function (Page) {
  var page = PageBase.instantiate(Page);
  pages[Page.pageName] = page;
  _.forEach(Page.aliases, function (alias) {
    pages[alias] = page;
  });
};

World.prototype.go = function (page) {
  return ptor.get(page.url).then(
    function () {
      self.currentPage = page;
    }
  );
  //   var setAndReturn = function () {
  //   this.currentPage = page;
  // };
  //
  // var doGo = function () {
  //   console.log('gonna doGo');
  //   return browser.driver.get(page.url).then(function () {
  //     console.log('did go');
  //     this.currentPage = page;
  //   });
  //
  // };
  //
  // console.log('getCurrentUrl');
  // try {
  //   return browser.driver.getCurrentUrl().then(
  //     function (currentUrl) {
  //       if (currentUrl === page.url) {
  //         console.log('current url!!!');
  //         return setAndReturn();
  //       }
  //       else {
  //         console.log('no current url');
  //         return browser.wait().then(doGo);
  //       }
  //     },
  //     function () {
  //       console.log('gonna wait');
  //       return browser.wait().then(doGo);
  //     }
  //   );
  // }
  // catch (err) {
  //   console.log('it has to be one or the other');
  //   console.log(err);
  // }
};

World.prototype.authenticateAs = function (userName, password) {
  var goPage;
  if (!self.currentPage) {
    goPage = self.go(self.pages.default);
  }
  return q.when(goPage, function () {
    if (userName) {
      return self.currentPage.loginIfNecessary(userName, password);
    }<commit_msg>e2e: work around cucumber next callback -> notifyOk<commit_after>// this file adds global variables -- not generally a good idea but for
// cucumber tests it's handy
var path = require('path');
global._ = require('lodash');
global.q = require('q');
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
global.expect = chai.expect;

var ptor = require('protractor').getInstance();

var util = require('util');

var pages = {};

var self;
function World (callback) {
  self = this;
  this.pages = pages;
  this.currentPage = null;
  callback(this);
}

var PageBase = require('./page-objects/PageBase');

World.addPage = function (Page) {
  var page = PageBase.instantiate(Page);
  pages[Page.pageName] = page;
  _.forEach(Page.aliases, function (alias) {
    pages[alias] = page;
  });
};

World.prototype.go = function (page) {
  return ptor.get(page.url).then(
    function () {
      self.currentPage = page;
    }
  );
};

var notifyOk = function (next) {
  return function () {
    next();
  };
};

World.prototype.notifyOk = notifyOk;

World.prototype.authenticateAs = function (userName, password) {
  var goPage;
  if (!self.currentPage) {
    goPage = self.go(self.pages.default);
  }
  return q.when(goPage, function () {
    if (userName) {
      return self.currentPage.loginIfNecessary(userName, password);
    }
{'fraction_non_alphanumeric': 0.1693046919163369, 'fraction_numerical': 0.0002826455624646693, 'mean_word_length': 2.821814254859611, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3816677', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1172, 'n_words': 256}