<commit_before>var async   = require('async'),
    chai    = require('chai'),
    expect  = chai.expect;

module.exports = function() {

  this.defineStep(/^(?:|I )browse "([^"]*)"$/, setBaseUrl);

  this.defineStep(/^(?:|I )am on (?:|the )homepage$/, iAmOnHomepage);
  this.defineStep(/^(?:|I )go to (?:|the )homepage$/, iAmOnHomepage);

  this.defineStep(/^(?:|I )am on "([^"]*)"$/, visit);
  this.defineStep(/^(?:|I )go to "([^"]*)"$/, visit);

  this.defineStep(/^(?:|I )am on "([^"]*)" and it should be an (\d+) error$/, visitWithError);
  this.defineStep(/^(?:|I )go to "([^"]*)" and it should be an (\d+) error$/, visitWithError);

  this.defineStep(/^(?:|I )reload the page$/, reload);
  this.defineStep(/^(?:|I )move backward one page$/, back);

  this.defineStep(/^(?:|I )press "([^"]*)"$/, pressButton);
  this.defineStep(/^(?:|I )follow "([^"]*)"$/, clickLink);

  this.defineStep(/^(?:|I )fill in "([^"]*)" with "([^"]*)"$/, fillField);
  this.defineStep(/^(?:|I )fill in "([^"]*)" with:$/, fillField);
  this.defineStep(/^(?:|I )fill in the following:$/, fillFields);

  this.defineStep(/^(?:|I )select "([^"]*)" from "([^"]*)"$/, selectOption);
  this.defineStep(/^(?:|I )check "([^"]*)"$/, checkOption);
  this.defineStep(/^(?:|I )uncheck "([^"]*)"$/, uncheckOption);

  this.defineStep(/^(?:|I )should be on "([^"]*)"$/, assertPageAddress);
  this.defineStep(/^(?:|I )should be on (?:|the )homepage$/, assertHomepage);
  this.defineStep(/^the url should match (.+)$/, assertUrlRegExp);

  this.defineStep(/^the response status code should be (\d+)$/, assertResponseStatus);
  this.defineStep(/^the response status code should not be (\d+)$/, assertResponseStatusIsNot);

  this.defineStep(/^(?:|I )should see "([^"]*)"$/, assertPageContainsText);
  this.defineStep(/^(?:|I )should not see "([^"]*)"$/, assertPageNotContainsText);
  this.defineStep(/^(?:|I )should see text matching (.+)$/, assertPageMatchesText);
  this.defineStep(/^(?:|I )should not see text matching (.+)$/, assertPageNotMatchesText);

  this.defineStep(/^(?:|I )should see "([^"]*)" in the "([^"]*)" element$/, assertElementContainsText);
  this.defineStep(/^(?:|I )should not see "([^"]*)" in the "([^"]*)" element$/, assertElementNotContainsText);

  this.defineStep(/^(?:|I )should see an? "([^"]*)" element$/, assertElementOnPage);
  this.defineStep(/^(?:|I )should not see an? "([^"]*)" element$/, assertElementNotOnPage);

  this.defineStep(/^the "([^"]*)" field should contain "([^"]*)"$/, assertFieldContains);
  this.defineStep(/^the "([^"]*)" field should not contain "([^"]*)"$/, assertFieldNotContains);

  this.defineStep(/^the "([^"]*)" checkbox should be checked$/, assertCheckboxChecked);
  this.defineStep(/^the checkbox "([^"]*)" (?:is|should be) checked$/, assertCheckboxChecked);

  this.defineStep(/^the "([^"]*)" checkbox should not be checked$/, assertCheckboxNotChecked);
  this.defineStep(/^the checkbox "([^"]*)" should (?:be unchecked|not be checked)$/, assertCheckboxNotChecked);
  this.defineStep(/^the checkbox "([^"]*)" is (?:unchecked|not checked)$/, assertCheckboxNotChecked);

  this.defineStep(/^(?:|I )should see (\d+) "([^"]*)" elements?$/, assertNumElements);
  this.defineStep(/^(?:|I )click on "([^"]*)"$/, click);

  this.defineStep(/^(?:|I )wait (\d+) seconds?$/, wait);

  ///////////////////////////

  function setBaseUrl (url, callback) {
    this.browser.site = url;
    callback();
  }

  function iAmOnHomepage (callback) {
    this.browser.visit('/', function (error, browser) {
      if (error) callback.fail(new Error("Can't load Homepage page !"));
      else callback();
    });
  }

  function visit (url, callback) {
    this.browser.visit(url, function (error, browser) {
      if (error) callback.fail(new Error("Can't load requested url ! " + error));
      else callback();
    });
  }

  function visitWithError (url, code, callback) {
    this.browser.visit(url, function (error) {
      expect(error).to.exist
        .and.be.instanceof(Error)
        .and.have.property('message').to.contain(code);
      callback();
    });
  }

  function reload (callback) {
    this.browser.reload(function (error, browser) {
      if (error) callback.fail(new Error("Can't reload current page ! " + error));
      else callback();
    });
  }

  function back (callback) {
    this.browser.back(function (error, browser) {
      if (error) callback.fail(new Error("Can't navigate to the previous page ! " + error));
      else callback();
    });
  }

  // CSS selector, button name or button text
  function pressButton (button, callback) {
    var element = this.browser.button(button);
    if (element) {
      this.browser.pressButton(button, callback);
    } else {
      callback.fail(new Error("Unable to find button|input with selector : " + button));
    }
  }

  // CSS selector or text contents (case sensitive, but ignores leading/trailing spaces)
  function clickLink (link, callback) {
    var element = this.browser.link(link);
    if (element) {
      this.browser.clickLink(link, callback);
    } else {
      callback.fail(new Error("Unable to find link with selector : " + link));
    }
  }

  function fillField (field, value, callback) {
    var element = this.browser.field(field);
    if (element) {
      this.browser.fill(field, value);
      callback();
    } else {
      callback.fail(new Error("Unable to find form field with selector|name : " + field));
    }
  }

  function fillFields (fields, callback) {
    var self = this;

    async.each(fields.raw(), function (row, cb) {
      var element = self.browser.field(row[0]);
      if (element) {
        self.browser.fill(row[0], row[1]);
        cb();
      } else {
        cb("Unable to find form field with selector|name|title : " + row[0]);
      }
    }, function (err) {
      if (err) callback.fail(new Error(err));
      else callback();
    });
  }

  function selectOption (option, select, callback) {
    var element = this.browser.field(select);
    if (element) {
      this.browser.select(select, option);
      callback();
    } else {
      callback.fail(new Error("Unable to find select field with selector : " + select + " or unavailable option : " + option));
    }
  }

  function checkOption (option, callback) {
    var element = this.browser.field(option);
    if (element) {
      this.browser.check(option);
      callback();
    } else {
      callback.fail(new Error("Unable to find checkbox field with selector|name : " + field));
    }
  }

  function uncheckOption (option, callback) {
    var element = this.browser.field(option);
    if (element) {
      this.browser.uncheck(option);
      callback();
    } else {
      callback.fail(new Error("Unable to find checkbox field with selector|name : " + field));
    }
  }
<commit_msg>Fix missing field inside mink<commit_after>var async   = require('async'),
    chai    = require('chai'),
    expect  = chai.expect;

module.exports = function() {

  this.defineStep(/^(?:|I )browse "([^"]*)"$/, setBaseUrl);

  this.defineStep(/^(?:|I )am on (?:|the )homepage$/, iAmOnHomepage);
  this.defineStep(/^(?:|I )go to (?:|the )homepage$/, iAmOnHomepage);

  this.defineStep(/^(?:|I )am on "([^"]*)"$/, visit);
  this.defineStep(/^(?:|I )go to "([^"]*)"$/, visit);

  this.defineStep(/^(?:|I )am on "([^"]*)" and it should be an (\d+) error$/, visitWithError);
  this.defineStep(/^(?:|I )go to "([^"]*)" and it should be an (\d+) error$/, visitWithError);

  this.defineStep(/^(?:|I )reload the page$/, reload);
  this.defineStep(/^(?:|I )move backward one page$/, back);

  this.defineStep(/^(?:|I )press "([^"]*)"$/, pressButton);
  this.defineStep(/^(?:|I )follow "([^"]*)"$/, clickLink);

  this.defineStep(/^(?:|I )fill in "([^"]*)" with "([^"]*)"$/, fillField);
  this.defineStep(/^(?:|I )fill in "([^"]*)" with:$/, fillField);
  this.defineStep(/^(?:|I )fill in the following:$/, fillFields);

  this.defineStep(/^(?:|I )select "([^"]*)" from "([^"]*)"$/, selectOption);
  this.defineStep(/^(?:|I )check "([^"]*)"$/, checkOption);
  this.defineStep(/^(?:|I )uncheck "([^"]*)"$/, uncheckOption);

  this.defineStep(/^(?:|I )should be on "([^"]*)"$/, assertPageAddress);
  this.defineStep(/^(?:|I )should be on (?:|the )homepage$/, assertHomepage);
  this.defineStep(/^the url should match (.+)$/, assertUrlRegExp);

  this.defineStep(/^the response status code should be (\d+)$/, assertResponseStatus);
  this.defineStep(/^the response status code should not be (\d+)$/, assertResponseStatusIsNot);

  this.defineStep(/^(?:|I )should see "([^"]*)"$/, assertPageContainsText);
  this.defineStep(/^(?:|I )should not see "([^"]*)"$/, assertPageNotContainsText);
  this.defineStep(/^(?:|I )should see text matching (.+)$/, assertPageMatchesText);
  this.defineStep(/^(?:|I )should not see text matching (.+)$/, assertPageNotMatchesText);

  this.defineStep(/^(?:|I )should see "([^"]*)" in the "([^"]*)" element$/, assertElementContainsText);
  this.defineStep(/^(?:|I )should not see "([^"]*)" in the "([^"]*)" element$/, assertElementNotContainsText);

  this.defineStep(/^(?:|I )should see an? "([^"]*)" element$/, assertElementOnPage);
  this.defineStep(/^(?:|I )should not see an? "([^"]*)" element$/, assertElementNotOnPage);

  this.defineStep(/^the "([^"]*)" field should contain "([^"]*)"$/, assertFieldContains);
  this.defineStep(/^the "([^"]*)" field should not contain "([^"]*)"$/, assertFieldNotContains);

  this.defineStep(/^the "([^"]*)" checkbox should be checked$/, assertCheckboxChecked);
  this.defineStep(/^the checkbox "([^"]*)" (?:is|should be) checked$/, assertCheckboxChecked);

  this.defineStep(/^the "([^"]*)" checkbox should not be checked$/, assertCheckboxNotChecked);
  this.defineStep(/^the checkbox "([^"]*)" should (?:be unchecked|not be checked)$/, assertCheckboxNotChecked);
  this.defineStep(/^the checkbox "([^"]*)" is (?:unchecked|not checked)$/, assertCheckboxNotChecked);

  this.defineStep(/^(?:|I )should see (\d+) "([^"]*)" elements?$/, assertNumElements);
  this.defineStep(/^(?:|I )click on "([^"]*)"$/, click);

  this.defineStep(/^(?:|I )wait (\d+) seconds?$/, wait);

  ///////////////////////////

  function setBaseUrl (url, callback) {
    this.browser.site = url;
    callback();
  }

  function iAmOnHomepage (callback) {
    this.browser.visit('/', function (error) {
      if (error) callback.fail(new Error("Can't load Homepage page !"));
      else callback();
    });
  }

  function visit (url, callback) {
    this.browser.visit(url, function (error) {
      if (error) callback.fail(new Error("Can't load requested url ! " + error));
      else callback();
    });
  }

  function visitWithError (url, code, callback) {
    this.browser.visit(url, function (error) {
      expect(error).to.exist
        .and.be.instanceof(Error)
        .and.have.property('message').to.contain(code);
      callback();
    });
  }

  function reload (callback) {
    this.browser.reload(function (error) {
      if (error) callback.fail(new Error("Can't reload current page ! " + error));
      else callback();
    });
  }

  function back (callback) {
    this.browser.back(function (error) {
      if (error) callback.fail(new Error("Can't navigate to the previous page ! " + error));
      else callback();
    });
  }

  // CSS selector, button name or button text
  function pressButton (button, callback) {
    var element = this.browser.button(button);
    if (element) {
      this.browser.pressButton(button, callback);
    } else {
      callback.fail(new Error("Unable to find button|input with selector : " + button));
    }
  }

  // CSS selector or text contents (case sensitive, but ignores leading/trailing spaces)
  function clickLink (link, callback) {
    var element = this.browser.link(link);
    if (element) {
      this.browser.clickLink(link, callback);
    } else {
      callback.fail(new Error("Unable to find link with selector : " + link));
    }
  }

  function fillField (field, value, callback) {
    var element = this.browser.field(field);
    if (element) {
      this.browser.fill(field, value);
      callback();
    } else {
      callback.fail(new Error("Unable to find form field with selector|name : " + field));
    }
  }

  function fillFields (fields, callback) {
    var self = this;

    async.each(fields.raw(), function (row, cb) {
      var element = self.browser.field(row[0]);
      if (element) {
        self.browser.fill(row[0], row[1]);
        cb();
      } else {
        cb("Unable to find form field with selector|name|title : " + row[0]);
      }
    }, function (err) {
      if (err) callback.fail(new Error(err));
      else callback();
    });
  }

  function selectOption (option, select, callback) {
    var element = this.browser.field(select);
    if (element) {
      this.browser.select(select, option);
      callback();
    } else {
      callback.fail(new Error("Unable to find select field with selector : " + select + " or unavailable option : " + option));
    }
  }

  function checkOption (option, callback) {
    var element = this.browser.field(option);
    if (element) {
      this.browser.check(option);
      callback();
    } else {
      callback.fail(new Error("Unable to find checkbox field with selector|name : " + option));
    }
  }

  function uncheckOption (option, callback) {
    var element = this.browser.field(option);
    if (element) {
      this.browser.uncheck(option);
      callback();
    } else {
      callback.fail(new Error("Unable to find checkbox field with selector|name : " + option));
    }
  }

{'fraction_non_alphanumeric': 0.20870206489675516, 'fraction_numerical': 0.0005899705014749262, 'mean_word_length': 3.59227903826617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7292561', 'n_tokens_mistral': 4438, 'n_tokens_neox': 4255, 'n_words': 1026}