<commit_before>var utils = require('./utils.js');
var pages = require('./pages.js');

describe('admin add, configure, and delete users', function() {
  var adminLog = new pages.adminLoginPage();
  var new_users = [
    {
      role: "Recipient",
      name: "<NAME>", 
      address: "<EMAIL>",
    },
    {
      role: "Recipient",
      name: "<NAME>", 
      address: "<EMAIL>",
    },
    {
      role: "Recipient",
      name: "<NAME>",
      address: "<EMAIL>",
    },
    {
      role: "Recipient",
      name: "<NAME>",
      address: "<EMAIL>",
    },
    {
      role: "Custodian",
      name: "<NAME>", 
      address: "<EMAIL>",
    },
  ];

  beforeAll(function() {
    adminLog.login('admin', 'ACollectionOfDiplomaticHistorySince_1966_ToThe_Pr esentDay#');
    browser.setLocation('admin/users');
  });

  it('should add new users', function() {
    var make_account = function(user) {
      element(by.model('new_user.name')).sendKeys(user.name);
      element(by.model('new_user.email')).sendKeys(user.address);
      element(by.model('new_user.role')).element(by.xpath(".//*[text()='" + user.role + "']")).click();
      element(by.css('[data-ng-click="add_user()"]')).click();
      utils.waitUntilReady(element(by.xpath(".//*[text()='" + user.name + "']")));
    };

    new_users.forEach(make_account);
  });

  it('should configure an existing user', function() {
    var user = { name: '<NAME>' };
    var path = '//form[contains(.,"' + user.name + '")]';

    // Find Recipient 1, click edit, flip some toggles, and save.
    var editUsrForm = element(by.xpath(path));
    editUsrForm.element(by.css('.actionButtonEdit')).click();
    
    // Pick Alaskan time zone for Giovanni
    var tz = "(GMT -9:00) Alaska";
    var tzBox = editUsrForm.element(by.cssContainingText('option', tz));
    tzBox.click();
    
    // Add a description 
    var descriptBox = editUsrForm.element(by.model('user.description'));
    var words = "A nice fellow with a neat quafe of hair!";
    descriptBox.clear();
    descriptBox.sendKeys(words);
    
    // Click Save and check the fields
    editUsrForm.element(by.css('.actionButtonSave')).click();
    editUsrForm.element(by.css('.actionButtonEdit')).click();
    editUsrForm.evaluate('user').then(function(userObj) {
        expect(userObj.timezone).toEqual(-9);
    });
    descriptBox.getAttribute('value').then(function(savedDescript) {
        expect(savedDescript).toEqual(words);
    });
  });

  it('should del existing users', function() {
    // delete's all accounts that match {{ user.name }} for all new_users
    var delete_account = function(user) {
      var path = '//form[contains(.,"' + user.name + '")]';
      element.all(by.xpath(path)).each(function(div) {
        div.element(by.css('.actionButtonDelete')).click();
        element(by.id('modal-action-ok')).click();
      });
    };

    delete_account(new_users[2]);
    delete_account(new_users[3]);
  });
});<commit_msg>Keep visible end2end texts polished for possible easy presentation<commit_after>var utils = require('./utils.js');
var pages = require('./pages.js');

describe('admin add, configure, and delete users', function() {
  var adminLog = new pages.adminLoginPage();
  var new_users = [
    {
      role: "Recipient",
      name: "<NAME>", 
      address: "<EMAIL>",
    },
    {
      role: "Recipient",
      name: "<NAME>", 
      address: "<EMAIL>",
    },
    {
      role: "Recipient",
      name: "<NAME>",
      address: "<EMAIL>",
    },
    {
      role: "Recipient",
      name: "<NAME>",
      address: "<EMAIL>",
    },
    {
      role: "Custodian",
      name: "<NAME>", 
      address: "<EMAIL>",
    },
  ];

  beforeAll(function() {
    adminLog.login('admin', 'ACollectionOfDiplomaticHistorySince_1966_ToThe_Pr esentDay#');
    browser.setLocation('admin/users');
  });

  it('should add new users', function() {
    var make_account = function(user) {
      element(by.model('new_user.name')).sendKeys(user.name);
      element(by.model('new_user.email')).sendKeys(user.address);
      element(by.model('new_user.role')).element(by.xpath(".//*[text()='" + user.role + "']")).click();
      element(by.css('[data-ng-click="add_user()"]')).click();
      utils.waitUntilReady(element(by.xpath(".//*[text()='" + user.name + "']")));
    };

    new_users.forEach(make_account);
  });

  it('should configure an existing user', function() {
    var user = { name: '<NAME>' };
    var path = '//form[contains(.,"' + user.name + '")]';

    // Find Recipient 1, click edit, flip some toggles, and save.
    var editUsrForm = element(by.xpath(path));
    editUsrForm.element(by.css('.actionButtonEdit')).click();
    
    // Pick Alaskan time zone for Giovanni
    var tz = "(GMT -9:00) Alaska";
    var tzBox = editUsrForm.element(by.cssContainingText('option', tz));
    tzBox.click();
    
    // Add a description 
    var descriptBox = editUsrForm.element(by.model('user.description'));
    var words = "Description of recipient 1";
    descriptBox.clear();
    descriptBox.sendKeys(words);
    
    // Click Save and check the fields
    editUsrForm.element(by.css('.actionButtonSave')).click();
    editUsrForm.element(by.css('.actionButtonEdit')).click();
    editUsrForm.evaluate('user').then(function(userObj) {
        expect(userObj.timezone).toEqual(-9);
    });
    descriptBox.getAttribute('value').then(function(savedDescript) {
        expect(savedDescript).toEqual(words);
    });
  });

  it('should del existing users', function() {
    // delete's all accounts that match {{ user.name }} for all new_users
    var delete_account = function(user) {
      var path = '//form[contains(.,"' + user.name + '")]';
      element.all(by.xpath(path)).each(function(div) {
        div.element(by.css('.actionButtonDelete')).click();
        element(by.id('modal-action-ok')).click();
      });
    };

    delete_account(new_users[2]);
    delete_account(new_users[3]);
  });
});
{'fraction_non_alphanumeric': 0.18998824122291283, 'fraction_numerical': 0.004031580715605577, 'mean_word_length': 3.128987517337032, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '6706331', 'n_tokens_mistral': 1951, 'n_tokens_neox': 1919, 'n_words': 347}