<commit_before>var expect = require('expect');
var should = require('should');
var request = require('superagent');

var GrommetE2EUtils = require('../src/utils/test/GrommetE2EUtils');

var options = {
  desiredCapabilities: {
    browserName: 'phantomjs'
  }
};

if (process.env.TRAVIS) {
  options = GrommetE2EUtils.getSauceLabsCIOptions(process.env.SAUCE_USERNAME,
    process.env.SAUCE_ACCESS_KEY);
}

var browser = GrommetE2EUtils.getBrowserClient(options);

var requestData = {
  sauceUsername: process.env.SAUCE_USERNAME,
  sauceAccessKey: process.env.SAUCE_ACCESS_KEY,
  failed: false
};

describe('Docs website e2e', function() {
  this.timeout(50000);

  beforeEach(function(done) {
    GrommetE2EUtils.configureBrowser(browser, 'http://localhost:8000/docs/',
      requestData, done);
  });

  it('loads the title for the docs home page', function(done) {
    browser
      .getTitle(function(err, title) {
        if (err) {
          should.fail('Expected the title to be returned.', err);
        }
        expect(title).toBe('Grommet - User Experience for the Enterprise');
        done();
      });
  });

  it('downloads adobe illustrator sticker sheet', function(done) {
    var selector = '.header .menu a:nth-child(1)';

    browser.getText(selector, function (err, text) {
      if (err) {
        should.fail('Expected to find design link.', err);
      }
      expect(text).toBe('Design');
      var buttonSelector = '.background-color-index-neutral-1 a:nth-child(1)';
      browser.click(selector).getText(buttonSelector).then(function(text) {
        expect(text).toBe('Resources');

        var aiSelector = '#illustrator p:last-of-type a';
        browser.click(buttonSelector).getText(aiSelector).then(function(text) {
          expect(text).toBe('Download Adobe Illustrator Sticker Sheet');
          browser.getAttribute(aiSelector, 'href').then(function(linkPath) {
            request.get(linkPath).end(function(err, res) {
              if (err) {
                should.fail('Expected to send a request to ai asset.', err);
              }
              expect(res.status).toBe(200);
              done();
            });
          });
        });
      });
    });
  });<commit_msg>Added test for pdf download of sticker sheet.<commit_after>var expect = require('expect');
var should = require('should');
var request = require('superagent');

var GrommetE2EUtils = require('../src/utils/test/GrommetE2EUtils');

var options = {
  desiredCapabilities: {
    browserName: 'phantomjs'
  }
};

if (process.env.TRAVIS) {
  options = GrommetE2EUtils.getSauceLabsCIOptions(process.env.SAUCE_USERNAME,
    process.env.SAUCE_ACCESS_KEY);
}

var browser = GrommetE2EUtils.getBrowserClient(options);

var requestData = {
  sauceUsername: process.env.SAUCE_USERNAME,
  sauceAccessKey: process.env.SAUCE_ACCESS_KEY,
  failed: false
};

describe('Docs website e2e', function() {
  this.timeout(50000);

  beforeEach(function(done) {
    GrommetE2EUtils.configureBrowser(browser, 'http://localhost:8000/docs/',
      requestData, done);
  });

  it('loads the title for the docs home page', function(done) {
    browser
      .getTitle(function(err, title) {
        if (err) {
          should.fail('Expected the title to be returned.', err);
        }
        expect(title).toBe('Grommet - User Experience for the Enterprise');
        done();
      });
  });

  it('downloads adobe illustrator sticker sheet', function(done) {
    var selector = '.header .menu a:nth-child(1)';

    browser.getText(selector, function (err, text) {
      if (err) {
        should.fail('Expected to find design link.', err);
      }
      expect(text).toBe('Design');
      var buttonSelector = '.background-color-index-neutral-1 a:nth-child(1)';
      browser.click(selector).getText(buttonSelector).then(function(text) {
        expect(text).toBe('Resources');

        var aiSelector = '#illustrator p:last-of-type a:first-of-type';
        browser.click(buttonSelector).getText(aiSelector).then(function(text) {
          expect(text).toBe('Download Adobe Illustrator Sticker Sheet');
          browser.getAttribute(aiSelector, 'href').then(function(linkPath) {
            request.get(linkPath).end(function(err, res) {
              if (err) {
                should.fail('Expected to send a request to ai asset.', err);
              }
              expect(res.status).toBe(200);
              done();
            });
          });
        });
      });
    });
  });

  it('downloads adobe illustrator pdf sticker sheet', function(done) {
    var selector = '.header .menu a:nth-child(1)';

    browser.getText(selector, function (err, text) {
      if (err) {
        should.fail('Expected to find design link.', err);
      }
      expect(text).toBe('Design');
      var buttonSelector = '.background-color-index-neutral-1 a:nth-child(1)';
      browser.click(selector).getText(buttonSelector).then(function(text) {
        expect(text).toBe('Resources');

        var pdfSelector = '#illustrator p:last-of-type a:last-of-type';
        browser.click(buttonSelector).getText(pdfSelector).then(function(text) {
          expect(text).toBe('pdf');
          browser.getAttribute(pdfSelector, 'href').then(function(linkPath) {
            request.get(linkPath).end(function(err, res) {
              if (err) {
                should.fail('Expected to send a request to pdf asset.', err);
              }
              expect(res.status).toBe(200);
              done();
            });
          });
        });
      });
    });
  });
{'fraction_non_alphanumeric': 0.14453054604433233, 'fraction_numerical': 0.008650207244548567, 'mean_word_length': 2.803975325565456, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7355487', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1666, 'n_words': 320}