<commit_before>/**
 * helper functions for e2e tests
 */

module.exports = {

  logout: logout,

  login: login,

  deleteAssetFromList: deleteAssetFromList,

  loginAsAdmin: function() {
    login('superadmin', 'admin', 'admin');
  }

};


// ----------------------------------------------------------------------------

function login(tenant, username, password) {

  browser.get('/login');
  element(by.id('loginTenant')).clear().sendKeys(tenant);
  element(by.id('loginUsername')).clear().sendKeys(username);
  element(by.id('loginPassword')).clear().sendKeys(password);
  element(by.partialButtonText('Submit')).click();
  expect(element(by.css('header .dropdown-toggle .fa-user')).isPresent()).toBe(true);

}

function deleteAssetFromList(list, name) {
  var selectedItem;
  list
    .then(function(s) {
      s.forEach(function(item, index) {
        item.getText().then(function(text) {
          if (text === name) {
            selectedItem = item;
          }
        });
      });
    })
    .then(function() {
      selectedItem.element(by.xpath("ancestor::tr"))
        .element(by.cssContainingText('.btn', 'Delete')).click();
      element(by.css('.modal-dialog .modal-footer .btn-primary')).click();
    });
}


function logout() {

  element(by.css('header .navbar-right .dropdown-toggle')).click();
  element(by.css('.dropdown-menu a[ng-click^="logout"]')).click();
  expect(element(by.css('header .dropdown-toggle .fa-user')).isPresent()).toBe(false);

}<commit_msg>Adds common edit-asset behavior as part of the helper function.<commit_after>/**
 * helper functions for e2e tests
 */

module.exports = {

  logout: logout,

  login: login,

  deleteAssetFromList: deleteAssetFromList,

  editAssetFromList: editAssetFromList,

  loginAsAdmin: function() {
    login('superadmin', 'admin', 'admin');
  }

};


// ----------------------------------------------------------------------------

function login(tenant, username, password) {

  browser.get('/login');
  element(by.id('loginTenant')).clear().sendKeys(tenant);
  element(by.id('loginUsername')).clear().sendKeys(username);
  element(by.id('loginPassword')).clear().sendKeys(password);
  element(by.partialButtonText('Submit')).click();
  expect(element(by.css('header .dropdown-toggle .fa-user')).isPresent()).toBe(true);

}

function deleteAssetFromList(list, name) {
  var selectedItem;
  list
    .then(function(s) {
      s.forEach(function(item, index) {
        item.getText().then(function(text) {
          if (text === name) {
            selectedItem = item;
          }
        });
      });
    })
    .then(function() {
      selectedItem.element(by.xpath("ancestor::tr"))
        .element(by.cssContainingText('.btn', 'Delete')).click();
      element(by.css('.modal-dialog .modal-footer .btn-primary')).click();
    });
}

function editAssetFromList(list, name) {
  var selectedItem;
  list
    .then(function(s) {
      s.forEach(function(item, index) {
        item.getText().then(function(text) {
          if (text === name) {
            selectedItem = item;
          }
        });
      });
    })
    .then(function() {
      selectedItem.element(by.xpath("ancestor::tr"))
        .element(by.cssContainingText('.btn', 'Edit')).click();
    });
}



function logout() {

  element(by.css('header .navbar-right .dropdown-toggle')).click();
  element(by.css('.dropdown-menu a[ng-click^="logout"]')).click();
  expect(element(by.css('header .dropdown-toggle .fa-user')).isPresent()).toBe(false);

}
{'fraction_non_alphanumeric': 0.2241921647126108, 'fraction_numerical': 0.0005719187875321705, 'mean_word_length': 2.8481848184818483, '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': '2249113', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1070, 'n_words': 154}