<commit_before>'use strict';

var Chance = require('chance'),
    chance = new Chance();

class CommunitiesPage {

  constructor () {
  }

  get () {
    browser.get('/communities');
  }

  getPlusEl () {
    var platform = global.isDesktop ? 'desktop' : 'mobile';
    return element(by.css('.plus-' + platform + ' button'));
  }

  goToNew () {
    var newEl = this.getPlusEl();
    browser.wait(protractor.ExpectedConditions.elementToBeClickable(newEl));
    newEl.click();
  }
}

class CommunityPage {

  constructor () {
    this.nameEl = element(by.css('.community-info h1'));

    this.descriptionEl = element(by.binding('community.description'));

    this.participantListEl = element(by.css('[avatars="community._participants"]'));
  }

  getJoinEl () {
    var platform = global.isDesktop ? '.hidden-mobile' : '.hidden-desktop';
    return element(by.css(platform + ' button[participate]'));
  }

  getMenuEl () {
    var platform = global.isDesktop ? '.menu-desktop' : '.nav-right';
    return element(by.css(platform + ' [ui-turn-on="dropdownProjectMenu"]'));
  }

  getLeaveEl() {
    var platform = global.isDesktop ? '.menu-desktop' : '.nav-right';
    return element(by.css(platform + ' [participate-copy-off="community.menu.join"]'));
  }

  join () {
    var joinEl = this.getJoinEl();
    browser.wait(protractor.ExpectedConditions.visibilityOf(joinEl));

    joinEl.click();
  }

  leave () {
    this.getMenuEl().click();
    this.getLeaveEl().click();
  }

  getName () {
    return this.nameEl.getText();
  }

  getDescription () {
    return this.descriptionEl.getText();
  }

  getParticipants () {
    return this.participantListEl.all(by.css('img')).getAttribute('title');
  }
}

class NewCommunityPage {

  constructor () {
    this.name = chance.sentence({ words: 3 });

      // Remove trailing period
    this.name = this.name.substring(0, this.name.length - 1);

    this.description = chance.paragraph({ sentences: 2 });

    this.nameInputEl = element(by.model('community.name'));
    this.descriptionInputEl = element(by.model('community.description'));
<commit_msg>Fix community leave test<commit_after>'use strict';

var Chance = require('chance'),
    chance = new Chance();

class CommunitiesPage {

  constructor () {
  }

  get () {
    browser.get('/communities');
  }

  getPlusEl () {
    var platform = global.isDesktop ? 'desktop' : 'mobile';
    return element(by.css('.plus-' + platform + ' button'));
  }

  goToNew () {
    var newEl = this.getPlusEl();
    browser.wait(protractor.ExpectedConditions.elementToBeClickable(newEl));
    newEl.click();
  }
}

class CommunityPage {

  constructor () {
    this.nameEl = element(by.css('.community-info h1'));

    this.descriptionEl = element(by.binding('community.description'));

    this.participantListEl = element(by.css('[avatars="community._participants"]'));

    this.menuEl = element(by.css('[ui-turn-on="dropdownCommunityMenu"]'));

    this.leaveEl = element(by.css('[participate-copy-off="community.menu.join"]'));
  }

  getJoinEl () {
    var platform = global.isDesktop ? '.hidden-mobile' : '.hidden-desktop';
    return element(by.css(platform + ' button[participate]'));
  }

  join () {
    var joinEl = this.getJoinEl();
    browser.wait(protractor.ExpectedConditions.visibilityOf(joinEl));

    joinEl.click();
  }

  leave () {
    this.menuEl.click();
    this.leaveEl.click();
  }

  getName () {
    return this.nameEl.getText();
  }

  getDescription () {
    return this.descriptionEl.getText();
  }

  getParticipants () {
    return this.participantListEl.all(by.css('img')).getAttribute('title');
  }
}

class NewCommunityPage {

  constructor () {
    this.name = chance.sentence({ words: 3 });

      // Remove trailing period
    this.name = this.name.substring(0, this.name.length - 1);

    this.description = chance.paragraph({ sentences: 2 });

    this.nameInputEl = element(by.model('community.name'));
    this.descriptionInputEl = element(by.model('community.description'));

{'fraction_non_alphanumeric': 0.16799601196410768, 'fraction_numerical': 0.0024925224327018943, 'mean_word_length': 3.514060742407199, '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': '4122882', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1233, 'n_words': 201}