<commit_before>/*
 * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
 * Code distributed by Google as part of the polymer project is also
 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
 */

'use strict';

const path = require('path');
const runGenerator = require('yeoman-test').run;
const createGithubGenerator
  = require('../../lib/init/github').createGithubGenerator;
const runCommand = require('./run-command').runCommand;

// Template Generators
const createApplicationGenerator
  = require('../../lib/init/application/application').createApplicationGenerator;
const createElementGenerator
  = require('../../lib/init/element/element').createElementGenerator;

// A zero priveledge github token of a nonce account, used for quota.
const githubToken = '8<PASSWORD>';


suite('integration tests', function() {

  const binPath = path.join(__dirname, '../../', 'bin', 'polymer.js');

  // Extend timeout limit to 90 seconds for slower systems
  this.timeout(120000);

  suite('init templates', () => {

    // TODO(#562): enable test commands.
    test('test the polymer 1.x application template', () => {
      let dir;
      return runGenerator(createApplicationGenerator('polymer-1.x'))
        .withPrompts({ name: 'my-app' }) // Mock the prompt answers
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], {cwd: dir}))
        .then(() => runCommand(binPath, ['experimental-lint'], {cwd: dir}))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}))
        .then(() => runCommand(binPath, ['build'], {cwd: dir}));
    });

    test('test the polymer 2.x application template', () => {
      let dir;
      return runGenerator(createApplicationGenerator('polymer-2.x'))
        .withPrompts({ name: 'my-app' }) // Mock the prompt answers
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], { cwd: dir }))
        .then(() => runCommand(binPath, ['experimental-lint'], {cwd: dir}))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}))
        .then(() => runCommand(binPath, ['build'], {cwd: dir}));
    });

    test('test the polymer 2.x "element" template', () => {
      let dir;
      return runGenerator(createElementGenerator('polymer-2.x'))
        .withPrompts({ name: 'my-element' }) // Mock the prompt answers
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], { cwd: dir }))
        .then(() => runCommand(binPath, ['experimental-lint'], {cwd: dir}))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}));
    });

    test('test the polymer 1.x "element" template', () => {
      let dir;
      return runGenerator(createElementGenerator('polymer-1.x'))
        .withPrompts({ name: 'my-element' }) // Mock the prompt answers
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], { cwd: dir }))
        .then(() => runCommand(binPath, ['experimental-lint'], {cwd: dir}))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}));
    });

    test('test the "shop" template', () => {
      let dir;
      const ShopGenerator = createGithubGenerator({
        owner: 'Polymer',
        repo: 'shop',
        githubToken,
      });

      return runGenerator(ShopGenerator)
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], {cwd: dir}))
        .then(() => runCommand(
          binPath, ['experimental-lint', '--rules=polymer-2-hybrid'],
          {cwd: dir}))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}))
        .then(() => runCommand(binPath, ['build'], {cwd: dir}));
    });

    test('test the "starter-kit" template', () => {
      let dir;
      const PSKGenerator = createGithubGenerator({
        owner: 'PolymerElements',
        repo: 'polymer-starter-kit',
        githubToken,
      });

      return runGenerator(PSKGenerator)
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], { cwd: dir }))
        .then(() => runCommand(
            binPath, ['experimental-lint', '--rules=polymer-2-hybrid'],
            { cwd: dir }))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}))
        .then(() => runCommand(binPath, ['build'], {cwd: dir}));
    });

  });

  // TODO(fks): Two things are needed to unskip these tests:
  //   1. Make the tools-sample-projects repo public
  //   2. Create a new release when the add-projects branch/pr is merged
  suite.skip('tools-sample-projects templates', () => {

    let tspDir;

    suiteSetup(() => {
      const TSPGenerator = createGithubGenerator({
        owner: 'Polymer',
        repo: 'tools-sample-projects',
        githubToken,
      });
<commit_msg>unskip integration tests (#570)<commit_after>/*
 * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
 * Code distributed by Google as part of the polymer project is also
 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
 */

'use strict';

const path = require('path');
const runGenerator = require('yeoman-test').run;
const createGithubGenerator
  = require('../../lib/init/github').createGithubGenerator;
const runCommand = require('./run-command').runCommand;

// Template Generators
const createApplicationGenerator
  = require('../../lib/init/application/application').createApplicationGenerator;
const createElementGenerator
  = require('../../lib/init/element/element').createElementGenerator;

// A zero priveledge github token of a nonce account, used for quota.
const githubToken = '<PASSWORD>';


suite('integration tests', function() {

  const binPath = path.join(__dirname, '../../', 'bin', 'polymer.js');

  // Extend timeout limit to 90 seconds for slower systems
  this.timeout(120000);

  suite('init templates', () => {

    // TODO(#562): enable test commands.
    test('test the polymer 1.x application template', () => {
      let dir;
      return runGenerator(createApplicationGenerator('polymer-1.x'))
        .withPrompts({ name: 'my-app' }) // Mock the prompt answers
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], {cwd: dir}))
        .then(() => runCommand(binPath, ['experimental-lint'], {cwd: dir}))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}))
        .then(() => runCommand(binPath, ['build'], {cwd: dir}));
    });

    test('test the polymer 2.x application template', () => {
      let dir;
      return runGenerator(createApplicationGenerator('polymer-2.x'))
        .withPrompts({ name: 'my-app' }) // Mock the prompt answers
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], { cwd: dir }))
        .then(() => runCommand(binPath, ['experimental-lint'], {cwd: dir}))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}))
        .then(() => runCommand(binPath, ['build'], {cwd: dir}));
    });

    test('test the polymer 2.x "element" template', () => {
      let dir;
      return runGenerator(createElementGenerator('polymer-2.x'))
        .withPrompts({ name: 'my-element' }) // Mock the prompt answers
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], { cwd: dir }))
        .then(() => runCommand(binPath, ['experimental-lint'], {cwd: dir}))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}));
    });

    test('test the polymer 1.x "element" template', () => {
      let dir;
      return runGenerator(createElementGenerator('polymer-1.x'))
        .withPrompts({ name: 'my-element' }) // Mock the prompt answers
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], { cwd: dir }))
        .then(() => runCommand(binPath, ['experimental-lint'], {cwd: dir}))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}));
    });

    test('test the "shop" template', () => {
      let dir;
      const ShopGenerator = createGithubGenerator({
        owner: 'Polymer',
        repo: 'shop',
        githubToken,
      });

      return runGenerator(ShopGenerator)
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], {cwd: dir}))
        .then(() => runCommand(
          binPath, ['experimental-lint', '--rules=polymer-2-hybrid'],
          {cwd: dir}))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}))
        .then(() => runCommand(binPath, ['build'], {cwd: dir}));
    });

    test('test the "starter-kit" template', () => {
      let dir;
      const PSKGenerator = createGithubGenerator({
        owner: 'PolymerElements',
        repo: 'polymer-starter-kit',
        githubToken,
      });

      return runGenerator(PSKGenerator)
        .toPromise()
        .then((_dir) => { dir = _dir })
        .then(() => runCommand(binPath, ['install'], { cwd: dir }))
        .then(() => runCommand(
            binPath, ['experimental-lint', '--rules=polymer-2-hybrid'],
            { cwd: dir }))
        // .then(() => runCommand(binPath, ['test'], {cwd: dir}))
        .then(() => runCommand(binPath, ['build'], {cwd: dir}));
    });

  });

  suite('tools-sample-projects templates', () => {

    let tspDir;

    suiteSetup(() => {
      const TSPGenerator = createGithubGenerator({
        owner: 'Polymer',
        repo: 'tools-sample-projects',
        githubToken,
      });

{'fraction_non_alphanumeric': 0.1839214542626616, 'fraction_numerical': 0.005443763973947701, 'mean_word_length': 2.8160237388724036, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 79, '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': '112856', 'n_tokens_mistral': 3119, 'n_tokens_neox': 2972, 'n_words': 787}