<commit_before>// # Frontend Route tests
// As it stands, these tests depend on the database, and as such are integration tests.
// Mocking out the models to not touch the DB would turn these into unit tests, and should probably be done in future,
// But then again testing real code, rather than mock code, might be more useful...
const should = require('should');

const sinon = require('sinon');
const supertest = require('supertest');
const testUtils = require('../../utils');
const configUtils = require('../../utils/configUtils');
const urlUtils = require('../../utils/urlUtils');
const config = require('../../../core/shared/config');
let request;

describe('Frontend Routing:Redirects', function () {
    function doEnd(done) {
        return function (err, res) {
            if (err) {
                return done(err);
            }

            should.not.exist(res.headers['x-cache-invalidate']);
            should.not.exist(res.headers['X-CSRF-Token']);
            should.not.exist(res.headers['set-cookie']);
            should.exist(res.headers.date);

            done();
        };
    }

    function addPosts(done) {
        testUtils.clearData().then(function () {
            return testUtils.initData();
        }).then(function () {
            return testUtils.fixtures.insertPostsAndTags();
        }).then(function () {
            done();
        });
    }

    afterEach(function () {
        sinon.restore();
    });

    before(function () {
        return testUtils.startGhost()
            .then(function () {
                request = supertest.agent(config.get('url'));
            });
    });

    // TODO: convert to unit tests
    const redirectsFileExts = ['.json', '.yaml'];

    redirectsFileExts.forEach((ext) => {
        describe(`Redirects (use redirects${ext} from test/utils/fixtures/data)`, function () {
            before(function () {
                configUtils.set('url', 'http://localhost:2370/');
                urlUtils.stubUrlUtilsFromConfig();

                return testUtils.startGhost({forceStart: true, redirectsFileExt: ext})
                    .then(function () {
                        request = supertest.agent(config.get('server:host') + ':' + config.get('server:port'));
                    });
            });

            after(function () {
                configUtils.restore();
                urlUtils.restore();
            });

            describe('1 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/post/10/a-nice-blog-post')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/a-nice-blog-post');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/post/10/a-nice-blog-post/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/a-nice-blog-post');
                            doEnd(done)(err, res);
                        });
                });

                it('with query params', function (done) {
                    request.get('/topic?something=good')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/?something=good');
                            doEnd(done)(err, res);
                        });
                });

                it('with query params', function (done) {
                    request.get('/post/10/a-nice-blog-post?a=b')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/a-nice-blog-post?a=b');
                            doEnd(done)(err, res);
                        });
                });

                it('with case insensitive', function (done) {
                    request.get('/CaSe-InSeNsItIvE')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/redirected-insensitive');
                            doEnd(done)(err, res);
                        });
                });

                it('with case sensitive', function (done) {
                    request.get('/Case-Sensitive')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/redirected-sensitive');
                            doEnd(done)(err, res);
                        });
                });

                it('defaults to case sensitive', function (done) {
                    request.get('/Default-Sensitive')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/redirected-default');
                            doEnd(done)(err, res);
                        });
                });

                it('should not redirect with case sensitive', function (done) {
                    request.get('/casE-sensitivE')
                        .end(function (err, res) {
                            res.headers.location.should.not.eql('/redirected-sensitive');
                            res.statusCode.should.not.eql(302);
                            doEnd(done)(err, res);
                        });
                });

                it('should not redirect with default case sensitive', function (done) {
                    request.get('/defaulT-sensitivE')
                        .end(function (err, res) {
                            res.headers.location.should.not.eql('/redirected-default');
                            res.statusCode.should.not.eql(302);
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('2 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/my-old-blog-post/')
                        .expect(301)
                        .expect('Cache-Control', testUtils.cacheRules.year)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/revamped-url/');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/my-old-blog-post')
                        .expect(301)
                        .expect('Cache-Control', testUtils.cacheRules.year)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/revamped-url/');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('3 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/what/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/what-does-god-say');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/what')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/what-does-god-say');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('4 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/search/label/&&&/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/tag/&&&/');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/search/label/&&&/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/tag/&&&/');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('5 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/topic/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/topic')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('6 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/resources/download/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/shubal-stearns');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/resources/download')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/shubal-stearns');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('7 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/2016/11/welcome.html')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/welcome');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('last case', function () {
                it('default', function (done) {
                    request.get('/prefix/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/blog/');
                            doEnd(done)(err, res);
                        });
                });

                it('with a custom path', function (done) {
                    request.get('/prefix/expect-redirect')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/blog/expect-redirect');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('external url redirect', function () {
                it('with trailing slash', function (done) {
                    request.get('/external-url/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('https://ghost.org/');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/external-url')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('https://ghost.org/');
                            doEnd(done)(err, res);
                        });
                });

                it('with capturing group', function (done) {
                    request.get('/external-url/docs')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('https://ghost.org/docs');
                            doEnd(done)(err, res);
                        });
                });
            });
        });

        describe(`Subdirectory redirects (use redirects${ext} from test/utils/fixtures/data)`, function () {
            before(function () {
                configUtils.set('url', 'http://localhost:2370/blog/');
                urlUtils.stubUrlUtilsFromConfig();

                return testUtils.startGhost({forceStart: true, subdir: true, redirectsFileExt: ext})
                    .then(function () {
                        request = supertest.agent(config.get('server:host') + ':' + config.get('server:port'));
                    });
            });

            after(function () {
                configUtils.restore();
                urlUtils.restore();
            });

            describe('internal url redirect', function () {
                it('should include the subdirectory', function (done) {
                    request.get('/blog/my-old-blog-post/')
                        .expect(301)
                        .expect('Cache-Control', testUtils.cacheRules.year)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/blog/revamped-url/');
                            doEnd(done)(err, res);
                        });
                });
                it('should work with regex "from" redirects', function (done) {
                    request.get('/blog/capture1/whatever')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/blog/whatever');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('external url redirect', function () {
                it('should not include the subdirectory', function (done) {
                    request.get('/blog/external-url/docs')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('https://ghost.org/docs');
                            doEnd(done)(err, res);
                        });
                });
            });
        });
    });
});
<commit_msg>Removed dead code in redirects.test<commit_after>// # Frontend Route tests
// As it stands, these tests depend on the database, and as such are integration tests.
// Mocking out the models to not touch the DB would turn these into unit tests, and should probably be done in future,
// But then again testing real code, rather than mock code, might be more useful...
const should = require('should');

const sinon = require('sinon');
const supertest = require('supertest');
const testUtils = require('../../utils');
const configUtils = require('../../utils/configUtils');
const urlUtils = require('../../utils/urlUtils');
const config = require('../../../core/shared/config');
let request;

describe('Frontend Routing:Redirects', function () {
    function doEnd(done) {
        return function (err, res) {
            if (err) {
                return done(err);
            }

            should.not.exist(res.headers['x-cache-invalidate']);
            should.not.exist(res.headers['X-CSRF-Token']);
            should.not.exist(res.headers['set-cookie']);
            should.exist(res.headers.date);

            done();
        };
    }

    afterEach(function () {
        sinon.restore();
    });

    // TODO: convert to unit tests
    const redirectsFileExts = ['.json', '.yaml'];

    redirectsFileExts.forEach((ext) => {
        describe(`Redirects (use redirects${ext} from test/utils/fixtures/data)`, function () {
            before(function () {
                configUtils.set('url', 'http://localhost:2370/');
                urlUtils.stubUrlUtilsFromConfig();

                return testUtils.startGhost({forceStart: true, redirectsFileExt: ext})
                    .then(function () {
                        request = supertest.agent(config.get('server:host') + ':' + config.get('server:port'));
                    });
            });

            after(function () {
                configUtils.restore();
                urlUtils.restore();
            });

            describe('1 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/post/10/a-nice-blog-post')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/a-nice-blog-post');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/post/10/a-nice-blog-post/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/a-nice-blog-post');
                            doEnd(done)(err, res);
                        });
                });

                it('with query params', function (done) {
                    request.get('/topic?something=good')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/?something=good');
                            doEnd(done)(err, res);
                        });
                });

                it('with query params', function (done) {
                    request.get('/post/10/a-nice-blog-post?a=b')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/a-nice-blog-post?a=b');
                            doEnd(done)(err, res);
                        });
                });

                it('with case insensitive', function (done) {
                    request.get('/CaSe-InSeNsItIvE')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/redirected-insensitive');
                            doEnd(done)(err, res);
                        });
                });

                it('with case sensitive', function (done) {
                    request.get('/Case-Sensitive')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/redirected-sensitive');
                            doEnd(done)(err, res);
                        });
                });

                it('defaults to case sensitive', function (done) {
                    request.get('/Default-Sensitive')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/redirected-default');
                            doEnd(done)(err, res);
                        });
                });

                it('should not redirect with case sensitive', function (done) {
                    request.get('/casE-sensitivE')
                        .end(function (err, res) {
                            res.headers.location.should.not.eql('/redirected-sensitive');
                            res.statusCode.should.not.eql(302);
                            doEnd(done)(err, res);
                        });
                });

                it('should not redirect with default case sensitive', function (done) {
                    request.get('/defaulT-sensitivE')
                        .end(function (err, res) {
                            res.headers.location.should.not.eql('/redirected-default');
                            res.statusCode.should.not.eql(302);
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('2 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/my-old-blog-post/')
                        .expect(301)
                        .expect('Cache-Control', testUtils.cacheRules.year)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/revamped-url/');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/my-old-blog-post')
                        .expect(301)
                        .expect('Cache-Control', testUtils.cacheRules.year)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/revamped-url/');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('3 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/what/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/what-does-god-say');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/what')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/what-does-god-say');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('4 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/search/label/&&&/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/tag/&&&/');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/search/label/&&&/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/tag/&&&/');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('5 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/topic/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/topic')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('6 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/resources/download/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/shubal-stearns');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/resources/download')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/shubal-stearns');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('7 case', function () {
                it('with trailing slash', function (done) {
                    request.get('/2016/11/welcome.html')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/welcome');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('last case', function () {
                it('default', function (done) {
                    request.get('/prefix/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/blog/');
                            doEnd(done)(err, res);
                        });
                });

                it('with a custom path', function (done) {
                    request.get('/prefix/expect-redirect')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/blog/expect-redirect');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('external url redirect', function () {
                it('with trailing slash', function (done) {
                    request.get('/external-url/')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('https://ghost.org/');
                            doEnd(done)(err, res);
                        });
                });

                it('without trailing slash', function (done) {
                    request.get('/external-url')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('https://ghost.org/');
                            doEnd(done)(err, res);
                        });
                });

                it('with capturing group', function (done) {
                    request.get('/external-url/docs')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('https://ghost.org/docs');
                            doEnd(done)(err, res);
                        });
                });
            });
        });

        describe(`Subdirectory redirects (use redirects${ext} from test/utils/fixtures/data)`, function () {
            before(function () {
                configUtils.set('url', 'http://localhost:2370/blog/');
                urlUtils.stubUrlUtilsFromConfig();

                return testUtils.startGhost({forceStart: true, subdir: true, redirectsFileExt: ext})
                    .then(function () {
                        request = supertest.agent(config.get('server:host') + ':' + config.get('server:port'));
                    });
            });

            after(function () {
                configUtils.restore();
                urlUtils.restore();
            });

            describe('internal url redirect', function () {
                it('should include the subdirectory', function (done) {
                    request.get('/blog/my-old-blog-post/')
                        .expect(301)
                        .expect('Cache-Control', testUtils.cacheRules.year)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/blog/revamped-url/');
                            doEnd(done)(err, res);
                        });
                });
                it('should work with regex "from" redirects', function (done) {
                    request.get('/blog/capture1/whatever')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('/blog/whatever');
                            doEnd(done)(err, res);
                        });
                });
            });

            describe('external url redirect', function () {
                it('should not include the subdirectory', function (done) {
                    request.get('/blog/external-url/docs')
                        .expect(302)
                        .expect('Cache-Control', testUtils.cacheRules.public)
                        .end(function (err, res) {
                            res.headers.location.should.eql('https://ghost.org/docs');
                            doEnd(done)(err, res);
                        });
                });
            });
        });
    });
});
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Thu Dec 19 2013 19:34:57 GMT+0100 (Mitteleuropäische Zeit)

module.exports = function(config) {
  config.set({

    // base path, that will be used to resolve files and exclude
    basePath: '',

    // frameworks to use
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'public/scripts/app.min.js',
      'karma/angular-mocks.js',
      'karma/**/*Spec.js'
    ],

    // list of files to exclude
    exclude: [

    ],

    // test results reporter to use
    // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera (has to be installed with `npm install karma-opera-launcher`)
    // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
    // - PhantomJS
    // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
    browsers: ['Chrome'],

    // If browser does not capture in given timeout [ms], kill it
    captureTimeout: 60000,

    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false
  });
};
<commit_msg>updated to actual file paths<commit_after>// Karma configuration
// Generated on Thu Dec 19 2013 19:34:57 GMT+0100 (Mitteleuropäische Zeit)

module.exports = function(config) {
  config.set({

    // base path, that will be used to resolve files and exclude
    basePath: '',

    // frameworks to use
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'vendor/*.js',
      'scripts/app.js',
      'scripts/timeAgoFilter.js',
      'tests/angular-mocks.js',
      'tests/**/*Spec.js'
    ],

    // list of files to exclude
    exclude: [

    ],

    // test results reporter to use
    // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera (has to be installed with `npm install karma-opera-launcher`)
    // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
    // - PhantomJS
    // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
    browsers: ['Chrome'],

    // If browser does not capture in given timeout [ms], kill it
    captureTimeout: 60000,

    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false
  });
};
<|endoftext|>


<commit_before>'use strict';

import Boom from 'boom';

import getLogger from '../../../libs/winston';

import {
  cardItemModel,
  cardsModel,
  cardModel
} from '../../../models/index';

import { buildResponse } from '../../../utils/responseService';

const objectIdRegex = /^(?=[a-f\d]{24}$)(\d+[a-f]|[a-f]+\d)/i;
const log = getLogger(module);

export const getUserBoardCards = async (req, res) => {
  const reqUser = req.user;

  try {
    let cards = await cardsModel.findOne({ userId: req.user._id, boardId: req.params.idBoard });

    if (!cards) {
      const response = {
        boards: reqUser.boards,
        organizations: reqUser.organizations,
        boardStars: reqUser.boardStars,
        cards: []
      };

      return buildResponse(200, response, res);
    } else {
      const response = {
        boards: reqUser.boards,
        organizations: reqUser.organizations,
        boardStars: reqUser.boardStars,
        cards: cards.cards
      };

      return buildResponse(200, response, res);
    }
  } catch (error) {
    if (error.isBoom) {
      buildResponse(error.output.statusCode, error.message, res)
    } else {
      buildResponse(500, error, res)
    }
  }
};

export const updateUserBoardCards = async (req, res) => {
  try {
    let cards = await cardsModel.findOne({ userId: req.user._id, boardId: req.params.idBoard });

    if (!cards) {
      buildResponse(400, 'This board does not have any cards', res);
    } else {
      cards.cards = req.body.cards;

      let cards = await cards.save();

      if (cards) {
        buildResponse(200, cards.cards, res);
      }
    }
  } catch (error) {
    log.error(error);

    buildResponse(500, error, res);
  }
};

const saveCards = async (cards, res) => {
  try {
    let cards = await cards.save();

    if (cards) {
      buildResponse(200, cards.cards, res);
    }
  } catch (error) {
    buildResponse(500, error, res);
  }
};

export const saveUserBoardCard = async (req, res) => {
  try {
    let cards = await cardsModel.findOne({ userId: req.user._id, boardId: req.params.idBoard });

    let card = new cardModel({
      header: req.body.name
    });

    if (cards) {
      cards.cards.push(card);

      saveCards(cards, res);
    } else {
      let cards = new cardsModel({
        boardId: req.params.idBoard,
        userId: req.user._id,
        cards: card
      });

      saveCards(cards, res);
    }
  } catch (error) {
    buildResponse(500, error, res);
  }
};

export const saveUserBoardCardItem = async (req, res) => {
  try {
    let cards = await  cardsModel.findOne({ userId: req.user._id, boardId: req.params.idBoard });

    if (!cards) {
      throw Boom.create(400, 'This board does not have any cards');
    } else {
      let card = cards.cards.id(req.params.idCard);

      if (!card) {
        throw Boom.create(400, 'That card does not exist');
      } else {
        let cardItem = new cardItemModel({
          name: req.body.name
        })

        card.cardItems.push(cardItem);

        return cards.save();
      }
    }
  } catch (error) {
    if (error.isBoom) {
      buildResponse(error.output.statusCode, error.message, res);
    } else {
      buildResponse(500, error, res)
    }
  }
};<commit_msg>Change the card controller response<commit_after>'use strict';

import Boom from 'boom';

import getLogger from '../../../libs/winston';

import {
  cardItemModel,
  cardsModel,
  cardModel
} from '../../../models/index';

import { buildResponse } from '../../../utils/responseService';

const objectIdRegex = /^(?=[a-f\d]{24}$)(\d+[a-f]|[a-f]+\d)/i;
const log = getLogger(module);

export const getUserBoardCards = async (req, res) => {
  const reqUser = req.user;

  try {
    let cards = await cardsModel.findOne({ userId: req.user._id, boardId: req.params.idBoard });

    if (!cards) {
      const response = {
        boards: reqUser.boards,
        organizations: reqUser.organizations,
        boardStars: reqUser.boardStars,
        cards: []
      };

      return buildResponse(200, response, res);
    } else {
      const response = {
        boards: reqUser.boards,
        organizations: reqUser.organizations,
        boardStars: reqUser.boardStars,
        cards: cards.cards
      };

      return buildResponse(200, response, res);
    }
  } catch (error) {
    if (error.isBoom) {
      buildResponse(error.output.statusCode, error.message, res)
    } else {
      buildResponse(500, error, res)
    }
  }
};

export const updateUserBoardCards = async (req, res) => {
  try {
    let cards = await cardsModel.findOne({ userId: req.user._id, boardId: req.params.idBoard });

    if (!cards) {
      buildResponse(400, 'This board does not have any cards', res);
    } else {
      cards.cards = req.body.cards;

      let cards = await cards.save();

      if (cards) {
        buildResponse(200, cards.cards, res);
      }
    }
  } catch (error) {
    log.error(error);

    buildResponse(500, error, res);
  }
};

export const saveUserBoardCard = async (req, res) => {
  try {
    let cards = await cardsModel.findOne({ userId: req.user._id, boardId: req.params.idBoard });

    let card = new cardModel({
      header: req.body.name
    });

    if (cards) {
      cards.cards.push(card);

      try {
        let savedCards = await cards.save();

        if (savedCards) {
          let response = {
            cards: cards.cards
          };

          buildResponse(200, response, res);
        }
      } catch (error) {
        buildResponse(500, error, res);
      }
    } else {
      let cardsToSave = new cardsModel({
        boardId: req.params.idBoard,
        userId: req.user._id,
        cards: card
      });

      try {
        let savedCards = await cardsToSave.save();

        if (savedCards) {
          let response = {
            cards: savedCards.cards
          };

          buildResponse(200, response, res);
        }
      } catch (error) {
        buildResponse(500, error, res);
      }
    }
  } catch (error) {
    buildResponse(500, error, res);
  }
};

export const saveUserBoardCardItem = async (req, res) => {
  try {
    let cards = await  cardsModel.findOne({ userId: req.user._id, boardId: req.params.idBoard });

    if (!cards) {
      throw Boom.create(400, 'This board does not have any cards');
    } else {
      let card = cards.cards.id(req.params.idCard);

      if (!card) {
        throw Boom.create(400, 'That card does not exist');
      } else {
        let cardItem = new cardItemModel({
          name: req.body.name
        })

        card.cardItems.push(cardItem);

        return cards.save();
      }
    }
  } catch (error) {
    if (error.isBoom) {
      buildResponse(error.output.statusCode, error.message, res);
    } else {
      buildResponse(500, error, res)
    }
  }
};<|endoftext|>


<commit_before>/* globals openRoom */
RocketChat.roomTypes.add('unread', 10, {
	unread: true,
	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return preferences.roomsListExhibitionMode === 'unread';
	},
	label: 'Unread'
});

RocketChat.roomTypes.add('f', 20, {
	header: 'favorite',
	icon: 'star',
	label: 'Favorites'
});

// activity
RocketChat.roomTypes.add('activity', 30, {
	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return preferences.roomsListExhibitionMode === 'activity';
	},
	label: 'Conversations'
});

RocketChat.roomTypes.add('channels', 30, {
	label: 'Channels',
	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && preferences.mergeChannels;
	}
});
// public
RocketChat.roomTypes.add('c', 30, {
	icon: 'hashtag',
	label: 'Channels',
	route: {
		name: 'channel',
		path: '/channel/:name',
		action(params) {
			return openRoom('c', params.name);
		}
	},

	findRoom(identifier) {
		const query = {
			t: 'c',
			name: identifier
		};
		return ChatRoom.findOne(query);
	},

	roomName(roomData) {
		return roomData.name;
	},

	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && !preferences.mergeChannels && (RocketChat.authz.hasAtLeastOnePermission(['view-c-room', 'view-joined-room']) || RocketChat.settings.get('Accounts_AllowAnonymousRead') === true);
	},

	showJoinLink(roomId) {
		return !!ChatRoom.findOne({ _id: roomId, t: 'c' });
	}
});

// private
RocketChat.roomTypes.add('p', 40, {
	icon: 'lock',
	label: 'Private_Groups',
	route: {
		name: 'group',
		path: '/group/:name',
		action(params) {
			return openRoom('p', params.name);
		}
	},

	findRoom(identifier) {
		const query = {
			t: 'p',
			name: identifier
		};
		return ChatRoom.findOne(query);
	},

	roomName(roomData) {
		return roomData.name;
	},

	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && !preferences.mergeChannels && RocketChat.authz.hasAllPermission('view-p-room');
	}
});

// direct
RocketChat.roomTypes.add('d', 50, {
	icon: false,
	label: 'Direct_Messages',
	route: {
		name: 'direct',
		path: '/direct/:username',
		action(params) {
			return openRoom('d', params.username);
		},
		link(sub) {
			return { username: sub.name };
		}
	},

	findRoom(identifier) {
		const query = {
			t: 'd',
			name: identifier
		};

		const subscription = ChatSubscription.findOne(query);
		if (subscription && subscription.rid) {
			return ChatRoom.findOne(subscription.rid);
		}
	},

	roomName(roomData) {
		const subscription = ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1, fname: 1 } });
		if (!subscription) {
			return '';
		}
		if (RocketChat.settings.get('UI_Use_Real_Name') && subscription.fname) {
			return subscription.fname;
		}

		return subscription.name;
	},

	secondaryRoomName(roomData) {
		if (RocketChat.settings.get('UI_Use_Real_Name')) {
			const subscription = ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1 } });
			return subscription && subscription.name;
		}
	},

	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && RocketChat.authz.hasAtLeastOnePermission(['view-d-room', 'view-joined-room']);
	},

	getUserStatus(roomId) {
		const subscription = RocketChat.models.Subscriptions.findOne({rid: roomId});
		if (subscription == null) { return; }

		return Session.get(`user_${ subscription.name }_status`);
	}
});
<commit_msg>fix channel list new users<commit_after>/* globals openRoom */
RocketChat.roomTypes.add('unread', 10, {
	unread: true,
	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return preferences.roomsListExhibitionMode === 'unread';
	},
	label: 'Unread'
});

RocketChat.roomTypes.add('f', 20, {
	header: 'favorite',
	icon: 'star',
	label: 'Favorites'
});

// activity
RocketChat.roomTypes.add('activity', 30, {
	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return preferences.roomsListExhibitionMode === 'activity';
	},
	label: 'Conversations'
});

RocketChat.roomTypes.add('channels', 30, {
	label: 'Channels',
	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && preferences.mergeChannels;
	}
});
// public
RocketChat.roomTypes.add('c', 30, {
	icon: 'hashtag',
	label: 'Channels',
	route: {
		name: 'channel',
		path: '/channel/:name',
		action(params) {
			return openRoom('c', params.name);
		}
	},

	findRoom(identifier) {
		const query = {
			t: 'c',
			name: identifier
		};
		return ChatRoom.findOne(query);
	},

	roomName(roomData) {
		return roomData.name;
	},

	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return !preferences.roomsListExhibitionMode || ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && !preferences.mergeChannels && (RocketChat.authz.hasAtLeastOnePermission(['view-c-room', 'view-joined-room']) || RocketChat.settings.get('Accounts_AllowAnonymousRead') === true);
	},

	showJoinLink(roomId) {
		return !!ChatRoom.findOne({ _id: roomId, t: 'c' });
	}
});

// private
RocketChat.roomTypes.add('p', 40, {
	icon: 'lock',
	label: 'Private_Groups',
	route: {
		name: 'group',
		path: '/group/:name',
		action(params) {
			return openRoom('p', params.name);
		}
	},

	findRoom(identifier) {
		const query = {
			t: 'p',
			name: identifier
		};
		return ChatRoom.findOne(query);
	},

	roomName(roomData) {
		return roomData.name;
	},

	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return !preferences.roomsListExhibitionMode || ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && !preferences.mergeChannels && RocketChat.authz.hasAllPermission('view-p-room');
	}
});

// direct
RocketChat.roomTypes.add('d', 50, {
	icon: false,
	label: 'Direct_Messages',
	route: {
		name: 'direct',
		path: '/direct/:username',
		action(params) {
			return openRoom('d', params.username);
		},
		link(sub) {
			return { username: sub.name };
		}
	},

	findRoom(identifier) {
		const query = {
			t: 'd',
			name: identifier
		};

		const subscription = ChatSubscription.findOne(query);
		if (subscription && subscription.rid) {
			return ChatRoom.findOne(subscription.rid);
		}
	},

	roomName(roomData) {
		const subscription = ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1, fname: 1 } });
		if (!subscription) {
			return '';
		}
		if (RocketChat.settings.get('UI_Use_Real_Name') && subscription.fname) {
			return subscription.fname;
		}

		return subscription.name;
	},

	secondaryRoomName(roomData) {
		if (RocketChat.settings.get('UI_Use_Real_Name')) {
			const subscription = ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1 } });
			return subscription && subscription.name;
		}
	},

	condition() {
		const user = Meteor.user();
		const preferences = (user && user.settings && user.settings.preferences && user.settings.preferences) || {};
		return !preferences.roomsListExhibitionMode || ['unread', 'category'].includes(preferences.roomsListExhibitionMode) && RocketChat.authz.hasAtLeastOnePermission(['view-d-room', 'view-joined-room']);
	},

	getUserStatus(roomId) {
		const subscription = RocketChat.models.Subscriptions.findOne({rid: roomId});
		if (subscription == null) { return; }

		return Session.get(`user_${ subscription.name }_status`);
	}
});
<|endoftext|>


<commit_before>// Base karma configuration
module.exports = function karmaConfig (karma) {
  'use strict';
  var config = getConfig();

  if (process.env.CI) {
    var customLaunchers = getCustomLaunchers();
    config.sauceLabs = {testName: 'Promissory Arbiter Browser Support'};
    config.reporters.push('saucelabs');
    config.customLaunchers = customLaunchers;
    config.browsers = config.browsers.concat(Object.keys(customLaunchers));
    config.coverageReporter.type = 'lcov';
  }

  karma.set(config);

  function getConfig() {
    return {
      basePath: '',

      port: 9876,
      colors: true,
      logLevel: karma.LOG_INFO,

      autoWatch: true,
      singleRun: false,
      frameworks: ['jasmine'],
      browsers: ['PhantomJS'],
      reporters: ['progress', 'coverage'],

      files: [
        'node_modules/es6-promise/dist/es6-promise.js',
        'src/**/*.js'
      ],
      exclude: [],

      preprocessors: {
        'src/*.js': ['coverage']
      },

      coverageReporter: {
        type: 'html',
        dir: 'docs/coverage'
      }
    };
  }

  function getCustomLaunchers() {
    var launchers = {
      sl_ie8: {
        browserName: 'internet explorer', platform: 'Windows XP', version: '8.0'
      },
      sl_safari_windows: {
        browserName: 'safari', platform: 'Windows 7', version: '5.1'
      },
      sl_firefox_legacy: {
        browserName: 'firefox', platform: 'Windows XP', version: '4.0'
      },
      sl_chrome_legacy: {
        browserName: 'chrome', platform: 'Windows 7', version: '26'
      },
      sl_edge: {
        browserName: 'microsoftedge', platform: 'Windows 10', version: '20.10240'
      },
      sl_capitan: {
        browserName: 'safari', platform: 'OS X 10.11', version: '8.1'
      },
      sl_firefox: {
        browserName: 'firefox', platform: 'Linux', version: '41'
      },
      sl_chrome: {
        browserName: 'chrome', platform: 'Windows 8', version: '45'
      },
    };

    Object.keys(launchers).forEach(function(key) {
      launchers[key].base = 'SauceLabs';
    });

    return launchers;
  }
}

<commit_msg>Update karma test browsers<commit_after>// Base karma configuration
module.exports = function karmaConfig (karma) {
  'use strict';
  var config = getConfig();

  if (process.env.CI) {
    var customLaunchers = getCustomLaunchers();
    config.sauceLabs = {testName: 'Promissory Arbiter Browser Support'};
    config.reporters.push('saucelabs');
    config.customLaunchers = customLaunchers;
    config.browsers = config.browsers.concat(Object.keys(customLaunchers));
    config.coverageReporter.type = 'lcov';
  }

  karma.set(config);

  function getConfig() {
    return {
      basePath: '',

      port: 9876,
      colors: true,
      logLevel: karma.LOG_INFO,

      autoWatch: true,
      singleRun: false,
      frameworks: ['jasmine'],
      browsers: ['PhantomJS'],
      reporters: ['progress', 'coverage'],

      files: [
        'node_modules/es6-promise/dist/es6-promise.js',
        'src/**/*.js'
      ],
      exclude: [],

      preprocessors: {
        'src/*.js': ['coverage']
      },

      coverageReporter: {
        type: 'html',
        dir: 'docs/coverage'
      }
    };
  }

  function getCustomLaunchers() {
    var launchers = {
      sl_ie8: {
        browserName: 'internet explorer', platform: 'Windows XP', version: '8.0'
      },
      sl_safari_windows: {
        browserName: 'safari', platform: 'Windows 7', version: '5.1'
      },
      sl_firefox_legacy: {
        browserName: 'firefox', platform: 'Windows XP', version: '4.0'
      },
      sl_chrome_legacy: {
        browserName: 'chrome', platform: 'Windows 7', version: '26'
      },
      sl_edge: {
        browserName: 'microsoftedge', platform: 'Windows 10', version: '20.10240'
      },
      sl_capitan: {
        browserName: 'safari', platform: 'OS X 10.11', version: '9'
      },
      sl_firefox: {
        browserName: 'firefox', platform: 'Linux', version: '42'
      },
      sl_chrome: {
        browserName: 'chrome', platform: 'Windows 8', version: '46'
      },
    };

    Object.keys(launchers).forEach(function(key) {
      launchers[key].base = 'SauceLabs';
    });

    return launchers;
  }
}

<|endoftext|>


<commit_before>import Ember from 'ember';
/**
  The Taxons Index route.

  **To Override:** You'll need to run the routes generator:

  ```bash
  ember g yebo-ember-storefront-routes
  ```

  This will install all of the Yebo Ember Storefront route files into your
  host application at `app/routes/yebo/*.js`, ready to be extended or
  overriden.

  @class TaxonsIndex
  @namespace Route
  @extends Ember.Component
*/
export default Ember.Route.extend({
  model: function(params) {
    return Ember.RSVP.hash({
      products: this.yebo.store.findAll('product', { taxon_id: params.taxon_id }),
      taxon: this.yebo.store.findAll('taxon').then(function(taxons) {
        return taxons.findBy('permalink', params.taxon_id)
      })
    })
  }
});
<commit_msg>Taxon index route logic<commit_after>import Ember from 'ember';

/**
  The Taxons Index route.

  **To Override:** You'll need to run the routes generator:

  ```bash
  ember g yebo-ember-storefront-routes
  ```

  This will install all of the Yebo Ember Storefront route files into your
  host application at `app/routes/yebo/*.js`, ready to be extended or
  overriden.

  @class TaxonsIndex
  @namespace Route
  @extends Ember.Component
*/
export default Ember.Route.extend({
  //
  model: function() {
    return this.yebo.store.findAll('taxonomy');
  },

  //
  setupController: function(controller, model) {
    // Get the controller
    let appController = this.controllerFor('application');

    // Set some values to the controller
    appController.set('taxonomies', model);
    appController.set('currentTaxonomy', { });
  }
});
<|endoftext|>


<commit_before>module.exports = function (config) {
    config.set({

        // base path, that will be used to resolve files and exclude
        basePath: '',

        // frameworks to use
        frameworks: ['jasmine'],

        // list of files / patterns to load in the browser
        files: [
            'bower_components/ionic/js/ionic.bundle.js',
            'bower_components/angular-mocks/angular-mocks.js',
            'src/ion-autocomplete.js',
            'test/ion-autocomplete.spec.js'
        ],

        // list of files to exclude
        exclude: [],

        // test results reporter to use
        // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
        reporters: ['progress'],

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,

        // Start these browsers, currently available:
        // - Chrome
        // - ChromeCanary
        // - Firefox
        // - Opera
        // - Safari (only Mac)
        // - PhantomJS
        // - IE (only Windows)
        browsers: ['PhantomJS', 'Chrome'],

        // If browser does not capture in given timeout [ms], kill it
        captureTimeout: 60000,

        // Continuous Integration mode
        // if true, it capture browsers, run tests and exit
        singleRun: false,

        customLaunchers: {
            Chrome_travis_ci: {
                base: 'Chrome',
                flags: ['--no-sandbox']
            }
        }
    });

    if (process.env.TRAVIS) {
        configuration.browsers = ['Chrome_travis_ci'];
    }
};
<commit_msg>Typo in Travis CI build configuration<commit_after>module.exports = function (config) {
    config.set({

        // base path, that will be used to resolve files and exclude
        basePath: '',

        // frameworks to use
        frameworks: ['jasmine'],

        // list of files / patterns to load in the browser
        files: [
            'bower_components/ionic/js/ionic.bundle.js',
            'bower_components/angular-mocks/angular-mocks.js',
            'src/ion-autocomplete.js',
            'test/ion-autocomplete.spec.js'
        ],

        // list of files to exclude
        exclude: [],

        // test results reporter to use
        // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
        reporters: ['progress'],

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,

        // Start these browsers, currently available:
        // - Chrome
        // - ChromeCanary
        // - Firefox
        // - Opera
        // - Safari (only Mac)
        // - PhantomJS
        // - IE (only Windows)
        browsers: ['PhantomJS', 'Chrome'],

        // If browser does not capture in given timeout [ms], kill it
        captureTimeout: 60000,

        // Continuous Integration mode
        // if true, it capture browsers, run tests and exit
        singleRun: false,

        customLaunchers: {
            Chrome_travis_ci: {
                base: 'Chrome',
                flags: ['--no-sandbox']
            }
        }
    });

    if (process.env.TRAVIS) {
        config.browsers = ['Chrome_travis_ci'];
    }
};
<|endoftext|>


<commit_before>function add(b, p, ver, device) {
    return {
        base: 'SauceLabs',
        browserName: b,
        platform: p,
        version: ver,
        deviceName: device
    };
}

function addAndroid(output) {
    output['android_4'] = add('android', 'Linux', '4.0', 'Android Emulator');
    output['android_4-4'] = add('android', 'Linux', '4.4', 'Google Nexus 7 HD Emulator');
}

function addIOS(output) {
    output['ios_safari_7-1'] = add('iphone', 'OS X 10.9', '7.1');
    output['ios_safari_8-2'] = add('iphone', 'OS X 10.10', '8.2');
}

function addChrome(output) {
    output['chrome_35'] = add('chrome', 'Windows 7', '35');
    output['chrome_41'] = add('chrome', 'Windows 8.1', '41');
    output['chrome_beta'] = add('chrome', 'Windows 8.1', 'beta');
}

function addFirefox(output) {
    output['firefox_30'] = add('firefox', null, null, '30');
    output['firefox_36'] = add('firefox', null, null, '36');
}

function addIE(output) {
    // output['ie_11'] = add('internet explorer', 'Windows 8.1', '11');
    output['ie_10'] = add('internet explorer', 'Windows 8', '10');
    output['ie_09'] = add('internet explorer', 'Windows 7', '9');
    output['ie_08'] = add('internet explorer', 'Windows 7', '8');
}

module.exports = function(config) {
    var settings = {
        basePath: '',
        frameworks: ['mocha', 'es5-shim', 'sinon', 'referee'],
        plugins: ['karma-*'],
        files: [{
                pattern: 'test/fixtures/childIframe.html',
                included: false,
                served: true
            },
            'node_modules/eventlistener/eventlistener.js',
            'test/helpers/helpers.js',
            'lib/xde.js',
            'test/*.test.js'
        ],
        browsers: ['PhantomJS'],
        singleRun: false,
        autoWatch: true,
        client: {
            captureConsole: true,
            mocha: {
                ui: 'bdd'
            }
        }
    };

    if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
        settings.reporters = ['progress'];
        settings.browsers = ['PhantomJS'];
    } else {
        settings.captureTimeout = 60000 * 3;
        settings.sauceLabs = {
            testName: 'XDE',
            tags: ['xde']
        };
        settings.reporters = ['dots', 'saucelabs'];
        settings.customLaunchers = {};

        // only 3 vmms / browsers per run because of
        // https://github.com/karma-runner/karma-sauce-launcher/issues/40
        // should either add better setup for running max currently or
        if (process.env.BROWSER_TYPE === 'android') {
            addAndroid(settings.customLaunchers);
        } else if (process.env.BROWSER_TYPE === 'ios') {
            addIOS(settings.customLaunchers);
        } else if (process.env.BROWSER_TYPE === 'chrome') {
            addChrome(settings.customLaunchers);
        } else if (process.env.BROWSER_TYPE === 'firefox') {
            addFirefox(settings.customLaunchers);
        } else if (process.env.BROWSER_TYPE === 'ie') {
            addIE(settings.customLaunchers);
        } else {
            console.error('Missing / Unknown pass ' + process.env.PASS);
            process.exit(1);
        }

        console.log('Running CI tests on', Object.keys(settings.customLaunchers).join(', '));
        settings.browsers = Object.keys(settings.customLaunchers);
    }

    config.set(settings);
};
<commit_msg>adding higher timeout values for saucelabs<commit_after>function add(b, p, ver, device) {
    return {
        base: 'SauceLabs',
        browserName: b,
        platform: p,
        version: ver,
        deviceName: device
    };
}

function addAndroid(output) {
    output['android_4'] = add('android', 'Linux', '4.0', 'Android Emulator');
    output['android_4-4'] = add('android', 'Linux', '4.4', 'Google Nexus 7 HD Emulator');
}

function addIOS(output) {
    output['ios_safari_7-1'] = add('iphone', 'OS X 10.9', '7.1');
    output['ios_safari_8-2'] = add('iphone', 'OS X 10.10', '8.2');
}

function addChrome(output) {
    output['chrome_35'] = add('chrome', 'Windows 7', '35');
    output['chrome_41'] = add('chrome', 'Windows 8.1', '41');
    output['chrome_beta'] = add('chrome', 'Windows 8.1', 'beta');
}

function addFirefox(output) {
    output['firefox_30'] = add('firefox', null, null, '30');
    output['firefox_36'] = add('firefox', null, null, '36');
}

function addIE(output) {
    // output['ie_11'] = add('internet explorer', 'Windows 8.1', '11');
    output['ie_10'] = add('internet explorer', 'Windows 8', '10');
    output['ie_09'] = add('internet explorer', 'Windows 7', '9');
    output['ie_08'] = add('internet explorer', 'Windows 7', '8');
}

module.exports = function(config) {
    var settings = {
        basePath: '',
        frameworks: ['mocha', 'es5-shim', 'sinon', 'referee'],
        plugins: ['karma-*'],
        files: [{
                pattern: 'test/fixtures/childIframe.html',
                included: false,
                served: true
            },
            'node_modules/eventlistener/eventlistener.js',
            'test/helpers/helpers.js',
            'lib/xde.js',
            'test/*.test.js'
        ],
        browsers: ['PhantomJS'],
        singleRun: false,
        autoWatch: true,
        client: {
            captureConsole: true,
            mocha: {
                ui: 'bdd'
            }
        }
    };

    if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
        settings.reporters = ['progress'];
        settings.browsers = ['PhantomJS'];
    } else {
        settings.browserDisconnectTimeout = 60000;
        settings.browserNoActivityTimeout = 60000;
        //settings.browserDisconnectTolerance = 1;
        settings.captureTimeout = 60000 * 3;
        settings.sauceLabs = {
            testName: 'XDE',
            tags: ['xde']
        };
        settings.reporters = ['dots', 'saucelabs'];
        settings.customLaunchers = {};

        // only 3 vmms / browsers per run because of
        // https://github.com/karma-runner/karma-sauce-launcher/issues/40
        // should either add better setup for running max currently or
        if (process.env.BROWSER_TYPE === 'android') {
            addAndroid(settings.customLaunchers);
        } else if (process.env.BROWSER_TYPE === 'ios') {
            addIOS(settings.customLaunchers);
        } else if (process.env.BROWSER_TYPE === 'chrome') {
            addChrome(settings.customLaunchers);
        } else if (process.env.BROWSER_TYPE === 'firefox') {
            addFirefox(settings.customLaunchers);
        } else if (process.env.BROWSER_TYPE === 'ie') {
            addIE(settings.customLaunchers);
        } else {
            console.error('Missing / Unknown pass ' + process.env.PASS);
            process.exit(1);
        }

        console.log('Running CI tests on', Object.keys(settings.customLaunchers).join(', '));
        settings.browsers = Object.keys(settings.customLaunchers);
    }

    config.set(settings);
};
<|endoftext|>


<commit_before>// Karma configuration
// Install required modules by running "npm install"

module.exports = function(config) {
  config.set({
    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '.',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: [
      'jasmine-ajax', 'jasmine',
      'sprintf-js',
    ],

    plugins: [
      'karma-*',  // default
      frameworkPluginForModule('sprintf-js'),
    ],

    // list of files / patterns to load in the browser
    files: [
      // closure base first
      'third_party/closure/goog/base.js',

      // deps next
      'dist/deps.js',
      'shaka-player.uncompiled.js',

      // test utils next
      'test/util/*.js',

      // support test first
      'test/support_check.js',

      // unit tests last
      'test/*_unit.js',

      // if --quick is not present, we will add integration tests.

      // source files - these are only watched and served
      {pattern: 'lib/**/*.js', included: false},
      {pattern: 'test/assets/*', included: false},
      {pattern: 'third_party/closure/goog/**/*.js', included: false},
    ],

    proxies: {
      '/test/assets/': '/base/test/assets/',
    },

    preprocessors: {
      // Don't compute coverage over lib/debug/ or lib/polyfill/
      'lib/!(debug|polyfill)/*.js': 'coverage',
      // Player is not matched by the above, so add it explicitly
      'lib/player.js': 'coverage',
    },

    coverageReporter: {
      reporters: [
        { type: 'text' },
      ],
    },

    // do not panic about "no activity" unless a test takes longer than 120s.
    // this value must be greater than any jasmine.DEFAULT_TIMEOUT_INTERVAL used
    // in test cases. (eg. 90s in test/streaming_engine_integration.js)
    browserNoActivityTimeout: 120000,

    client: {
      // don't capture the client's console logs
      captureConsole: false,
      // |args| must be an array; pass a key-value map as the sole client
      // argument.
      args: [{}],
    },

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR ||
    //                  config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_WARN,

    // do not execute tests whenever any file changes
    autoWatch: false,

    // do a single run of the tests on captured browsers and then quit
    singleRun: true,

    customLaunchers: {
      // BrowserStack launchers require login information in the form of
      // the environment variables BROWSER_STACK_USERNAME and
      // BROWSER_STACK_ACCESS_KEY.

      // NOTE: PlayReady not working on BrowserStack IE11.  We are waiting for
      // a response from BrowserStack support.
      BrowserStack_IE11: {
        base: 'BrowserStack',
        browser: 'ie',
        browser_version: '11.0',
        os: 'Windows',
        os_version: '8.1',
      },

      BrowserStack_Edge12: {
        base: 'BrowserStack',
        browser: 'edge',
        browser_version: '12.0',
        os: 'Windows',
        os_version: '10',
      },

      BrowserStack_Edge13: {
        base: 'BrowserStack',
        browser: 'edge',
        browser_version: '13.0',
        os: 'Windows',
        os_version: '10',
      },

      BrowserStack_Safari8: {
        base: 'BrowserStack',
        browser: 'safari',
        browser_version: '8.0',
        os: 'OS X',
        os_version: 'Yosemite',
      },

      BrowserStack_Safari9: {
        base: 'BrowserStack',
        browser: 'safari',
        browser_version: '9.0',
        os: 'OS X',
        os_version: 'El Capitan',
      },

      WebDriver_Safari8: {
        base: 'WebDriver',
        config: {hostname: 'localhost', port: 4444},
        browserName: 'safari',
        pseudoActivityInterval: 20000
      },

      WebDriver_Safari9: {
        base: 'WebDriver',
        config: {hostname: 'localhost', port: 4445},
        browserName: 'safari',
        pseudoActivityInterval: 20000
      },

      WebDriver_IE11: {
        base: 'WebDriver',
        config: {hostname: 'localhost', port: 4446},
        browserName: 'internet explorer',
        pseudoActivityInterval: 20000
      },
    },

    browserStack: {
      // Always start a tunnel if using BrowserStack.  This used to be default,
      // but is now required as an explicit parameter.
      startTunnel: true
    },

    // By default, use Chrome only, unless command-line arguments override.
    browsers: ['Chrome'],
  });

  if (flagPresent('html-coverage-report')) {
    // Wipe out any old coverage reports to avoid confusion.
    var rimraf = require('rimraf');
    rimraf.sync('coverage', {});  // Like rm -rf

    config.set({
      reporters: [ 'coverage', 'progress' ],
      coverageReporter: {
        reporters: [
          { type: 'html', dir: 'coverage' },
        ],
      },
    });
  }

  if (!flagPresent('quick')) {
    var files = config.files;
    files.push('test/*_integration.js');
    // We just modified the config in-place.  No need for config.set().
  }

  var logLevel = getFlagValue('enable-logging');
  if (logLevel !== null) {
    if (logLevel === '')
      logLevel = 3;  // INFO

    config.set({
      reporters: ['spec'],
    });
    // Setting |config.client| using config.set will remove the
    // |config.client.args| member.
    config.client.captureConsole = true;
    setClientArg(config, 'logLevel', logLevel);
  }
};

// Sets the value of an argument passed to the client.
function setClientArg(config, name, value) {
  config.client.args[0][name] = value;
}

// Find a custom command-line flag that has a value (e.g. --option=12).
// Returns:
// * string value  --option=12
// * empty string  --option= or --option
// * null          not present
function getFlagValue(name) {
  var re = /^--([^=]+)(?:=(.*))?$/;
  for (var i = 0; i < process.argv.length; i++) {
    var match = re.exec(process.argv[i]);
    if (match && match[1] == name) {
      if (match[2] !== undefined)
        return match[2];
      else
        return '';
    }
  }

  return null;
}

// Find custom command-line flags.
function flagPresent(name) {
  return getFlagValue(name) !== null;
}

// Construct framework plugins on-the-fly for arbitrary node modules.
// A call to this must be placed in the config in the 'plugins' array,
// and the module name must be added to the config in the 'frameworks' array.
function frameworkPluginForModule(name) {
  // The framework injects files into the client which runs the tests.
  var framework = function(files) {
    // Locate the main file for the node module.
    var path = require('path');
    var mainFile = path.resolve(require.resolve(name));

    // Add a file entry to the list of files to be served.
    // This follows the same syntax as above in config.set({files: ...}).
    files.unshift({
      pattern: mainFile, included: true, served: true, watched: false
    });
  };

  // The framework factory function takes one argument, which is the list of
  // files from the karma config.
  framework.$inject = ['config.files'];

  // This is the plugin interface to register a new framework.  Adding this to
  // the list of plugins makes the named module available as a framework.  That
  // framework then injects the module into the client.
  var obj = {};
  obj['framework:' + name] = ['factory', framework];
  return obj;
}
<commit_msg>Don't print skipped tests when using spec reporter.<commit_after>// Karma configuration
// Install required modules by running "npm install"

module.exports = function(config) {
  config.set({
    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '.',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: [
      'jasmine-ajax', 'jasmine',
      'sprintf-js',
    ],

    plugins: [
      'karma-*',  // default
      frameworkPluginForModule('sprintf-js'),
    ],

    // list of files / patterns to load in the browser
    files: [
      // closure base first
      'third_party/closure/goog/base.js',

      // deps next
      'dist/deps.js',
      'shaka-player.uncompiled.js',

      // test utils next
      'test/util/*.js',

      // support test first
      'test/support_check.js',

      // unit tests last
      'test/*_unit.js',

      // if --quick is not present, we will add integration tests.

      // source files - these are only watched and served
      {pattern: 'lib/**/*.js', included: false},
      {pattern: 'test/assets/*', included: false},
      {pattern: 'third_party/closure/goog/**/*.js', included: false},
    ],

    proxies: {
      '/test/assets/': '/base/test/assets/',
    },

    preprocessors: {
      // Don't compute coverage over lib/debug/ or lib/polyfill/
      'lib/!(debug|polyfill)/*.js': 'coverage',
      // Player is not matched by the above, so add it explicitly
      'lib/player.js': 'coverage',
    },

    // do not panic about "no activity" unless a test takes longer than 120s.
    // this value must be greater than any jasmine.DEFAULT_TIMEOUT_INTERVAL used
    // in test cases. (eg. 90s in test/streaming_engine_integration.js)
    browserNoActivityTimeout: 120000,

    client: {
      // don't capture the client's console logs
      captureConsole: false,
      // |args| must be an array; pass a key-value map as the sole client
      // argument.
      args: [{}],
    },

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR ||
    //                  config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_WARN,

    // do not execute tests whenever any file changes
    autoWatch: false,

    // do a single run of the tests on captured browsers and then quit
    singleRun: true,

    // By default, use Chrome only, unless command-line arguments override.
    browsers: ['Chrome'],

    customLaunchers: {
      // BrowserStack launchers require login information in the form of
      // the environment variables BROWSER_STACK_USERNAME and
      // BROWSER_STACK_ACCESS_KEY.

      // NOTE: PlayReady not working on BrowserStack IE11.  We are waiting for
      // a response from BrowserStack support.
      BrowserStack_IE11: {
        base: 'BrowserStack',
        browser: 'ie',
        browser_version: '11.0',
        os: 'Windows',
        os_version: '8.1',
      },

      BrowserStack_Edge12: {
        base: 'BrowserStack',
        browser: 'edge',
        browser_version: '12.0',
        os: 'Windows',
        os_version: '10',
      },

      BrowserStack_Edge13: {
        base: 'BrowserStack',
        browser: 'edge',
        browser_version: '13.0',
        os: 'Windows',
        os_version: '10',
      },

      BrowserStack_Safari8: {
        base: 'BrowserStack',
        browser: 'safari',
        browser_version: '8.0',
        os: 'OS X',
        os_version: 'Yosemite',
      },

      BrowserStack_Safari9: {
        base: 'BrowserStack',
        browser: 'safari',
        browser_version: '9.0',
        os: 'OS X',
        os_version: 'El Capitan',
      },

      WebDriver_Safari8: {
        base: 'WebDriver',
        config: {hostname: 'localhost', port: 4444},
        browserName: 'safari',
        pseudoActivityInterval: 20000
      },

      WebDriver_Safari9: {
        base: 'WebDriver',
        config: {hostname: 'localhost', port: 4445},
        browserName: 'safari',
        pseudoActivityInterval: 20000
      },

      WebDriver_IE11: {
        base: 'WebDriver',
        config: {hostname: 'localhost', port: 4446},
        browserName: 'internet explorer',
        pseudoActivityInterval: 20000
      },
    },

    browserStack: {
      // Always start a tunnel if using BrowserStack.  This used to be default,
      // but is now required as an explicit parameter.
      startTunnel: true
    },

    coverageReporter: {
      reporters: [
        { type: 'text' },
      ],
    },

    specReporter: {
      suppressSkipped: true,
    },
  });

  if (flagPresent('html-coverage-report')) {
    // Wipe out any old coverage reports to avoid confusion.
    var rimraf = require('rimraf');
    rimraf.sync('coverage', {});  // Like rm -rf

    config.set({
      reporters: [ 'coverage', 'progress' ],
      coverageReporter: {
        reporters: [
          { type: 'html', dir: 'coverage' },
        ],
      },
    });
  }

  if (!flagPresent('quick')) {
    var files = config.files;
    files.push('test/*_integration.js');
    // We just modified the config in-place.  No need for config.set().
  }

  var logLevel = getFlagValue('enable-logging');
  if (logLevel !== null) {
    if (logLevel === '')
      logLevel = 3;  // INFO

    config.set({
      reporters: ['spec'],
    });
    // Setting |config.client| using config.set will remove the
    // |config.client.args| member.
    config.client.captureConsole = true;
    setClientArg(config, 'logLevel', logLevel);
  }
};

// Sets the value of an argument passed to the client.
function setClientArg(config, name, value) {
  config.client.args[0][name] = value;
}

// Find a custom command-line flag that has a value (e.g. --option=12).
// Returns:
// * string value  --option=12
// * empty string  --option= or --option
// * null          not present
function getFlagValue(name) {
  var re = /^--([^=]+)(?:=(.*))?$/;
  for (var i = 0; i < process.argv.length; i++) {
    var match = re.exec(process.argv[i]);
    if (match && match[1] == name) {
      if (match[2] !== undefined)
        return match[2];
      else
        return '';
    }
  }

  return null;
}

// Find custom command-line flags.
function flagPresent(name) {
  return getFlagValue(name) !== null;
}

// Construct framework plugins on-the-fly for arbitrary node modules.
// A call to this must be placed in the config in the 'plugins' array,
// and the module name must be added to the config in the 'frameworks' array.
function frameworkPluginForModule(name) {
  // The framework injects files into the client which runs the tests.
  var framework = function(files) {
    // Locate the main file for the node module.
    var path = require('path');
    var mainFile = path.resolve(require.resolve(name));

    // Add a file entry to the list of files to be served.
    // This follows the same syntax as above in config.set({files: ...}).
    files.unshift({
      pattern: mainFile, included: true, served: true, watched: false
    });
  };

  // The framework factory function takes one argument, which is the list of
  // files from the karma config.
  framework.$inject = ['config.files'];

  // This is the plugin interface to register a new framework.  Adding this to
  // the list of plugins makes the named module available as a framework.  That
  // framework then injects the module into the client.
  var obj = {};
  obj['framework:' + name] = ['factory', framework];
  return obj;
}
<|endoftext|>


<commit_before>"use strict";
let bsCaps;
if (process.env.BROWSER_STACK_USERNAME) {
    bsCaps = require("browserstack-capabilities")(process.env.BROWSER_STACK_USERNAME, process.env.BROWSER_STACK_ACCESS_KEY);
}

module.exports = (config) => {
    let customLaunchers = {};
    config.set({
        frameworks: ["mocha"],
        reporters: ["coverage-istanbul", "progress", "BrowserStack"].slice(0, bsCaps ? 3: 2),
        files: ["test/test_index.js"],
        preprocessors: {
            "test/test_index.js": ["webpack", "sourcemap"]
        },
        webpack: require("./webpack.config"),
        beforeMiddleware: ["webpackBlocker"],
        concurrency: bsCaps ? 1: Infinity,
        browsers: bsCaps ? bsCaps.create({
            browser: ["chrome", "firefox"],
            "browser_version": "latest"
        }).map((cap) => {
            cap.base = "BrowserStack";
            var browser = ("device" in cap && cap.device) ? cap.device:
                (cap.browser + " " +
                cap.browser_version + " on " +
                cap.os + " " +
                cap.os_version + " resolution:" +
                cap.resolution);
            customLaunchers[browser] = cap;
            return browser;
        }).filter((_, i) => i % (process.env.CIRCLE_NODE_TOTAL || 1) == process.env.CIRCLE_NODE_INDEX): [],
        browserStack: {
            project: (process.env.CIRCLE_PROJECT_REPONAME || "frame") + "_" + (process.env.CIRCLE_BRANCH || require("child_process").execSync("git branch | grep \\* | cut -d \" \" -f2-"))
        },
        customLaunchers: customLaunchers
    });
};
<commit_msg>Complexity を減らしました。<commit_after>"use strict";

const frameworks = ["mocha"];
const reporters = ["coverage-istanbul", "progress"];
const files = ["test/test_index.js"];
const preprocessors = {
    "test/test_index.js": ["webpack", "sourcemap"]
};
const webpack = require("./webpack.config");
const beforeMiddleware = ["webpackBlocker"];
let concurrency = Infinity;
const browsers = [];
const customLaunchers = {};
const browserStack = {
    project: "frame_" + require("child_process").execSync("git branch | grep \\* | cut -d \" \" -f2-")
};

if (process.env.BROWSER_STACK_USERNAME) {
    reporters.push("BrowserStack");
    concurrency = 1;
    const bsCaps = require("browserstack-capabilities")(process.env.BROWSER_STACK_USERNAME, process.env.BROWSER_STACK_ACCESS_KEY);
    const capabilities = bsCaps.create({
        "browser": ["chrome", "firefox"],
        "browser_version": "latest"
    });
    capabilities.forEach((capability) => {
        const browser = Object.keys(capability).map((key) => capability[key]).filter((str) => str).join();
        browsers.push(browser);
        capability.base = "BrowserStack";
        customLaunchers[browser] = capability;
    });
}

if (process.env.CIRCLECI) {
    browsers.sort();
    const browserNum = Math.ceil(browsers.length / process.env.CIRCLE_NODE_TOTAL);
    browsers.splice(0, browserNum * process.env.CIRCLE_NODE_INDEX);
    browsers.splice(browserNum * (process.env.CIRCLE_NODE_INDEX + 1));
    browserStack.project = process.env.CIRCLE_PROJECT_REPONAME + "_" + process.env.CIRCLE_BRANCH
}

module.exports = (config) => {
    let customLaunchers = {};
    config.set({
        frameworks,
        reporters,
        files,
        preprocessors,
        webpack,
        beforeMiddleware,
        concurrency,
        browsers,
        browserStack,
        customLaunchers
    });
};
<|endoftext|>


<commit_before>var toString = require('../lang/toString')

// underscore.string titleize.js

function titleize (str) {
  return toString(str).toLowerCase().replace(/(?:^|\s|-)\S/g, function (c) {
    return c.toUpperCase()
  })
}

module.exports = titleize
<commit_msg>update string/case-titleize adjust dependencies<commit_after>var stringify = require('./stringify')
var normalize = require('./case-normalize')

// underscore.string titleize.js

function titleize (str) {
  return stringify(str)
    .toLowerCase()
    .replace(/(?:^|\s|-)\S/g, function (c) {
    return c.toUpperCase()
  })
}

module.exports = titleize
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Thu Nov 24 2016 06:53:29 GMT+0100 (WAT)

module.exports = (config) => {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'jasmine/src/js/*.js',
      'jasmine/spec/*.js'
    ],

    // list of files to exclude
    exclude: [
      'jasmine/src/js/app.js'
    ],

    // preprocess matching files before serving them to the browser
    preprocessors: {
    },

    // test results reporter to use
    reporters: ['spec', 'coverage', 'coveralls'],

    coverageReporter: {
      type: 'lcov',
      dir: 'coverage/'
    },

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    logLevel: config.LOG_INFO,

    // enable/disable watching file
    autoWatch: true,

    // start these browsers depending on our enviroment
    browsers: process.env.TRAVIS ? ['Chrome_travis_ci']: ['Chrome'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  });
};
<commit_msg>add missing custom launcher to karma config file<commit_after>// Karma configuration
// Generated on Thu Nov 24 2016 06:53:29 GMT+0100 (WAT)

module.exports = (config) => {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'jasmine/src/js/*.js',
      'jasmine/spec/*.js'
    ],

    // list of files to exclude
    exclude: [
      'jasmine/src/js/app.js'
    ],

    // preprocess matching files before serving them to the browser
    preprocessors: {
    },

    // test results reporter to use
    reporters: ['spec', 'coverage', 'coveralls'],

    coverageReporter: {
      type: 'lcov',
      dir: 'coverage/'
    },

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    logLevel: config.LOG_INFO,

    // enable/disable watching file
    autoWatch: true,

    customLaunchers: {
      Chrome_travis_ci: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },

    // start these browsers depending on our enviroment
    browsers: process.env.TRAVIS ? ['Chrome_travis_ci'] : ['Chrome'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  });
};
<|endoftext|>


<commit_before>
/*!
 * Module dependencies
 */

var mongoose = require('mongoose');
//var userPlugin = require('mongoose-user');
var Schema = mongoose.Schema;
var QueryPlugin = require('mongoose-query');

/**
 * User schema
 */
var ResultSchema = new Schema({
  tcid: { type: String, required: true },
  tcRef: {type: Schema.Types.ObjectId, ref: 'Testcase' },
  cre: {
    time: {type: Date, default: Date.now},
    user: {type: String},
    userRef: {type: Schema.Types.ObjectId, ref: 'User' }
  },
  exec: {
    verdict: { type: String, required: true, enum: ['pass', 'fail', 'inconclusive', 'blocked', 'error'] },
    duration: {type: Number}, //seconds
    env: { //environment information
      ref: {type: Schema.Types.ObjectId, ref: 'Resource' },
      rackId: {type: String},
      framework: {
        name: {type: String, enum: ['clitest'], required: true},
        ver: {type: String, required: true},
      },
    },
    sut: { // software under test
      ref: {type: Schema.Types.ObjectId, ref: 'Build' },
      branch: {type: String},
      commitId: {type: String},
      tag: [{type: String}],
      href: {type: String}
    },
    dut: {  //device under test
      ref: {type: Schema.Types.ObjectId, ref: 'Resource' },
      vendor: {type: String},
      model: {type: String},
      ver: {type: String},
      sn: {type: String}
    },
    logs: [
      {
        ref: {type: Schema.Types.ObjectId, ref: 'Resource' },
        from: {type: String, enum: ['dut', 'framework', 'env', 'other']},
        filename: {type: String},
        filesize: {type: Number},
        refs: {type: String},
        data: {type: Buffer},
      }
    ]
  }
});

/**
 * Query plugin
 */
ResultSchema.plugin( QueryPlugin ); //install QueryPlugin

/**
 * Add your
 * - pre-save hooks
 * - validations
 * - virtuals
 */

/**
 * Methods
 */

ResultSchema.method({

});

/**
 * Statics
 */

ResultSchema.static({

});

/**
 * Register
 */
mongoose.model('Result', ResultSchema);
<commit_msg>update result object<commit_after>
/*!
 * Module dependencies
 */

var mongoose = require('mongoose');
//var userPlugin = require('mongoose-user');
var Schema = mongoose.Schema;
var QueryPlugin = require('mongoose-query');

/**
 * User schema
 */
var ResultSchema = new Schema({
  tcid: { type: String, required: true },
  tcRef: {type: Schema.Types.ObjectId, ref: 'Testcase' },
  cre: {
    time: {type: Date, default: Date.now},
    user: {type: String},
    userRef: {type: Schema.Types.ObjectId, ref: 'User' }
  },
  exec: {
    verdict: { type: String, required: true, enum: ['pass', 'fail', 'inconclusive', 'blocked', 'error'] },
    duration: {type: Number}, //seconds
    env: { //environment information
      ref: {type: Schema.Types.ObjectId, ref: 'Resource' },
      rackId: {type: String},
      framework: {
        name: {type: String, enum: ['clitest'], required: true},
        ver: {type: String, required: true},
      },
    },
    sut: { // software under test
      ref: {type: Schema.Types.ObjectId, ref: 'Build' },
      branch: {type: String},
      commitId: {type: String},
      tag: [{type: String}],
      href: {type: String},
      cut: [{type: String}], // Component Under Test
      fut: [{type: String}], // Feature Under Test
    },
    dut: {  //device under test
      count: {type: Number},
      type: {type: String, enum: ['hw','simulator', 'process'], default: 'simulator'},
      ref: {type: Schema.Types.ObjectId, ref: 'Resource' },
      vendor: {type: String},
      model: {type: String},
      ver: {type: String},
      sn: {type: String}
    },
    logs: [
      {
        ref: {type: Schema.Types.ObjectId, ref: 'Resource' },
        from: {type: String, enum: ['dut', 'framework', 'env', 'other']},
        filename: {type: String},
        filesize: {type: Number},
        refs: {type: String},
        data: {type: Buffer},
      }
    ]
  }
});

/**
 * Query plugin
 */
ResultSchema.plugin( QueryPlugin ); //install QueryPlugin

/**
 * Add your
 * - pre-save hooks
 * - validations
 * - virtuals
 */

/**
 * Methods
 */

ResultSchema.method({

});

/**
 * Statics
 */

ResultSchema.static({

});

/**
 * Register
 */
mongoose.model('Result', ResultSchema);
<|endoftext|>