<commit_before>'use strict';

var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
var ProfilePage = process.require('tests/client/e2eTests/pages/ProfilePage.js');
var datas = process.require('tests/client/e2eTests/resources/data.json');

// Load assertion library
var assert = chai.assert;
chai.use(chaiAsPromised);

describe('Profile page', function() {
  var page;

  // Prepare page
  before(function() {
    page = new ProfilePage();
    page.logAs(datas.users.coreAdmin);
    return page.load();
  });

  // Logout after tests
  after(function() {
    return page.logout();
  });

  // Reload page after each test
  afterEach(function() {
    return page.refresh();
  });

  it('should display page title', function() {
    return assert.eventually.ok(page.pageTitleElement.isPresent());
  });

  it('should display page description', function() {
    return assert.eventually.ok(page.pageDescriptionElement.isPresent());
  });

  it('should display user name, email and roles', function() {
    assert.eventually.equal(page.userNameElement.getText(), page.getUser().name);
    assert.eventually.equal(page.userEmailElement.getText(), page.getUser().email);
    assert.eventually.equal(page.userRolesElement.getText(), datas.roles.coreAdmin.name + ', ' +
                            datas.roles.coreGuest.name);
    return assert.eventually.ok(page.editUserElement.isPresent());
  });

  it('should display form to change password', function() {
    assert.eventually.ok(page.passwordElement.isPresent(), 'Password field is not present');
    assert.eventually.ok(page.confirmPasswordElement.isPresent(), 'Password confirmation field is not present');
    assert.eventually.ok(page.submitPasswordElement.isPresent(), 'Submit button is not present');
    return assert.eventually.ok(page.cancelPasswordElement.isPresent(), 'Cancel button is not present');
  });

  it('should be able to change user name', function() {
    var newAdminName = 'test changing user name';
    page.setNameAndSave(newAdminName);
    assert.eventually.equal(page.userNameElement.getText(), newAdminName);
    return page.setNameAndSave(page.getUser().name);
  });

  it('should not be able to save user without a name', function() {
    return assert.isRejected(page.setNameAndSave());
  });

  it('should be able to cancel user edition', function() {
    page.activateEdition();
    page.setName('test cancelling edition');
    page.cancelEdition();
    return assert.eventually.equal(page.userNameElement.getText(), page.getUser().name);
  });
<commit_msg>Fix bug on profile end to end tests<commit_after>'use strict';

var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
var ProfilePage = process.require('tests/client/e2eTests/pages/ProfilePage.js');
var datas = process.require('tests/client/e2eTests/resources/data.json');

// Load assertion library
var assert = chai.assert;
chai.use(chaiAsPromised);

describe('Profile page', function() {
  var page;

  // Prepare page
  before(function() {
    page = new ProfilePage();
    page.logAs(datas.users.coreAdmin);
    return page.load();
  });

  // Logout after tests
  after(function() {
    return page.logout();
  });

  // Reload page after each test
  afterEach(function() {
    return page.refresh();
  });

  it('should display page title', function() {
    return assert.eventually.ok(page.pageTitleElement.isPresent());
  });

  it('should display page description', function() {
    return assert.eventually.ok(page.pageDescriptionElement.isPresent());
  });

  it('should display user name, email and roles', function() {
    assert.eventually.equal(page.userNameElement.getText(), page.getUser().name);
    assert.eventually.equal(page.userEmailElement.getText(), page.getUser().email);

    page.userRolesElement.getText().then(function(text) {
      var roles = text.split(', ');
      assert.includeMembers(roles, [datas.roles.coreAdmin.name, datas.roles.coreGuest.name]);
    });

    return assert.eventually.ok(page.editUserElement.isPresent());
  });

  it('should display form to change password', function() {
    assert.eventually.ok(page.passwordElement.isPresent(), 'Password field is not present');
    assert.eventually.ok(page.confirmPasswordElement.isPresent(), 'Password confirmation field is not present');
    assert.eventually.ok(page.submitPasswordElement.isPresent(), 'Submit button is not present');
    return assert.eventually.ok(page.cancelPasswordElement.isPresent(), 'Cancel button is not present');
  });

  it('should be able to change user name', function() {
    var newAdminName = 'test changing user name';
    page.setNameAndSave(newAdminName);
    assert.eventually.equal(page.userNameElement.getText(), newAdminName);
    return page.setNameAndSave(page.getUser().name);
  });

  it('should not be able to save user without a name', function() {
    return assert.isRejected(page.setNameAndSave());
  });

  it('should be able to cancel user edition', function() {
    page.activateEdition();
    page.setName('test cancelling edition');
    page.cancelEdition();
    return assert.eventually.equal(page.userNameElement.getText(), page.getUser().name);
  });

{'fraction_non_alphanumeric': 0.14332435552135436, 'fraction_numerical': 0.0007695267410542517, 'mean_word_length': 4.387564766839378, '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': '967169', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1497, 'n_words': 333}