<commit_before>'use strict';

/* https://github.com/angular/protractor/blob/master/docs/toc.md */

describe('Pear2Pear', function() {

  browser.get('index.html');

  it('should automatically redirect to /session/new when location hash/fragment is empty', function() {
    expect(browser.getLocationAbsUrl()).toMatch('/session/new');
  });


  describe('session/new', function() {

    beforeEach(function() {
      browser.get('index.html#/session/new');
    });


    it('should render session/new when user navigates to /session/new', function() {
      expect(element.all(by.css('[ng-view] input#login')).first()).toBeDefined();
    });

  });

  describe('chatpad', function() {
    beforeAll(function() {
      browser.get('index.html');
    });

    it('should use the chadpad', function() {
      var timeout = 10000;

      element(by.css('input#login')).sendKeys('Test');
      element(by.css('.login-form button')).click();

      var communityList = by.css('.communities');

      browser.wait(function() {
        return browser.isElementPresent(communityList);
      }, timeout);


      var newCommunityButton = by.css('.new-community a');
      element(newCommunityButton).click();

      var newCommunityName = by.css('.new-community-name');

      browser.wait(function(){
        return browser.isElementPresent(newCommunityName);
      });

      element(newCommunityName).sendKeys('Testing Community');

      element(by.css('.create-community-btn')).click();

      var projectList = by.css('.projects');

      browser.wait(function() {
        return browser.isElementPresent(projectList);
      }, timeout);

      // Wait until pear has loaded the projects
      browser.wait(element(projectList).evaluate('projects.create'), timeout);

      var newProjectButton = by.css('.new-project a');
      element(newProjectButton).click();

      var editTitle = by.css('.project-title input');

      browser.wait(function() {
        return browser.isElementPresent(editTitle);
      }, timeout);

      element(editTitle).sendKeys('Testing');

      element(by.css('#pad .swellrt-editor')).click();
      element(by.css('#pad .wave-editor-on')).sendKeys('Grow your community with Pear2Pear');

      element(by.css('a.nav-chat')).click();

      var chatText = 'This is a nice opportunity to discuss about testing';

      element(by.css('.chat-send textarea')).sendKeys(chatText);
      element(by.css('.chat-input-button')).click();

      expect(element.all(by.css('.chat-message-text')).last().getText())
        .toEqual(chatText);

      // Temporary solution for removing a project
      // It should be included inside tests
      browser.executeScript(function() {
        angular.element(document.querySelector('.chat')).scope().destroyProject();
      });

      // Temporary solution for removing a community
      // It should be included inside tests
      browser.executeScript(function() {
        angular.element(document.querySelector('.chat')).scope().destroyCommunity();
      });
      // Give time for the former to be exec
      element(by.css('.nav-left a')).click();
    });
  });
});
<commit_msg>Remove communities and projects destroy<commit_after>'use strict';

/* https://github.com/angular/protractor/blob/master/docs/toc.md */

describe('Pear2Pear', function() {

  browser.get('index.html');

  it('should automatically redirect to /session/new when location hash/fragment is empty', function() {
    expect(browser.getLocationAbsUrl()).toMatch('/session/new');
  });


  describe('session/new', function() {

    beforeEach(function() {
      browser.get('index.html#/session/new');
    });


    it('should render session/new when user navigates to /session/new', function() {
      expect(element.all(by.css('[ng-view] input#login')).first()).toBeDefined();
    });

  });

  describe('chatpad', function() {
    beforeAll(function() {
      browser.get('index.html');
    });

    it('should use the chadpad', function() {
      var timeout = 10000;

      element(by.css('input#login')).sendKeys('Test');
      element(by.css('.login-form button')).click();

      var communityList = by.css('.communities');

      browser.wait(function() {
        return browser.isElementPresent(communityList);
      }, timeout);


      var newCommunityButton = by.css('.new-community a');
      element(newCommunityButton).click();

      var newCommunityName = by.css('.new-community-name');

      browser.wait(function(){
        return browser.isElementPresent(newCommunityName);
      });

      element(newCommunityName).sendKeys('Testing Community');

      element(by.css('.create-community-btn')).click();

      var projectList = by.css('.projects');

      browser.wait(function() {
        return browser.isElementPresent(projectList);
      }, timeout);

      // Wait until pear has loaded the projects
      browser.wait(element(projectList).evaluate('projects.create'), timeout);

      var newProjectButton = by.css('.new-project a');
      element(newProjectButton).click();

      var editTitle = by.css('.project-title input');

      browser.wait(function() {
        return browser.isElementPresent(editTitle);
      }, timeout);

      element(editTitle).sendKeys('Testing');

      element(by.css('#pad .swellrt-editor')).click();
      element(by.css('#pad .wave-editor-on')).sendKeys('Grow your community with Pear2Pear');

      element(by.css('a.nav-chat')).click();

      var chatText = 'This is a nice opportunity to discuss about testing';

      element(by.css('.chat-send textarea')).sendKeys(chatText);
      element(by.css('.chat-input-button')).click();

      expect(element.all(by.css('.chat-message-text')).last().getText())
        .toEqual(chatText);
    });
  });
});

{'fraction_non_alphanumeric': 0.1679110956763327, 'fraction_numerical': 0.002430977600277826, 'mean_word_length': 3.2729970326409497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '7206840', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1579, 'n_words': 290}