<commit_before>/* globals protractor, element, by, browser */
/**
 * @ngdoc overview
 * @name ui.grid.e2eTestLibrary
 * @description
 * End to end test functions.  Whenever these are updated, it may also be necessary
 * to update the associated tutorial.
 *
 */

/**
 * @ngdoc service
 * @name ui.grid.e2eTestLibrary.api:gridTest
 * @description
 * End to end test functions.  Whenever these are updated, it may also be necessary
 * to update the associated tutorial.
 *
 */
module.exports = {
  /**
  * Helper function that reloads the page between each test if the current browser is Firefox
  *
  * @example
  * <pre>
  *   gridTestUtils.firefoxReload();
  * </pre>
  */
  firefoxReload: function () {
    beforeEach(function () {
      return browser.getCapabilities().then(function (cap) {
        if (cap.caps_.browserName === 'firefox') {
          return browser.refresh()
            .then(function () {
              // Remove the fixed navbar, it overlays elements and intercepts events in Firefox
              return browser.driver.executeScript(function () {
                angular.element(document.getElementsByClassName('navbar')).remove();
              });
            });
        }
        else {
          return protractor.promise.when(true);
        }
      });
    });
  },

  isFirefox: function () {
    return browser.getCapabilities()
      .then(function (cap) {
        if (cap.caps_.browserName === 'firefox') {
          return true;
        }
        else {
         return false;
        }
      });
  },

  /**
  * Helper function that uses mouseMove/mouseDown/mouseUp for clicking.
  *
  * This is unfortunately needed because `.click()` doesn't work right in Firefox.
  *
  * @param element {WebElement}
  *
  * @returns {Promise} A promise that is resolved when the click has been performed.
  *
  * @example
  * <pre>
  *   gridTestUtils.click(element);
  * </pre>
  */
  click: function (element) {
    return browser.actions().mouseMove(element).mouseDown(element).mouseUp().perform();
  },

  /**
  * Helper function for returning a grid element.
  * @param gridId Id of grid to return.
  *
  * @returns {ElementFinder|Grid}  Grid wrapped in an ElementFinder
  *
  * @example
  * <pre>
  *   var grid = gridTestUtils.getGrid( 'myGrid' ); //or internally
  *   var row = this.getGrid( gridId );
  * </pre>
  */
  getGrid: function( gridId ) {
    return element( by.id( gridId ) );
  },

  /**
  * Helper function for returning a row.
  *
  * @param gridId {string}
  * @param rowNum {integer}
  *
  * @returns {ElementFinder|*}
  *
  * @example
  * <pre>
  *   var row = gridTestUtils.getRow( 'myGrid', 0); //or internally
  *   var row = this.getRow( gridId, rowNum );
  * </pre>
  */
  getRow: function( gridId, rowNum ) {
    return this.getGrid( gridId ).element( by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index').row( rowNum )  );
  },

  /**
  * Helper function to select a row.
  *
  * @param gridId {string}
  * @param rowNum {integer}
  *
  *
  * @example
  * <pre>
  *   var row = gridTestUtils.selectRow( 'myGrid', 0 );
  * </pre>
  */
  selectRow: function( gridId, rowNum ) {
    // NOTE: Can't do .click() as it doesn't work when webdriving Firefox
    var row = this.getRow( gridId, rowNum );
    return browser.actions().mouseMove(row).mouseDown(row).mouseUp().perform();
  },

  /**
  * @ngdoc method
  * @methodOf ui.grid.e2eTestLibrary.api:gridTest
  * @name expectRowCount
  * @description Checks that a grid has the specified number of rows. Note
  * that this only returns the number of rendered rows, and the grid does
  * row virtualisation - that is that the browser can only see the rendered
  * rows, not all the rows in the dataset.  This method is useful when doing
  * functional tests with small numbers of data, but typically with numbers
  * greater than about 10 you'll find that some of the rows are not rendered
  * and therefore an error is given.
  * @param {string} gridId the id of the grid that you want to inspect
  * @param {integer} expectedNumRows the number of visible rows you expect the
  * grid to have
  *
  * @example
  * <pre>
  *   gridTestUtils.expectRowCount('myGrid', 2);
  * </pre>
  *
  */
  expectRowCount: function( gridId, expectedNumRows ) {

    var rows = this.getGrid( gridId ).all( by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index') );
    expect(rows.count()).toEqual(expectedNumRows);
  },

  /**
  * @ngdoc method
  * @methodOf ui.grid.e2eTestLibrary.api:gridTest
  * @name expectHeaderColumnCount
  * @description Checks that a grid header body render container (the default render container)
  * has the specified number of columns.  If you are using pinned columns then you may also want
  * to check expectHeaderLeftColumnCount
  * @param {string} gridId the id of the grid that you want to inspect
  * @param {integer} expectedNumCols the number of visible columns you expect the<commit_msg>Fix bug: expectRowCount will get doubled row count if there is pinned columns<commit_after>/* globals protractor, element, by, browser */
/**
 * @ngdoc overview
 * @name ui.grid.e2eTestLibrary
 * @description
 * End to end test functions.  Whenever these are updated, it may also be necessary
 * to update the associated tutorial.
 *
 */

/**
 * @ngdoc service
 * @name ui.grid.e2eTestLibrary.api:gridTest
 * @description
 * End to end test functions.  Whenever these are updated, it may also be necessary
 * to update the associated tutorial.
 *
 */
module.exports = {
  /**
  * Helper function that reloads the page between each test if the current browser is Firefox
  *
  * @example
  * <pre>
  *   gridTestUtils.firefoxReload();
  * </pre>
  */
  firefoxReload: function () {
    beforeEach(function () {
      return browser.getCapabilities().then(function (cap) {
        if (cap.caps_.browserName === 'firefox') {
          return browser.refresh()
            .then(function () {
              // Remove the fixed navbar, it overlays elements and intercepts events in Firefox
              return browser.driver.executeScript(function () {
                angular.element(document.getElementsByClassName('navbar')).remove();
              });
            });
        }
        else {
          return protractor.promise.when(true);
        }
      });
    });
  },

  isFirefox: function () {
    return browser.getCapabilities()
      .then(function (cap) {
        if (cap.caps_.browserName === 'firefox') {
          return true;
        }
        else {
         return false;
        }
      });
  },

  /**
  * Helper function that uses mouseMove/mouseDown/mouseUp for clicking.
  *
  * This is unfortunately needed because `.click()` doesn't work right in Firefox.
  *
  * @param element {WebElement}
  *
  * @returns {Promise} A promise that is resolved when the click has been performed.
  *
  * @example
  * <pre>
  *   gridTestUtils.click(element);
  * </pre>
  */
  click: function (element) {
    return browser.actions().mouseMove(element).mouseDown(element).mouseUp().perform();
  },

  /**
  * Helper function for returning a grid element.
  * @param gridId Id of grid to return.
  *
  * @returns {ElementFinder|Grid}  Grid wrapped in an ElementFinder
  *
  * @example
  * <pre>
  *   var grid = gridTestUtils.getGrid( 'myGrid' ); //or internally
  *   var row = this.getGrid( gridId );
  * </pre>
  */
  getGrid: function( gridId ) {
    return element( by.id( gridId ) );
  },

  /**
  * Helper function for returning a row.
  *
  * @param gridId {string}
  * @param rowNum {integer}
  *
  * @returns {ElementFinder|*}
  *
  * @example
  * <pre>
  *   var row = gridTestUtils.getRow( 'myGrid', 0); //or internally
  *   var row = this.getRow( gridId, rowNum );
  * </pre>
  */
  getRow: function( gridId, rowNum ) {
    return this.getGrid( gridId ).element( by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index').row( rowNum )  );
  },

  /**
  * Helper function to select a row.
  *
  * @param gridId {string}
  * @param rowNum {integer}
  *
  *
  * @example
  * <pre>
  *   var row = gridTestUtils.selectRow( 'myGrid', 0 );
  * </pre>
  */
  selectRow: function( gridId, rowNum ) {
    // NOTE: Can't do .click() as it doesn't work when webdriving Firefox
    var row = this.getRow( gridId, rowNum );
    return browser.actions().mouseMove(row).mouseDown(row).mouseUp().perform();
  },

  /**
  * @ngdoc method
  * @methodOf ui.grid.e2eTestLibrary.api:gridTest
  * @name expectRowCount
  * @description Checks that a grid has the specified number of rows. Note
  * that this only returns the number of rendered rows, and the grid does
  * row virtualisation - that is that the browser can only see the rendered
  * rows, not all the rows in the dataset.  This method is useful when doing
  * functional tests with small numbers of data, but typically with numbers
  * greater than about 10 you'll find that some of the rows are not rendered
  * and therefore an error is given.
  * @param {string} gridId the id of the grid that you want to inspect
  * @param {integer} expectedNumRows the number of visible rows you expect the
  * grid to have
  *
  * @example
  * <pre>
  *   gridTestUtils.expectRowCount('myGrid', 2);
  * </pre>
  *
  */
  expectRowCount: function( gridId, expectedNumRows ) {

    var rows = this.getGrid( gridId ).element( by.css('.ui-grid-render-container-body')).all( by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index') );
    expect(rows.count()).toEqual(expectedNumRows);
  },

  /**
  * @ngdoc method
  * @methodOf ui.grid.e2eTestLibrary.api:gridTest
  * @name expectHeaderColumnCount
  * @description Checks that a grid header body render container (the default render container)
  * has the specified number of columns.  If you are using pinned columns then you may also want
  * to check expectHeaderLeftColumnCount
  * @param {string} gridId the id of the grid that you want to inspect
  * @param {integer} expectedNumCols the number of visible columns you expect the
{'fraction_non_alphanumeric': 0.11576330183988065, 'fraction_numerical': 0.0017901541521631028, 'mean_word_length': 2.8991857309034508, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '1759850', 'n_tokens_mistral': 3076, 'n_tokens_neox': 3018, 'n_words': 990}