<commit_before>var babelify = require('babelify').configure({loose: 'all'});
var isparta = require('isparta');
var istanbul = require('browserify-istanbul')({
  ignore: ['**/node_modules/**', '**/test/**'],
  instrumenter: isparta
});

module.exports = function(config) {
  config.set({
    basePath: 'test',
    browsers: ['PhantomJS'],
    frameworks: ['browserify', 'fixture', 'mocha'],
    files: [
      'spec/fixtures/*.html',
      'spec/*.js'
    ],
    preprocessors: {
      '**/*.js': ['browserify'],
      '**/*.html': ['html2js']
    },
    reporters: ['progress', 'coverage', 'coveralls'],
    coverageReporter: {
      reporters: [
        {type: 'lcov'},
        {type: 'text'}
      ]
    },
    browserify: {
      debug: true,
      transform: [istanbul, babelify]
    },

    // Custom browser configurations for Sauce Labs.
    customLaunchers: {
      'SL_Chrome': {
        base: 'SauceLabs',
        browserName: 'chrome',
        version: '41'
      },
      'SL_Firefox': {
        base: 'SauceLabs',
        browserName: 'firefox',
        version: '36'
      },
      'SL_Safari': {
        base: 'SauceLabs',
        browserName: 'safari',
        platform: 'OS X 10.10',
        version: '8'
      },
      'SL_IE_8': {
        base: 'SauceLabs',
        browserName: 'internet explorer',
        platform: 'Windows 7',
        version: '8'
      },
      'SL_IE_9': {
        base: 'SauceLabs',
        browserName: 'internet explorer',
        platform: 'Windows 7',
        version: '9'
      },
      'SL_IE_10': {
        base: 'SauceLabs',
        browserName: 'internet explorer',
        platform: 'Windows 8',
        version: '10'
      },
      'SL_IE_11': {
        base: 'SauceLabs',
        browserName: 'internet explorer',
        platform: 'Windows 8.1',
        version: '11'
      }
    }
  })

  try {
    var sauceCredentials = require('./sauce.json');
    process.env.SAUCE_USERNAME = sauceCredentials.username;
    process.env.SAUCE_ACCESS_KEY = sauceCredentials.accessKey;
  } catch (e) {
    console.log('Note: run `git-crypt unlock` to use Sauce Labs credentials.');
  }

  if (process.env.SAUCE_USERNAME) {
    config.browserNoActivityTimeout = 30 * 1000;
    config.sauceLabs = {
      testName: 'XPath Range test',
    };
  }

  if (process.env.TRAVIS) {
    config.browsers = [process.env.BROWSER];
    config.singleRun = true;
    if (process.env.BROWSER === 'PhantomJS') {
      config.reporters = ['progress', 'coverage', 'coveralls'];
    } else {
      config.reporters = ['progress', 'saucelabs'];
    }
  }
}
<commit_msg>Re-enable loose on the isparta instrumenter, too<commit_after>var babelify = require('babelify').configure({loose: 'all'});
var isparta = require('isparta');
var istanbul = require('browserify-istanbul')({
  ignore: ['**/node_modules/**', '**/test/**'],
  instrumenter: isparta,
  instrumenterConfig: {babel: {loose: 'all'}}
});

module.exports = function(config) {
  config.set({
    basePath: 'test',
    browsers: ['PhantomJS'],
    frameworks: ['browserify', 'fixture', 'mocha'],
    files: [
      'spec/fixtures/*.html',
      'spec/*.js'
    ],
    preprocessors: {
      '**/*.js': ['browserify'],
      '**/*.html': ['html2js']
    },
    reporters: ['progress', 'coverage', 'coveralls'],
    coverageReporter: {
      reporters: [
        {type: 'lcov'},
        {type: 'text'}
      ]
    },
    browserify: {
      debug: true,
      transform: [istanbul, babelify]
    },

    // Custom browser configurations for Sauce Labs.
    customLaunchers: {
      'SL_Chrome': {
        base: 'SauceLabs',
        browserName: 'chrome',
        version: '41'
      },
      'SL_Firefox': {
        base: 'SauceLabs',
        browserName: 'firefox',
        version: '36'
      },
      'SL_Safari': {
        base: 'SauceLabs',
        browserName: 'safari',
        platform: 'OS X 10.10',
        version: '8'
      },
      'SL_IE_8': {
        base: 'SauceLabs',
        browserName: 'internet explorer',
        platform: 'Windows 7',
        version: '8'
      },
      'SL_IE_9': {
        base: 'SauceLabs',
        browserName: 'internet explorer',
        platform: 'Windows 7',
        version: '9'
      },
      'SL_IE_10': {
        base: 'SauceLabs',
        browserName: 'internet explorer',
        platform: 'Windows 8',
        version: '10'
      },
      'SL_IE_11': {
        base: 'SauceLabs',
        browserName: 'internet explorer',
        platform: 'Windows 8.1',
        version: '11'
      }
    }
  })

  try {
    var sauceCredentials = require('./sauce.json');
    process.env.SAUCE_USERNAME = sauceCredentials.username;
    process.env.SAUCE_ACCESS_KEY = sauceCredentials.accessKey;
  } catch (e) {
    console.log('Note: run `git-crypt unlock` to use Sauce Labs credentials.');
  }

  if (process.env.SAUCE_USERNAME) {
    config.browserNoActivityTimeout = 30 * 1000;
    config.sauceLabs = {
      testName: 'XPath Range test',
    };
  }

  if (process.env.TRAVIS) {
    config.browsers = [process.env.BROWSER];
    config.singleRun = true;
    if (process.env.BROWSER === 'PhantomJS') {
      config.reporters = ['progress', 'coverage', 'coveralls'];
    } else {
      config.reporters = ['progress', 'saucelabs'];
    }
  }
}
<|endoftext|>


<commit_before>import AlertService from './AlertService';
import controllerModule from '../common/ControllerModule';
import DeepStreamService from '../common/DeepStreamService';
import BindMessages from './BindMessages';

class AlertController {
    constructor(AlertService, CommonService, DeepStreamService, BindMessages) {
        this.alertService = AlertService;
        this.commonService = CommonService;
        this.deepStreamService = DeepStreamService;
        this.bindMessages = BindMessages;
        this.alertMessages = "";
        this.mainMarker = {
            lat: 13.0601709,
            lng: 77.56245290000001,
            focus: true,
            message: "I am draggable",
            draggable: false,
            icon: {
                iconUrl: 'img/location-pointer.png',
                iconSize: [32, 32], // size of the icon
                iconAnchor: [22, 94], // point of the icon which will correspond to marker's location
                shadowAnchor: [4, 62],  // the same for the shadow
                popupAnchor: [-7, -90] // point from which the popup should open relative to the iconAnchor
            }
        };
        this.connection = this.deepStreamService.getServerConnection();

        /*this.list = this.connection.record.getRecord('safety/messages');
         this.fields = ['firstname', 'lastname'];
         this.sendMessage = [{'firstname': 'sandeep-name', 'lastname': 'M'},
         {'firstname': 'raghu', 'lastname': 'k'},
         {'firstname': 'sanmay', 'lastname': 'M'}];
         this.list.set(this.sendMessage);
         this.bindMessages.getField(this, this.list, this.fields);

         this.messages = [];
         this.list.subscribe((entries) => {
         console.log("inside subscribe controller");
         console.log(entries);
         this.messages = entries;
         entries.map((entry)=> {
         var record = this.connection.record.getRecord(entry);
         // record.subscribe(scopeApply);
         // return record;
         this.messages.push(record);
         });
         console.log(this.messages);
         // scopeApply();

         });

         */
        this.messages = [];
        angular.extend(this, {
            london: {
                lat: 13.0601709,
                lng: 77.56245290000001,
                zoom: 15
            },
            markers: {
                mainMarker: angular.copy(this.mainMarker)
            },
            position: {
                lat: 51,
                lng: 0
            }
        });
        this.sendMessage = [];
        this.readMessage = [];
    };

    loadAlertsAsync() {
        console.log("this.alertmessages");
        this.list = this.connection.record.getRecord('safety/messages');
        this.list.subscribe((entries) => {
            console.log(entries);
            this.alertMessages = entries;
        });
        console.log(this.alertMessages);
        /*this.alertService.getAlertDataFromService().then((data) => {
            this.alertMessages = data;
        });*/
    };

    sendMessages(formMessages) {
        this.list = this.connection.record.getRecord('safety/messages');
        console.log(formMessages.userMessage);
        /*this.list.subscribe((entries) => {
            console.log("inside subscribe controller -send");
            console.log(entries);
            count = entries.length;
            /!*angular.forEach(entries, (entry) => {
             this.sendMessage.push(entry);
             });*!/

        });*/
        // this.sendMessage.push({'message': formMessages.userMessage});
        // this.list.push(this.sendMessage);
    }

    readMessages() {
        this.list = this.connection.record.getRecord('safety/messages');
        this.list.subscribe((entries) => {
            console.log(entries);
            this.readMessage = entries;
            console.log("inside subscribe controller - read");
            /*angular.forEach(entries, (entry) => {
             this.readMessage.push(entry);
             });*/

        });
        console.log(this.readMessage);
    };

    deleteMessages() {
        this.list = this.connection.record.getRecord('safety/messages').delete();
        console.log(this.list);
        // this.list.discard();
    };
}

AlertController.$inject = ['AlertService', 'CommonService', 'DeepStreamService', 'BindMessages'];
export default controllerModule.controller('AlertController', AlertController).name;<commit_msg>code cleanup<commit_after>import AlertService from './AlertService';
import controllerModule from '../common/ControllerModule';
import DeepStreamService from '../common/DeepStreamService';
import BindMessages from './BindMessages';

class AlertController {
    constructor(AlertService, CommonService, DeepStreamService, BindMessages) {
        this.alertService = AlertService;
        this.commonService = CommonService;
        this.deepStreamService = DeepStreamService;
        this.bindMessages = BindMessages;
        this.alertMessages = "";
        this.mainMarker = {
            lat: 13.0601709,
            lng: 77.56245290000001,
            focus: true,
            message: "I am draggable",
            draggable: false,
            icon: {
                iconUrl: 'img/location-pointer.png',
                iconSize: [32, 32], // size of the icon
                iconAnchor: [22, 94], // point of the icon which will correspond to marker's location
                shadowAnchor: [4, 62],  // the same for the shadow
                popupAnchor: [-7, -90] // point from which the popup should open relative to the iconAnchor
            }
        };
        this.connection = this.deepStreamService.getServerConnection();

        angular.extend(this, {
            london: {
                lat: 13.0601709,
                lng: 77.56245290000001,
                zoom: 15
            },
            markers: {
                mainMarker: angular.copy(this.mainMarker)
            },
            position: {
                lat: 51,
                lng: 0
            }
        });
        this.sendMessage = [];
        this.readMessage = [];
    };

    loadAlertsAsync() {
        console.log("this.alertmessages");
        this.list = this.connection.record.getRecord('safety/messages');
        this.list.subscribe((entries) => {
            console.log(entries);
            this.alertMessages = entries;
        });
        console.log(this.alertMessages);
        /*this.alertService.getAlertDataFromService().then((data) => {
         this.alertMessages = data;
         });*/
    };

    sendMessages(formMessages) {
        console.log(formMessages.userMessage);
    }

    readMessages() {
        this.list = this.connection.record.getRecord('safety/messages');
        this.list.subscribe((entries) => {
            console.log("inside subscribe controller - read");
            console.log(entries);
        });
    };

    deleteMessages() {
        //this.list = this.connection.record.getRecord('safety/messages').delete();
        // console.log(this.list);
        // this.list.discard();
    };
}

AlertController.$inject = ['AlertService', 'CommonService', 'DeepStreamService', 'BindMessages'];
export default controllerModule.controller('AlertController', AlertController).name;<|endoftext|>


<commit_before>/*jslint node: true */
module.exports = function (config) {
    'use strict';

    config.set({

        basePath: '',

        files: [
            'app/bower_components/angular/angular.js',
            'app/bower_components/angular-route/angular-route.js',
            'app/bower_components/angular-mocks/angular-mocks.js',
            'app/bower_components/angular-cookies/angular-cookies.js',
            'app/bower_components/angular-touch/angular-touch.js',
            'app/bower_components/angular-animate/angular-animate.js',
            'app/bower_components/angular-bootstrap/ui-bootstrap.js',
            'app/bower_components/underscore/underscore.js',
            'app/bower_components/jquery/dist/jquery.js',
            'app/js/app.js',
            'app/js/**/*.js',
            'test/client/**/*.js'
        ],

        colors: true,
        singleRun: true,

        frameworks: ['jasmine'],

        browsers: ['PhantomJS'],

        plugins: [
            'karma-phantomjs-launcher',
            'karma-jasmine',
            'karma-coverage',
            'karma-junit-reporter'
        ],

        reporters: ['progress', 'coverage', 'junit'],

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

        preprocessors: {
            'app/js/**/*.js': 'coverage'
        },

        junitReporter: {
            outputDir: 'build/reports'
        }
    });
};
<commit_msg>Remove redundant glob expression<commit_after>/*jslint node: true */
module.exports = function (config) {
    'use strict';

    config.set({

        basePath: '',

        files: [
            'app/bower_components/angular/angular.js',
            'app/bower_components/angular-route/angular-route.js',
            'app/bower_components/angular-mocks/angular-mocks.js',
            'app/bower_components/angular-cookies/angular-cookies.js',
            'app/bower_components/angular-touch/angular-touch.js',
            'app/bower_components/angular-animate/angular-animate.js',
            'app/bower_components/angular-bootstrap/ui-bootstrap.js',
            'app/bower_components/underscore/underscore.js',
            'app/bower_components/jquery/dist/jquery.js',
            'app/js/**/*.js',
            'test/client/**/*.js'
        ],

        colors: true,
        singleRun: true,

        frameworks: ['jasmine'],

        browsers: ['PhantomJS'],

        plugins: [
            'karma-phantomjs-launcher',
            'karma-jasmine',
            'karma-coverage',
            'karma-junit-reporter'
        ],

        reporters: ['progress', 'coverage', 'junit'],

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

        preprocessors: {
            'app/js/**/*.js': 'coverage'
        },

        junitReporter: {
            outputDir: 'build/reports'
        }
    });
};
<|endoftext|>


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

  var customLaunchers = {
    sl_chrome: {
      base: 'SauceLabs',
      browserName: 'chrome',
      platform: 'Windows 7',
      version: '41'
    },

    sl_firefox: {
      base: 'SauceLabs',
      browserName: 'firefox',
      version: '37'
    },

//    sl_ios_safari: {
//      base: 'SauceLabs',
//      browserName: 'iphone',
//      platform: 'OS X 10.9',
//      version: '7.1'
//    },

//    sl_ie_11: {
//      base: 'SauceLabs',
//      browserName: 'internet explorer',
//      platform: 'Windows 8.1',
//      version: '11'
//    }

  };

  config.set({
    basePath: '.',
    files: [
      './index.js',

      'test/errors.test.js',
      'test/index.test.js'
    ],

    frameworks: ['mocha', 'sinon-chai'],
    reporters: ['dots', 'saucelabs'],
    browsers: process.env.NODE_ENV === 'development' ? [ 'Chrome' ] : Object.keys(customLaunchers),
    customLaunchers: customLaunchers,
    sauceLabs: {
      testName: 'Yield-yield tests'
    },
    singleRun: true
  });

};
<commit_msg>Added tests still to rework<commit_after>module.exports = function (config) {

  var customLaunchers = {
    sl_chrome: {
      base: 'SauceLabs',
      browserName: 'chrome',
      platform: 'Windows 7',
      version: '41'
    },

    sl_firefox: {
      base: 'SauceLabs',
      browserName: 'firefox',
      version: '37'
    },

//    sl_ios_safari: {
//      base: 'SauceLabs',
//      browserName: 'iphone',
//      platform: 'OS X 10.9',
//      version: '7.1'
//    },

//    sl_ie_11: {
//      base: 'SauceLabs',
//      browserName: 'internet explorer',
//      platform: 'Windows 8.1',
//      version: '11'
//    }

  };

  config.set({
    basePath: '.',
    files: [
      './index.js',

      'test/errors.test.js',
      'test/index.test.js'
      // 'test/process.test.js',
      // 'test/twice.test.js'
    ],

    frameworks: ['mocha', 'sinon-chai'],
    reporters: ['dots', 'saucelabs'],
    browsers: process.env.NODE_ENV === 'development' ? [ 'Chrome' ] : Object.keys(customLaunchers),
    customLaunchers: customLaunchers,
    sauceLabs: {
      testName: 'Yield-yield tests'
    },
    singleRun: true
  });

};
<|endoftext|>


<commit_before>/* eslint-disable global-require */
const path = require('path');

const webpack = require('webpack');
const ESLintPlugin = require('eslint-webpack-plugin');
const testsRules = require('./Utilities/config/rules-tests');

const sourcePath = path.join(__dirname, './Sources');

if (!process.env.NODE_ENV) process.env.NODE_ENV = 'test';

module.exports = function init(config) {
  config.set({
    plugins: [
      require('karma-webpack'),
      require('karma-chrome-launcher'),
      require('karma-firefox-launcher'),
      require('karma-coverage'),
      require('karma-junit-reporter'),
      require('./Utilities/Karma/tape-object-stream'),
      require('./Utilities/Karma/tape-html-reporter'),
    ],

    basePath: '',
    frameworks: ['tape-object-stream', 'webpack'],
    files: [
      'Sources/Testing/setupTestEnv.js',
      'Sources/**/test*.js',
      { pattern: 'Data/**', watched: false, served: true, included: false },
    ],

    preprocessors: {
      'Sources/Testing/setupTestEnv.js': ['webpack'],
      'Sources/**/test*.js': ['webpack'],
    },

    webpack: {
      mode: 'development',
      module: {
        rules: [].concat(testsRules),
      },
      resolve: {
        modules: [path.resolve(__dirname, 'node_modules'), sourcePath],
        alias: {
          'vtk.js': __dirname,
          stream: 'stream-browserify',
          buffer: 'buffer',
        },
        fallback: {
          path: false,
          fs: false,
        },
      },
      plugins: [
        new ESLintPlugin(),
        new webpack.DefinePlugin({
          __BASE_PATH__: "'/base'",
        }),
        new webpack.ProvidePlugin({ process: ['process/browser'] }),
      ],
    },

    reporters: ['coverage', 'junit', 'tape-html'],

    tapeHTMLReporter: {
      templateFile: 'Utilities/Karma/reporting-template.html',
      outputFile: 'Utilities/TestResults/Test-Report.html',
    },

    coverageReporter: {
      dir: 'Documentation/build-tmp/public',
      reporters: [{ type: 'html', subdir: 'coverage' }],
    },

    junitReporter: {
      outputDir: 'Utilities/TestResults',
    },

    client: {
      useIframe: true,
    },

    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: ['--no-sandbox', '--ignore-gpu-blacklist'],
      },
      ChromeWebGPU: {
        base: 'ChromeCanary',
        flags: ['--enable-unsafe-webgpu'],
      },
    },
    // browserNoActivityTimeout: 600000,
    // browserDisconnectTimeout: 600000,

    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: true,
  });
};
<commit_msg>chore(karma): increase disconnect timeout<commit_after>/* eslint-disable global-require */
const path = require('path');

const webpack = require('webpack');
const ESLintPlugin = require('eslint-webpack-plugin');
const testsRules = require('./Utilities/config/rules-tests');

const sourcePath = path.join(__dirname, './Sources');

if (!process.env.NODE_ENV) process.env.NODE_ENV = 'test';

module.exports = function init(config) {
  config.set({
    plugins: [
      require('karma-webpack'),
      require('karma-chrome-launcher'),
      require('karma-firefox-launcher'),
      require('karma-coverage'),
      require('karma-junit-reporter'),
      require('./Utilities/Karma/tape-object-stream'),
      require('./Utilities/Karma/tape-html-reporter'),
    ],

    basePath: '',
    frameworks: ['tape-object-stream', 'webpack'],
    files: [
      'Sources/Testing/setupTestEnv.js',
      'Sources/**/test*.js',
      { pattern: 'Data/**', watched: false, served: true, included: false },
    ],

    preprocessors: {
      'Sources/Testing/setupTestEnv.js': ['webpack'],
      'Sources/**/test*.js': ['webpack'],
    },

    webpack: {
      mode: 'development',
      module: {
        rules: [].concat(testsRules),
      },
      resolve: {
        modules: [path.resolve(__dirname, 'node_modules'), sourcePath],
        alias: {
          'vtk.js': __dirname,
          stream: 'stream-browserify',
          buffer: 'buffer',
        },
        fallback: {
          path: false,
          fs: false,
        },
      },
      plugins: [
        new ESLintPlugin(),
        new webpack.DefinePlugin({
          __BASE_PATH__: "'/base'",
        }),
        new webpack.ProvidePlugin({ process: ['process/browser'] }),
      ],
    },

    reporters: ['coverage', 'junit', 'tape-html'],

    tapeHTMLReporter: {
      templateFile: 'Utilities/Karma/reporting-template.html',
      outputFile: 'Utilities/TestResults/Test-Report.html',
    },

    coverageReporter: {
      dir: 'Documentation/build-tmp/public',
      reporters: [{ type: 'html', subdir: 'coverage' }],
    },

    junitReporter: {
      outputDir: 'Utilities/TestResults',
    },

    client: {
      useIframe: true,
    },

    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: ['--no-sandbox', '--ignore-gpu-blacklist'],
      },
      ChromeWebGPU: {
        base: 'ChromeCanary',
        flags: ['--enable-unsafe-webgpu'],
      },
    },
    // browserNoActivityTimeout: 600000,
    browserDisconnectTimeout: 10000,
    browserDisconnectTolerance: 3,

    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: true,
  });
};
<|endoftext|>


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

    basePath : './',

    files : [
      'app/bower_components/angular/angular.js',
      'app/bower_components/angular-route/angular-route.js',
      'app/bower_components/angular-mocks/angular-mocks.js',
      'app/components/**/*.js',
      'app/authentication/**/*.js',
      'app/view*/**/*.js'
    ],

    autoWatch : true,

    frameworks: ['jasmine', 'sinon'],

    browsers : ['Chrome'],

    plugins : [
            'karma-chrome-launcher',
            'karma-firefox-launcher',
            'karma-jasmine',
            'karma-junit-reporter'
            ],

    junitReporter : {
      outputFile: 'test_out/unit.xml',
      suite: 'unit'
    }

  });
};
<commit_msg>Fix the karma-plugins configuration<commit_after>module.exports = function(config){
  config.set({

    basePath : './',

    files : [
      'app/bower_components/angular/angular.js',
      'app/bower_components/angular-route/angular-route.js',
      'app/bower_components/angular-mocks/angular-mocks.js',
      'app/components/**/*.js',
      'app/authentication/**/*.js',
      'app/view*/**/*.js'
    ],

    autoWatch : true,

    frameworks: ['jasmine', 'sinon'],

    browsers : ['Chrome'],

    junitReporter : {
      outputFile: 'test_out/unit.xml',
      suite: 'unit'
    }

  });
};
<|endoftext|>


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

  var appBase   = 'app/';      // transpiled app JS files
  var appAssets ='/base/app/'; // component assets fetched by Angular's compiler

  config.set({
    basePath: '',
    frameworks: ['jasmine'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-htmlfile-reporter')
    ],

    customLaunchers: {
      // From the CLI. Not used here but interesting
      // chrome setup for travis CI using chromium
      Chrome_travis_ci: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },
    files: [
      // System.js for module loading
      'node_modules/systemjs/dist/system.src.js',

      // Polyfills
      'node_modules/core-js/client/shim.js',

      // Reflect and Zone.js
      'node_modules/reflect-metadata/Reflect.js',
      'node_modules/zone.js/dist/zone.js',
      'node_modules/zone.js/dist/async-test.js',
      'node_modules/zone.js/dist/fake-async-test.js',
      'node_modules/zone.js/dist/sync-test.js',
      'node_modules/zone.js/dist/proxy-zone.js',

      // RxJs.
      { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
      { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },

      // Angular 2 itself and the testing library
      {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
      {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},

      {pattern: 'systemjs.config.js', included: false, watched: false},
      'karma-test-shim.js',

      // transpiled application & spec code paths loaded via module imports
      {pattern: appBase + '**/*.js', included: false, watched: true},

      // asset (HTML & CSS) paths loaded via Angular's component compiler
      // (these paths need to be rewritten, see proxies section)
      {pattern: appBase + '**/*.html', included: false, watched: true},
      {pattern: appBase + '**/*.css', included: false, watched: true},

      // paths for debugging with source maps in dev tools
      {pattern: appBase + '**/*.ts', included: false, watched: false},
      {pattern: appBase + '**/*.js.map', included: false, watched: false}
    ],

    // proxied base paths for loading assets
    proxies: {
      // required for component assets fetched by Angular's compiler
      "/app/": appAssets
    },

    exclude: [],
    preprocessors: {},
    reporters: ['progress', 'html'],

    // HtmlReporter configuration
    htmlReporter: {
      // Open this file to see results in browser
      outputFile: '_test-output/tests.html',

      // Optional
      pageTitle: 'Unit Tests',
      subPageTitle: __dirname
    },

    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  })
}
<commit_msg>cherry picked commit 1c78664<commit_after>module.exports = function(config) {

  var appBase   = 'app/';      // transpiled app JS files
  var appAssets ='/base/app/'; // component assets fetched by Angular's compiler

  config.set({
    basePath: '',
    frameworks: ['jasmine'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-htmlfile-reporter')
    ],

    customLaunchers: {
      // From the CLI. Not used here but interesting
      // chrome setup for travis CI using chromium
      Chrome_travis_ci: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },
    files: [
      // System.js for module loading
      'node_modules/systemjs/dist/system.src.js',

      // Polyfills
      'node_modules/core-js/client/shim.js',

      // Reflect and Zone.js
      'node_modules/reflect-metadata/Reflect.js',
      'node_modules/zone.js/dist/zone.js',
      'node_modules/zone.js/dist/async-test.js',
      'node_modules/zone.js/dist/fake-async-test.js',
      'node_modules/zone.js/dist/sync-test.js',
      'node_modules/zone.js/dist/proxy.js',

      // RxJs.
      { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
      { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },

      // Angular 2 itself and the testing library
      {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
      {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},

      {pattern: 'systemjs.config.js', included: false, watched: false},
      'karma-test-shim.js',

      // transpiled application & spec code paths loaded via module imports
      {pattern: appBase + '**/*.js', included: false, watched: true},

      // asset (HTML & CSS) paths loaded via Angular's component compiler
      // (these paths need to be rewritten, see proxies section)
      {pattern: appBase + '**/*.html', included: false, watched: true},
      {pattern: appBase + '**/*.css', included: false, watched: true},

      // paths for debugging with source maps in dev tools
      {pattern: appBase + '**/*.ts', included: false, watched: false},
      {pattern: appBase + '**/*.js.map', included: false, watched: false}
    ],

    // proxied base paths for loading assets
    proxies: {
      // required for component assets fetched by Angular's compiler
      "/app/": appAssets
    },

    exclude: [],
    preprocessors: {},
    reporters: ['progress', 'html'],

    // HtmlReporter configuration
    htmlReporter: {
      // Open this file to see results in browser
      outputFile: '_test-output/tests.html',

      // Optional
      pageTitle: 'Unit Tests',
      subPageTitle: __dirname
    },

    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  })
}
<|endoftext|>


<commit_before>/*
 * Karma configuration.
 *
 * @author Aki Karkkainen
 * @url https://github.com/akikoo/grunt-frontend-workflow
 * Twitter: http://twitter.com/akikoo
 *
 * See https://github.com/kjbekkelund/karma-requirejs
 * See http://karma-runner.github.io/0.8/plus/RequireJS.html
 */

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

// list of files / patterns to load in the browser
files = [

    // Adapters
    JASMINE,
    JASMINE_ADAPTER,
    REQUIRE,
    REQUIRE_ADAPTER,

    // Which files do you want to test?
    //
    // Choose all the files we want to load with Require.js.
    {pattern: 'www/js/lib/**/*.js', included: false},       // All external libraries.
    {pattern: 'www/js/app/**/*.js', included: false},       // Our source code.
    {pattern: 'test/spec/*Spec.js', included: false},       // All the tests.

    // Which files do you want to include with <script> tag?
    //
    // Choose all files which are not loaded by Require.js.
    // Usually you'll only need to include your test-main.js file,
    // which has the same role for your tests as main.js has for
    // your app when using Require.js.
    'test/test-main.js'
];

// list of files to exclude
// We don't want to actually start the application in our tests.
exclude = [
    'www/js/app/mainpage.js',
    'www/js/app/subpage.js'
];

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

// web server port
port = 9876;

// cli runner port
runnerPort = 9100;

// enable / disable colors in the output (reporters and logs)
colors = true;

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = 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 = [
    // 'Chrome',
    // 'PhantomJS'
    // 'Safari',
    'Firefox'
];

// 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>Adapted Karma configuration in karma.conf.js, to follow the latest updated syntax.<commit_after>/*
 * Karma configuration. Generated on Wed Oct 09 2013 12:04:13 GMT+0200 (CEST)
 *
 * @author Aki Karkkainen (edits)
 * @url https://github.com/akikoo/grunt-frontend-workflow
 * Twitter: http://twitter.com/akikoo
 *
 * See https://github.com/kjbekkelund/karma-requirejs
 * See http://karma-runner.github.io/0.8/plus/RequireJS.html
 */

module.exports = function (config) {

    config.set({

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

        // Frameworks to use.
        frameworks: ['jasmine', 'requirejs'],

        // list of files / patterns to load in the browser.
        files: [
            // Which files do you want to test?
            //
            // Choose all the files we want to load with Require.js.
            {pattern: 'www/js/lib/**/*.js', included: false},   // All external libraries.
            {pattern: 'www/js/app/**/*.js', included: false},   // Our source code.
            {pattern: 'test/spec/*Spec.js', included: false},   // All the tests.

            // Which files do you want to include with <script> tag?
            //
            // Choose all files which are not loaded by Require.js.
            // Usually you'll only need to include your test-main.js file,
            // which has the same role for your tests as main.js has for
            // your app when using Require.js.
            'test/test-main.js'
        ],

        // List of files to exclude.
        // We don't want to actually start the application in our tests.
        exclude: [
            'www/js/app/mainpage.js',
            'www/js/app/subpage.js'
        ],

        // 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: ['Firefox'],

        // 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";

module.exports = (config) => {

    const options = {
        frameworks: ["polyfill", "mocha"],
        reporters: ["coverage-istanbul"],
        files: ["test/index.js"],
        preprocessors: {
            "test/index.js": ["webpack", "sourcemap"]
        },
        webpack: require("./webpack.config"),
        beforeMiddleware: ["webpackBlocker"]
    };

    if (!process.env.CIRCLECI) {
        options.reporters.push("progress");
    } else {
        options.singleRun = true;
        options.logLevel = config.LOG_ERROR;
        options.reporters.push("junit");
        options.junitReporter = {
            outputDir: process.env.CIRCLE_TEST_REPORTS + "/junit/"
        };
        options.concurrency = 1;
        options.browserNoActivityTimeout = 240000;
        options.browserDisconnectTolerance = 1;
        options.browserDisconnectTimeout = 10000;
        options.captureTimeout = 240000;

        options.browserStack = {
            project: process.env.CIRCLE_PROJECT_REPONAME + "_" + process.env.CIRCLE_BRANCH
        };

        let customLaunchers = {};

        switch (process.env.CIRCLE_NODE_INDEX) {
            case "0":
                // Test on BrowserStack
                options.reporters.push("BrowserStack");
                const bsCaps = require("browserstack-capabilities")(process.env.BROWSER_STACK_USERNAME, process.env.BROWSER_STACK_ACCESS_KEY);
                const capabilities = bsCaps.create([{
                    "browser": ["chrome", "firefox", "ie", "opera", "edge"],
                    "browser_version": "latest",
                    "os": "Windows",
                    "os_version": ["10", "7"]
                }, {
                    "browser": ["chrome", "firefox", "opera", "safari"],
                    "browser_version": "latest",
                    "os": "OS X",
                    "os_version": ["Sierra", "El Capitan"]
                }]).filter((capability) => capability);
                const browsers = [];
                capabilities.forEach((capability) => {
                    const browser = [
                        "os",
                        "os_version",
                        "browser",
                        "browser_version"
                    ].map((key) => capability[key]).join(" ");
                    browsers.push(browser);
                    capability.base = "BrowserStack";
                    customLaunchers[browser] = capability;
                });
                options.customLaunchers = customLaunchers;
                options.browsers = browsers;
                break;
            case "1":
                // Test on SauceLabs
                options.reporters.push("saucelabs");
                customLaunchers = {
                    slChrome: {
                        base: "SauceLabs",
                        browserName: "chrome",
                        platform: "Windows 7",
                        version: "35"
                    },
                    slFirefox: {
                        base: "SauceLabs",
                        browserName: "firefox",
                        version: "30"
                    },
                    slSafari: {
                        base: "SauceLabs",
                        browserName: "safari",
                        platform: "macOS 10.12",
                        version: "10.0"
                    },
                    slIE11: {
                        base: "SauceLabs",
                        browserName: "internet explorer",
                        platform: "Windows 8.1",
                        version: "11"
                    }
                };
                options.customLaunchers = customLaunchers;
                options.browsers = Object.keys(customLaunchers);
                break;
            case "2":
                break;
            case "3":
                break;
            default:
        }
    }

    config.set(options);
};
<commit_msg>SauceLabでのテストからappleのプラットフォームを削除し、windowsのブラウザを追加。<commit_after>"use strict";

module.exports = (config) => {

    const options = {
        frameworks: ["polyfill", "mocha"],
        reporters: ["coverage-istanbul"],
        files: ["test/index.js"],
        preprocessors: {
            "test/index.js": ["webpack", "sourcemap"]
        },
        webpack: require("./webpack.config"),
        beforeMiddleware: ["webpackBlocker"]
    };

    if (!process.env.CIRCLECI) {
        options.reporters.push("progress");
    } else {
        options.singleRun = true;
        options.logLevel = config.LOG_ERROR;
        options.reporters.push("junit");
        options.junitReporter = {
            outputDir: process.env.CIRCLE_TEST_REPORTS + "/junit/"
        };
        options.concurrency = 1;
        options.browserNoActivityTimeout = 240000;
        options.browserDisconnectTolerance = 1;
        options.browserDisconnectTimeout = 10000;
        options.captureTimeout = 240000;

        options.browserStack = {
            project: process.env.CIRCLE_PROJECT_REPONAME + "_" + process.env.CIRCLE_BRANCH
        };

        let customLaunchers = {};

        switch (process.env.CIRCLE_NODE_INDEX) {
            case "0":
                // Test on BrowserStack
                options.reporters.push("BrowserStack");
                const bsCaps = require("browserstack-capabilities")(process.env.BROWSER_STACK_USERNAME, process.env.BROWSER_STACK_ACCESS_KEY);
                const capabilities = bsCaps.create([{
                    "browser": ["chrome", "firefox", "ie", "opera", "edge"],
                    "browser_version": "latest",
                    "os": "Windows",
                    "os_version": ["10", "7"]
                }, {
                    "browser": ["chrome", "firefox", "opera", "safari"],
                    "browser_version": "latest",
                    "os": "OS X",
                    "os_version": ["Sierra", "El Capitan"]
                }]).filter((capability) => capability);
                const browsers = [];
                capabilities.forEach((capability) => {
                    const browser = [
                        "os",
                        "os_version",
                        "browser",
                        "browser_version"
                    ].map((key) => capability[key]).join(" ");
                    browsers.push(browser);
                    capability.base = "BrowserStack";
                    customLaunchers[browser] = capability;
                });
                options.customLaunchers = customLaunchers;
                options.browsers = browsers;
                break;
            case "1":
                // Test on SauceLabs
                options.reporters.push("saucelabs");
                customLaunchers = {
                    "Chrome on Windows 7": {
                        base: "SauceLabs",
                        browserName: "chrome",
                        version: "latest",
                        platform: "Windows 7"
                    },
                    "Firefox on Windows 7": {
                        base: "SauceLabs",
                        browserName: "firefox",
                        version: "latest",
                        platform: "Windows 7"
                    },
                    "Internet Explorer 11 on Windows 7": {
                        base: "SauceLabs",
                        browserName: "internet explorer",
                        version: "11",
                        platform: "Windows 7"
                    },
                    "Opera on Windows 7": {
                        base: "SauceLabs",
                        browserName: "opera",
                        version: "latest",
                        platform: "Windows 7"
                    },
                    "Edge on Windows 10": {
                        base: "SauceLabs",
                        browserName: "MicrosoftEdge",
                        version: "latest",
                        platform: "Windows 10"
                    },
                    "Internet Explorer 11 on Windows 10": {
                        base: "SauceLabs",
                        browserName: "internet explorer",
                        version: "11",
                        platform: "Windows 10"
                    },
                    "Chrome on Windows 10": {
                        base: "SauceLabs",
                        browserName: "chrome",
                        version: "latest",
                        platform: "Windows 10"
                    },
                    "Firefox on Windows 10": {
                        base: "SauceLabs",
                        browserName: "firefox",
                        version: "latest",
                        platform: "Windows 10"
                    }
                };
                options.customLaunchers = customLaunchers;
                options.browsers = Object.keys(customLaunchers);
                break;
            case "2":
                break;
            case "3":
                break;
            default:
        }
    }

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


<commit_before>/*jshint node: true */
// Karma configuration
// Generated on Thu Mar 12 2015 16:54:00 GMT-0500 (Central Daylight Time)

// use test configuration
process.env.NODE_ENV = 'test';

// load gme configuration
var testFixture = require('./test/_globals.js'),
    gmeConfig = testFixture.getGmeConfig(),
    webgme = testFixture.WebGME,
    Q = testFixture.Q,
    gmeAuth,
    storage,
    server,
    logger = testFixture.logger.fork('karma.conf'),
    PROJECTS_TO_IMPORT = [
        {name: 'ProjectAndBranchOperationsTest', path: './test-karma/client/js/client/basicProject.json'},
        {name: 'noBranchSeedProject', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'alreadyExists', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'createGenericBranch', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'removeGenericBranch', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'metaQueryAndManipulationTest', path: './test-karma/client/js/client/metaTestProject.json'},
        {name: 'ClientNodeInquiryTests', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {name: 'nodeManipulationProject', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {name: 'RESTLikeTests', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {name: 'undoRedoTests', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {name: 'territoryProject', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {name: 'projectSeedSingleMaster', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {
            name: 'projectSeedSingleNonMaster',
            path: './test-karma/client/js/client/clientNodeTestProject.json',
            branches: ['other']
        },
        {
            name: 'projectSeedMultiple',
            path: './test-karma/client/js/client/clientNodeTestProject.json',
            branches: ['master', 'other']
        },
        {name: 'pluginProject', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'branchWatcher', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'branchStatus', path: './test-karma/client/js/client/pluginProject.json'}
    ];

(function initializeServer() {
    'use strict';
    // Add a user to to GMEAuth
    var projectNames = PROJECTS_TO_IMPORT.map(function (projectData) {
        return projectData.name;
    });
    console.log(projectNames);
    testFixture.clearDBAndGetGMEAuth(gmeConfig, projectNames)
        .then(function (gmeAuth_) {
            // Open the database storage
            gmeAuth = gmeAuth_;
            storage = testFixture.getMongoStorage(logger, gmeConfig, gmeAuth);
            return storage.openDatabase();
        })
        .then(function () {
            // Delete the projects to be imported
            function deleteProject(projectInfo) {
                return testFixture.forceDeleteProject(storage, gmeAuth, projectInfo.name);
            }

            return Q.all(PROJECTS_TO_IMPORT.map(deleteProject));
        })
        .then(function () {
            // Import all the projects.
            function importProject(projectInfo) {
                var branchName = projectInfo.hasOwnProperty('branches') ?
                    projectInfo.branches[0] : 'master';

                return testFixture.importProject(storage, {
                    projectSeed: projectInfo.path,
                    projectName: projectInfo.name,
                    branchName: branchName,
                    gmeConfig: gmeConfig,
                    logger: logger
                })
                    .then(function (importResult) {
                        var i,
                            createBranches = [];
                        if (projectInfo.hasOwnProperty('branches') && projectInfo.branches.length > 1) {
                            // First one is already added thus i = 1.
                            for (i = 1; i < projectInfo.branches.length; i += 1) {
                                createBranches.push(storage.createBranch({
                                        projectId: testFixture.projectName2Id(projectInfo.name),
                                        branchName: projectInfo.branches[i],
                                        hash: importResult.commitHash
                                    })
                                );
                            }
                        }
                        return Q.all(createBranches);
                    });
            }

            return Q.all(PROJECTS_TO_IMPORT.map(importProject));
        })
        .then(function () {
            // Close the storage
            return storage.closeDatabase();
        })
        .then(function () {
            server = webgme.standaloneServer(gmeConfig);
            //setTimeout(function () {
            server.start(function () {
                console.log('webgme server started');
            });
            //}, 10000); // timeout to emulate long server start up see test-main.js
        })
        .catch(function (err) {
            console.error(err);
        });
}());

module.exports = function (config) {
    'use strict';

    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: ['mocha', 'requirejs', 'chai'],

        // list of files / patterns to load in the browser
        files: [
            {pattern: 'src/**/*.js', included: false},
            {pattern: 'utils/build/empty/empty.js', included: false},
            {pattern: 'test/plugin/scenarios/plugins/**/*.js', included: false},
            {pattern: 'seeds/*.json', included: false}, //seeds
            {pattern: 'test-karma/**/*.spec.js', included: false},
            {pattern: 'test-karma/**/*.inc.js', included: false}, //test include scripts
            {pattern: 'test-karma/**/*.json', included: false}, //test assets
            'test-main.js'
        ],

        // list of files to exclude
        exclude: [
            'src/server/middleware/executor/worker/node_modules/**/*.js'
        ],

        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {
            'src/**/*.js': ['coverage']
        },

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['dots', 'coverage'],

        // 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
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['Chrome', 'Firefox'],

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

        // forward these requests to the webgme server. All other files are server by the karma web server
        proxies: {
            '/base/gmeConfig.json': 'http://localhost:' + gmeConfig.server.port + '/gmeConfig.json',
            '/rest': 'http://localhost:' + gmeConfig.server.port + '/rest',
            '/worker': 'http://localhost:' + gmeConfig.server.port + '/worker',
            '/listAllDecorators': 'http://localhost:' + gmeConfig.server.port + '/listAllDecorators',
            '/listAllPlugins': 'http://localhost:' + gmeConfig.server.port + '/listAllPlugins',
            '/listAllSeeds': 'http://localhost:' + gmeConfig.server.port + '/listAllSeeds'
        }
    });
};
<commit_msg>Increase timout values for karma config to avoid DISCONNECT messages on travis.<commit_after>/*jshint node: true */
// Karma configuration
// Generated on Thu Mar 12 2015 16:54:00 GMT-0500 (Central Daylight Time)

// use test configuration
process.env.NODE_ENV = 'test';

// load gme configuration
var testFixture = require('./test/_globals.js'),
    gmeConfig = testFixture.getGmeConfig(),
    webgme = testFixture.WebGME,
    Q = testFixture.Q,
    gmeAuth,
    storage,
    server,
    logger = testFixture.logger.fork('karma.conf'),
    PROJECTS_TO_IMPORT = [
        {name: 'ProjectAndBranchOperationsTest', path: './test-karma/client/js/client/basicProject.json'},
        {name: 'noBranchSeedProject', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'alreadyExists', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'createGenericBranch', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'removeGenericBranch', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'metaQueryAndManipulationTest', path: './test-karma/client/js/client/metaTestProject.json'},
        {name: 'ClientNodeInquiryTests', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {name: 'nodeManipulationProject', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {name: 'RESTLikeTests', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {name: 'undoRedoTests', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {name: 'territoryProject', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {name: 'projectSeedSingleMaster', path: './test-karma/client/js/client/clientNodeTestProject.json'},
        {
            name: 'projectSeedSingleNonMaster',
            path: './test-karma/client/js/client/clientNodeTestProject.json',
            branches: ['other']
        },
        {
            name: 'projectSeedMultiple',
            path: './test-karma/client/js/client/clientNodeTestProject.json',
            branches: ['master', 'other']
        },
        {name: 'pluginProject', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'branchWatcher', path: './test-karma/client/js/client/pluginProject.json'},
        {name: 'branchStatus', path: './test-karma/client/js/client/pluginProject.json'}
    ];

(function initializeServer() {
    'use strict';
    // Add a user to to GMEAuth
    var projectNames = PROJECTS_TO_IMPORT.map(function (projectData) {
        return projectData.name;
    });
    console.log(projectNames);
    testFixture.clearDBAndGetGMEAuth(gmeConfig, projectNames)
        .then(function (gmeAuth_) {
            // Open the database storage
            gmeAuth = gmeAuth_;
            storage = testFixture.getMongoStorage(logger, gmeConfig, gmeAuth);
            return storage.openDatabase();
        })
        .then(function () {
            // Delete the projects to be imported
            function deleteProject(projectInfo) {
                return testFixture.forceDeleteProject(storage, gmeAuth, projectInfo.name);
            }

            return Q.all(PROJECTS_TO_IMPORT.map(deleteProject));
        })
        .then(function () {
            // Import all the projects.
            function importProject(projectInfo) {
                var branchName = projectInfo.hasOwnProperty('branches') ?
                    projectInfo.branches[0] : 'master';

                return testFixture.importProject(storage, {
                    projectSeed: projectInfo.path,
                    projectName: projectInfo.name,
                    branchName: branchName,
                    gmeConfig: gmeConfig,
                    logger: logger
                })
                    .then(function (importResult) {
                        var i,
                            createBranches = [];
                        if (projectInfo.hasOwnProperty('branches') && projectInfo.branches.length > 1) {
                            // First one is already added thus i = 1.
                            for (i = 1; i < projectInfo.branches.length; i += 1) {
                                createBranches.push(storage.createBranch({
                                        projectId: testFixture.projectName2Id(projectInfo.name),
                                        branchName: projectInfo.branches[i],
                                        hash: importResult.commitHash
                                    })
                                );
                            }
                        }
                        return Q.all(createBranches);
                    });
            }

            return Q.all(PROJECTS_TO_IMPORT.map(importProject));
        })
        .then(function () {
            // Close the storage
            return storage.closeDatabase();
        })
        .then(function () {
            server = webgme.standaloneServer(gmeConfig);
            //setTimeout(function () {
            server.start(function () {
                console.log('webgme server started');
            });
            //}, 10000); // timeout to emulate long server start up see test-main.js
        })
        .catch(function (err) {
            console.error(err);
        });
}());

module.exports = function (config) {
    'use strict';

    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: ['mocha', 'requirejs', 'chai'],

        // list of files / patterns to load in the browser
        files: [
            {pattern: 'src/**/*.js', included: false},
            {pattern: 'utils/build/empty/empty.js', included: false},
            {pattern: 'test/plugin/scenarios/plugins/**/*.js', included: false},
            {pattern: 'seeds/*.json', included: false}, //seeds
            {pattern: 'test-karma/**/*.spec.js', included: false},
            {pattern: 'test-karma/**/*.inc.js', included: false}, //test include scripts
            {pattern: 'test-karma/**/*.json', included: false}, //test assets
            'test-main.js'
        ],

        // list of files to exclude
        exclude: [
            'src/server/middleware/executor/worker/node_modules/**/*.js'
        ],

        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {
            'src/**/*.js': ['coverage']
        },

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['dots', 'coverage'],

        // 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
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['Chrome', 'Firefox'],

        // to avoid DISCONNECTED messages
        browserDisconnectTimeout: 10000, // default 2000
        browserDisconnectTolerance: 1, // default 0
        browserNoActivityTimeout: 60000, //default 10000

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

        // forward these requests to the webgme server. All other files are server by the karma web server
        proxies: {
            '/base/gmeConfig.json': 'http://localhost:' + gmeConfig.server.port + '/gmeConfig.json',
            '/rest': 'http://localhost:' + gmeConfig.server.port + '/rest',
            '/worker': 'http://localhost:' + gmeConfig.server.port + '/worker',
            '/listAllDecorators': 'http://localhost:' + gmeConfig.server.port + '/listAllDecorators',
            '/listAllPlugins': 'http://localhost:' + gmeConfig.server.port + '/listAllPlugins',
            '/listAllSeeds': 'http://localhost:' + gmeConfig.server.port + '/listAllSeeds'
        }
    });
};
<|endoftext|>


<commit_before> module.exports = function(config) {
    "use strict";

    config.set({
      frameworks: ['jasmine', 'fixture'],

      singleRun: true,

      browsers: ['Firefox', 'Chrome'],

      files: [
        // PhantomJS polyfill
        'node_modules/phantomjs-polyfill/bind-polyfill.js',

        // Vendor files
        'node_modules/jquery/dist/jquery.js',
        'node_modules/jasmine-jquery/lib/jasmine-jquery.js',

        // Helper files

        // Fixtures
        /*{ pattern: 'src/test/fixtures/html/*.html',
          watched: true,
          served:  true,
          included: false },*/

        /*{ pattern: 'src/test/fixtures/json/*.json',
          watched: true,
          served:  true,
          included: false },*/

        // Source code
        'src/js/Calendar.js',

        // Spec files
        'src/test/js/*Spec.js'
      ],

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

      exclude: [
        'src/js/main.js'
      ],

      plugins: [
        'karma-jasmine',
        'karma-firefox-launcher',
        'karma-chrome-launcher',
        'karma-phantomjs-launcher',
        'karma-fixture',
        'karma-junit-reporter',
        'karma-coverage'
      ],

      reporters: ['progress', 'junit', 'coverage'],

      junitReporter: {
        outputDir: 'build/test-reports'
      },

      coverageReporter: {
        reporters: [
          {
            type : 'html',
            dir : 'build/coverage/',
            subdir: 'html'
          },
          {
            type: 'cobertura',
            dir: 'build/coverage',
            subdir: 'xml'
          },
          {
            type: 'json',
            dir: 'build/coverage',
            subdir: 'json'
          },
          {
            type: 'text-summary'
          }
        ]
      }
    });
  };<commit_msg>Update 'karma' dependencies<commit_after> module.exports = function(config) {
    "use strict";

    config.set({
      frameworks: ['jasmine', 'fixture'],

      singleRun: true,

      browsers: ['Firefox', 'Chrome'],

      files: [
        // PhantomJS polyfill
        'node_modules/phantomjs-polyfill/bind-polyfill.js',

        // Vendor files
        'node_modules/vis/dist/vis.js',
        'node_modules/jquery/dist/jquery.js',
        'node_modules/jasmine-jquery/lib/jasmine-jquery.js',

        // Helper files

        // Fixtures
        { pattern: 'src/test/fixtures/html/*.html',
          watched: true,
          served:  true,
          included: false },

        /*{ pattern: 'src/test/fixtures/json/*.json',
          watched: true,
          served:  true,
          included: false },*/

        // Source code
        'src/js/Calendar.js',

        // Spec files
        'src/test/js/*Spec.js'
      ],

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

      exclude: [
        'src/js/main.js'
      ],

      plugins: [
        'karma-jasmine',
        'karma-firefox-launcher',
        'karma-chrome-launcher',
        'karma-phantomjs-launcher',
        'karma-fixture',
        'karma-junit-reporter',
        'karma-coverage'
      ],

      reporters: ['progress', 'junit', 'coverage'],

      junitReporter: {
        outputDir: 'build/test-reports'
      },

      coverageReporter: {
        reporters: [
          {
            type : 'html',
            dir : 'build/coverage/',
            subdir: 'html'
          },
          {
            type: 'cobertura',
            dir: 'build/coverage',
            subdir: 'xml'
          },
          {
            type: 'json',
            dir: 'build/coverage',
            subdir: 'json'
          },
          {
            type: 'text-summary'
          }
        ]
      }
    });
  };<|endoftext|>


<commit_before>module.exports = config => {
  const browser = process.env.BROWSER || 'chrome';

  config.set({
    basePath: '',
    frameworks: ['browserify', 'jasmine'],
    files: [
      'https://static.opentok.com/v2/js/opentok.js',
      'test/**/*.js'
    ],
    preprocessors: {
      'src/**/*.js': ['babel', 'browserify'],
      'test/**/*.js': ['babel', 'browserify']
    },
    browserify: {
      debug: true,
      transform: [
        ['babelify']
      ],
      configure: bundle => {
        bundle.on('prebundle', () => {
          bundle.external('react/addons');
          bundle.external('react/lib/ReactContext');
          bundle.external('react/lib/ExecutionEnvironment');
        });
      }
    },
    reporters: ['spec'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: [browser[0].toUpperCase() + browser.substr(1)],
    singleRun: false
  });
};
<commit_msg>Use debug logs in karma<commit_after>module.exports = config => {
  const browser = process.env.BROWSER || 'chrome';

  config.set({
    basePath: '',
    frameworks: ['browserify', 'jasmine'],
    files: [
      'https://static.opentok.com/v2/js/opentok.js',
      'test/**/*.js'
    ],
    preprocessors: {
      'src/**/*.js': ['babel', 'browserify'],
      'test/**/*.js': ['babel', 'browserify']
    },
    browserify: {
      debug: true,
      transform: [
        ['babelify']
      ],
      configure: bundle => {
        bundle.on('prebundle', () => {
          bundle.external('react/addons');
          bundle.external('react/lib/ReactContext');
          bundle.external('react/lib/ExecutionEnvironment');
        });
      }
    },
    reporters: ['spec'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_DEBUG,
    autoWatch: true,
    browsers: [browser[0].toUpperCase() + browser.substr(1)],
    singleRun: false
  });
};
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Mon Jun 22 2015 10:34:42 GMT+0200 (CEST)

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: ['mocha'],

    // list of files / patterns to load in the browser
    files: [
      'spendb/static/vendor/moment/moment.js',
      'spendb/static/vendor/speakingurl/speakingurl.min.js',
      'spendb/static/vendor/angular/angular.js',
      'spendb/static/vendor/angular-route/angular-route.js',
      'spendb/static/vendor/angular-moment/angular-moment.js',
      'spendb/static/vendor/angular-scroll/angular-scroll.js',
      'spendb/static/vendor/angular-cookies/angular-cookies.js',
      'spendb/static/vendor/angular-ui-select/dist/select.js',
      'spendb/static/vendor/angular-truncate/src/truncate.js',
      'spendb/static/vendor/ng-file-upload/ng-file-upload-shim.js',
      'spendb/static/vendor/ng-file-upload/ng-file-upload.js',
      'spendb/static/vendor/angular-bootstrap/ui-bootstrap-tpls.min.js',
      'spendb/static/vendor/angular-cubes/build/angular-cubes.js',
      'node_modules/angular-mocks/angular-mocks.js',
      'spendb/tests/js/helper.js',
      'spendb/static/js/app.js',
      'spendb/static/js/**/*.js',
      'spendb/tests/js/**/*Spec.js'
    ],

    // list of files to exclude
    exclude: [
      '**/*.swp'
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    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
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['PhantomJS'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  });
};
<commit_msg>Add chai and sinon chai to karma frameworks<commit_after>// Karma configuration
// Generated on Mon Jun 22 2015 10:34:42 GMT+0200 (CEST)

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: ['mocha','chai', 'sinon-chai'],

    // list of files / patterns to load in the browser
    files: [
      'spendb/static/vendor/moment/moment.js',
      'spendb/static/vendor/speakingurl/speakingurl.min.js',
      'spendb/static/vendor/angular/angular.js',
      'spendb/static/vendor/angular-route/angular-route.js',
      'spendb/static/vendor/angular-moment/angular-moment.js',
      'spendb/static/vendor/angular-scroll/angular-scroll.js',
      'spendb/static/vendor/angular-cookies/angular-cookies.js',
      'spendb/static/vendor/angular-ui-select/dist/select.js',
      'spendb/static/vendor/angular-truncate/src/truncate.js',
      'spendb/static/vendor/ng-file-upload/ng-file-upload-shim.js',
      'spendb/static/vendor/ng-file-upload/ng-file-upload.js',
      'spendb/static/vendor/angular-bootstrap/ui-bootstrap-tpls.min.js',
      'spendb/static/vendor/angular-cubes/build/angular-cubes.js',
      'node_modules/angular-mocks/angular-mocks.js',
      'spendb/tests/js/helper.js',
      'spendb/static/js/app.js',
      'spendb/static/js/**/*.js',
      'spendb/tests/js/**/*Spec.js'
    ],

    // list of files to exclude
    exclude: [
      '**/*.swp'
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    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
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['PhantomJS'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  });
};
<|endoftext|>


<commit_before>// ==UserScript==
// @name         Legend Express Agar.io Extension
// @namespace    Legend Express Agario Mod
// @version      1.6
// @description  Agario Mod - Legend,Ogario,Kitty,Old Skins,Animated Skins,Language Packs,Manual User Scripts,Chat,60++ Macros/Hotkeys(Tricksplit,Doublesplit,Quick Feeding,Popsplit,Auto Coins,Freeze Cell Macro,Auto respawn)
// @homepage     http://www.legendmod.ml
// @author       Jimboy3100
// @license      MIT
// @icon         https://jimboy3100.github.io/banners/CropedImage128.gif
// @match        https://agar.io/*
// @match        https://play.google.com/*
// @downloadURL  jimboy3100.github.io/LMexpress/LMexpress.user.js
// @updateURL    jimboy3100.github.io/LMexpress/LMexpress.user.js
// @run-at       document-start
// @grant        GM_xmlhttpRequest
// @connect      jimboy3100.github.io
// ==/UserScript==

// Legend Mod by Jimboy3100
/*MIT License*/

// Check location
if (location.host === "agar.io" && location.pathname === "/") {
    location.href = "https://agar.io/legendmod" + location.hash;
    return;
}
var modVersion = GM_info.script.version;
// Inject Legend
function inject(page) {
    var page = page.replace("", "" + "");
    return page;
}
window.stop();
document.documentElement.innerHTML = "";

GM_xmlhttpRequest({
    method: "GET",
    url: "https://jimboy3100.github.io/LMexpress/LMexpress.html",
    onload: function(legend) {
        var doc = inject(legend.responseText);
        document.open();
        document.write(doc);
        setTimeout(function() {
            window.history.pushState(null, null, "/");
        }, 2000);

        document.close();
    }
});

if (location.host == "play.google.com") {
    window.close();
}
<commit_msg>Update LMexpress.user.js<commit_after>// ==UserScript==
// @name         Legend Express Agar.io Extension
// @namespace    Legend Express Agario Mod
// @version      1.6
// @description  Agario Mod - Legend,Ogario,Kitty,Old Skins,Animated Skins,Language Packs,Manual User Scripts,Chat,60++ Macros/Hotkeys(Tricksplit,Doublesplit,Quick Feeding,Popsplit,Auto Coins,Freeze Cell Macro,Auto respawn)
// @homepage     http://www.legendmod.ml
// @author       Jimboy3100
// @license      MIT
// @icon         https://jimboy3100.github.io/banners/CropedImage128.gif
// @match        https://agar.io/*
// @match        https://play.google.com/*
// @downloadURL  jimboy3100.github.io/LMexpress/LMexpress.user.js
// @updateURL    jimboy3100.github.io/LMexpress/LMexpress.user.js
// @run-at       document-start
// @grant        GM_xmlhttpRequest
// @connect      jimboy3100.github.io
// ==/UserScript==

// Legend Mod by Jimboy3100
/*MIT License*/

// Check location
if (location.host === "agar.io" && location.pathname === "/") {
    location.href = "https://agar.io/legendmod" + location.hash;
    return;
}
var modVersion = GM_info.script.version;
// Inject Legend
function inject(page) {
    var page = page.replace("", "" + "");
    return page;
}
window.stop();
document.documentElement.innerHTML = "";

GM_xmlhttpRequest({
    method: "GET",
    url: "https://jimboy3100.github.io/LMexpress/LMexpress.html",
    onload: function(legend) {
        var doc = inject(legend.responseText);
        document.open();
        document.write(doc);
        setTimeout(function() {
            window.history.pushState(null, null, "/");
        }, 2000);

        document.close();
    }
});

if (location.host == "play.google.com") {
    window.close();
}

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}

<|endoftext|>


<commit_before>import React, { Component } from "react";
import cx from 'classnames';

// Main
import './styles';
import config from './config'
import connect from './connect'

// Other
import {
    Icon,
    Circle,
    Tooltip,
    CircleSpinner as Spinner,
    Button,
    MasonryGrid,
    Line
} from '~/components';

import {
    NoSearchResults,
    BoardMetadata,
    BoardSpinner
} from './components';
import {
    BoardPost as Post,
    BoardToolbar as Toolbar,
    BoardHeader
} from './assemblies';

import {
    emitThreadOpen, emitHeaderExpand, emitHeaderShrink,
    onAppReady, onSettingsToggle, onBoardReset
} from '~/events'

import {throttleByCount, invokeAfterUninterruptedDelay} from '~/utils/throttle';
import {isDefined} from '~/utils/types'

const s = window.appSettings

export class Board extends Component {

    constructor(props) {
        super(props);

        this.onScroll = throttleByCount(7, this.handleScroll);
        this.previousScrollTop = 0;

        this.applyLayout = MasonryGrid(
            props.isDrawerOpen
                ? config.masonryGridWithDrawer
                : config.masonryGrid
        );

        this.isSubheaderExpanded =
            isDefined(props.isSubheaderExpanded)
                 ? props.isSubheaderExpanded
                 : true;
    }

    @onBoardReset
    onBoardReset() {
        this.scrollToTop({duration: 0})
        emitHeaderExpand()
    }

    @onAppReady
    onAppReady() {
        this.revealPostsPartiallyInView();
    }

    @onSettingsToggle
    onSettingsToggle(isDrawerOpen) {
        this.applyLayout = MasonryGrid(
            isDrawerOpen
                ? config.masonryGridWithDrawer
                : config.masonryGrid
        );
        this.applyLayout()
        setTimeout(this.revealPostsInView, 400);
    }

    componentDidMount() {
        // Board scroller
        this.updateScroller(config.nano);

        const onWindowResize =
            // Must be in callback because this.applyLayout changes
            invokeAfterUninterruptedDelay(50, () => this.applyLayout())

        $(window).resize(onWindowResize)

        // Hover over board posts reveals more info
        // catchTooltip(board);  // TODO: Implement catchtooltip on board
    }

    componentWillUpdate({ posts }) {
        if (posts !== this.props.posts) {
            this.onPostsChange();
        }
    }

    componentDidUpdate({ posts }) {
        if (posts !== this.props.posts) {
            this.applyLayout();
            setTimeout(this.revealPostsPartiallyInView, 200);
        }
    }

    componentWillUnmount() {
        this._board.off();
    }

    render() {
        const { posts, isFetching, statistics, searchBoard } = this.props;

        const boardClasses = cx('Board', 'nano', {
            'disable-animations': this.props.isBeingSearched
        })

        const createdPosts = this.createPosts();

        return (

 this._board = $(b)}>

                    {/*
                    <Toolbar
                        posts={posts}
                        statistics={statistics}
                        onSearch={searchBoard}
                    />
                    */}
                    <BoardHeader
                        onSearch={this.handleSearch}
                    />
                    <BoardMetadata
                        postsShown={createdPosts.length}
                        totalPosts={posts.length}
                        totalImages={statistics.images}
                        totalReplies={statistics.replies}
                    />

 this._postContainer = x}>
                        {isFetching && !posts.length &&
                            <BoardSpinner />}
                        {createdPosts}

        );
    }

    createPosts() {
        var pageNum;

        return this.getPosts().map(
            (post, index) => {
                if (post.page !== pageNum) {
                    pageNum = post.page
                }
                return <Post
                    className={index < 10 ? "animate" : ""}
                    key={post.id}
                    post={post}
                    onClick={() => this.handlePostClick(post.id)}
                />
            }
        );
    }

    // updateScrollTop({ scrollTop, scrollHeight }) {
    //     this.setState({
    //         scrollTop,
    //         threadHeight: scrollHeight,
    //     })
    // }

    onPostsChange() {
        this.resetBoard();
        setTimeout(this.revealPostsPartiallyInView, 400)
    }

    handleScroll = (e) => {
        e.stopPropagation();
        this.revealPostsPartiallyInView();
        this.emitScroll(e)
    }

    emitScroll(e) {
        const canExpandHeader = e.target.scrollTop < config.scroll.headerToggleOffset;

        if (this.isSubheaderExpanded === canExpandHeader) {
            return
        }

        console.log("Board -> canExpandHeader:", canExpandHeader)
        canExpandHeader ? emitHeaderExpand() : emitHeaderShrink();

        this.isSubheaderExpanded = canExpandHeader;
    }

    revealPostsInView = () => {
        if (!this._postContainer)
            return

        const toloratedHeight = window.innerHeight + 250;
        $.each(this._postContainer.children, function(index, element) {
            if (element.getBoundingClientRect().bottom <= toloratedHeight) {
                element.classList.add('animate');
            } else {
                return false
            }
        })
    }

    revealPostsPartiallyInView = () => {
        if (!this._postContainer)
            return

        const toloratedHeight = window.innerHeight;
        $.each(this._postContainer.children, function(index, element) {
            if (element.getBoundingClientRect().top < toloratedHeight) {
                element.classList.add('animate');
            }
        })
    }

    getPosts() {
        const { isBeingSearched, isFiltered } = this.props;

        if (isBeingSearched) {
            setTimeout(this.resetBoard, 300);
            return this.props.postsBySearchTerm
        }

        if (isFiltered) {
            return this.props.postsByFilterTerm
        }

        return this.props.posts
    }

    resetBoard = () => {
        // Reshuffle posts and scroll to top of container
        this.updateScroller({ scroll:"top" });
        this.applyLayout();
        this.revealPostsPartiallyInView();
        this._board.trigger('scroll');
    }

    handlePostClick = (threadID) => {
        // Fetch if user not highlighting any text
        if (!window.getSelection().toString()) {
            const { boardID, fetchThread, scrollHeader } = this.props;
            // always close subheader while fetching thread
            emitHeaderShrink();

            fetchThread({
                threadID,
                boardID: boardID,
                callback: emitThreadOpen
            });
        }
    }

    updateScroller(args) {
        this._board.nanoScroller(args);
    }

    scrollToTop = (options) => {
        options = options || {
            duration: 1000,
            easing: 'ease',
            mobileHA: false
        }

        const $scrollArea = this._board.find('.nano-content');
        const $firstChild = $scrollArea.find(">:first-child");

        options.container = $scrollArea

        return this.scrollTo($firstChild, options);
    }

    scrollTo (element, options) {
        return element.velocity("scroll", options)
    }

    handleSearch = (searchValue) => {
        console.log("Board.handleSearch:", searchValue)
        // Change class
        if (searchValue === "") {
            // remove animation-disabling class from board
            this._board.removeClass('disable-animations')
        } else {
            // add animation-disabling class from board
            this._board.addClass('disable-animations')
        }

        this.props.searchBoard(searchValue);
        !searchValue && setTimeout(this.applyLayout, 200)

    }
}

export default connect(Board)
<commit_msg>refactor(Board): Update scroll logic<commit_after>import React, { Component } from "react";
import cx from 'classnames';

// Main
import './styles';
import config from './config'
import connect from './connect'

// Other
import {
    Icon,
    Circle,
    Tooltip,
    CircleSpinner as Spinner,
    Button,
    MasonryGrid,
    Line
} from '~/components';

import {
    NoSearchResults,
    BoardMetadata,
    BoardSpinner
} from './components';
import {
    BoardPost as Post,
    BoardToolbar as Toolbar,
    BoardHeader
} from './assemblies';

import {
    emitThreadOpen, emitHeaderExpand, emitHeaderShrink,
    onAppReady, onSettingsToggle, onBoardReset
} from '~/events'

import {throttleByCount, invokeAfterUninterruptedDelay} from '~/utils/throttle';
import {isDefined} from '~/utils/types'

const s = window.appSettings

export class Board extends Component {

    constructor(props) {
        super(props);

        this.onScroll = throttleByCount(7, this.handleScroll);
        this.previousScrollTop = 0;

        this.applyLayout = MasonryGrid(
            props.isDrawerOpen
                ? config.masonryGridWithDrawer
                : config.masonryGrid
        );

        this.isSubheaderExpanded =
            isDefined(props.isSubheaderExpanded)
                 ? props.isSubheaderExpanded
                 : true;
    }

    @onBoardReset
    onBoardReset(duration=0) {
        this.scrollToTop({ duration, complete: emitHeaderExpand})
    }

    @onAppReady
    onAppReady() {
        this.revealPostsPartiallyInView();
    }

    @onSettingsToggle
    onSettingsToggle(isDrawerOpen) {
        this.applyLayout = MasonryGrid(
            isDrawerOpen
                ? config.masonryGridWithDrawer
                : config.masonryGrid
        );
        this.applyLayout()
        setTimeout(this.revealPostsInView, 400);
    }

    componentDidMount() {
        // Board scroller
        this.updateScroller(config.nano);

        const onWindowResize =
            // Must be in callback because this.applyLayout changes
            invokeAfterUninterruptedDelay(50, this.applyLayout)

        $(window).resize(onWindowResize)

        // Hover over board posts reveals more info
        // catchTooltip(board);  // TODO: Implement catchtooltip on board
    }

    componentWillUpdate({ posts }) {
        if (posts !== this.props.posts) {
            this.onPostsChange();
        }
    }

    componentDidUpdate({ posts }) {
        if (posts !== this.props.posts) {
            this.applyLayout();
            setTimeout(this.revealPostsPartiallyInView, 200);
        }
    }

    componentWillUnmount() {
        this._board.off();
    }

    render() {
        const { posts, isFetching, statistics, searchBoard } = this.props;

        const boardClasses = cx('Board', 'nano', {
            'disable-animations': this.props.isBeingSearched
        })

        const createdPosts = this.createPosts();

        return (

 this._board = $(b)}>

                    {/*
                    <Toolbar
                        posts={posts}
                        statistics={statistics}
                        onSearch={searchBoard}
                    />
                    */}
                    <BoardHeader
                        onSearch={this.handleSearch}
                    />
                    <BoardMetadata
                        postsShown={createdPosts.length}
                        totalPosts={posts.length}
                        totalImages={statistics.images}
                        totalReplies={statistics.replies}
                    />

 this._postContainer = x}>
                        {isFetching && !posts.length &&
                            <BoardSpinner />}
                        {createdPosts}

        );
    }

    createPosts() {
        var pageNum;

        return this.getPosts().map(
            (post, index) => {
                if (post.page !== pageNum) {
                    pageNum = post.page
                }
                return <Post
                    className={index < 10 ? "animate" : ""}
                    key={post.id}
                    post={post}
                    onClick={() => this.handlePostClick(post.id)}
                />
            }
        );
    }

    // updateScrollTop({ scrollTop, scrollHeight }) {
    //     this.setState({
    //         scrollTop,
    //         threadHeight: scrollHeight,
    //     })
    // }

    onPostsChange() {
        this.resetBoard();
        setTimeout(this.revealPostsPartiallyInView, 400)
    }

    handleScroll = (e) => {
        e.stopPropagation();
        this.revealPostsPartiallyInView();
        this.emitScroll(e)
    }

    emitScroll(e) {
        const canExpandHeader = e.target.scrollTop < config.scroll.headerToggleOffset;

        if (this.isSubheaderExpanded === canExpandHeader) {
            return
        }

        console.log("Board -> canExpandHeader:", canExpandHeader)
        canExpandHeader ? emitHeaderExpand() : emitHeaderShrink();

        this.isSubheaderExpanded = canExpandHeader;
    }

    revealPostsInView = () => {
        if (!this._postContainer)
            return

        const toloratedHeight = window.innerHeight + 250;
        $.each(this._postContainer.children, function(index, element) {
            if (element.getBoundingClientRect().bottom <= toloratedHeight) {
                element.classList.add('animate');
            } else {
                return false
            }
        })
    }

    revealPostsPartiallyInView = () => {
        if (!this._postContainer)
            return

        const toloratedHeight = window.innerHeight;
        $.each(this._postContainer.children, function(index, element) {
            if (element.getBoundingClientRect().top < toloratedHeight) {
                element.classList.add('animate');
            }
        })
    }

    getPosts() {
        const { isBeingSearched, isFiltered } = this.props;

        if (isBeingSearched) {
            setTimeout(this.resetBoard, 300);
            return this.props.postsBySearchTerm
        }

        if (isFiltered) {
            return this.props.postsByFilterTerm
        }

        return this.props.posts
    }

    resetBoard = () => {
        // Reshuffle posts and scroll to top of container
        this.updateScroller({ scroll:"top" });
        this.applyLayout();
        this.revealPostsPartiallyInView();
        this._board.trigger('scroll');
    }

    handlePostClick = (threadID) => {
        // Fetch if user not highlighting any text
        if (!window.getSelection().toString()) {
            const { boardID, fetchThread, scrollHeader } = this.props;
            // always close subheader while fetching thread
            emitHeaderShrink();

            fetchThread({
                threadID,
                boardID: boardID,
                callback: emitThreadOpen
            });
        }
    }

    updateScroller(args) {
        this._board.nanoScroller(args);
    }

    scrollToTop = (options) => {
        options = Object.assign({}, {
            duration: 1000,
            easing: 'ease-in-out',
            mobileHA: false
        }, options)

        const $scrollArea = this._board.find('.nano-content');
        const $firstChild = $scrollArea.find(">:first-child");

        options.container = $scrollArea

        return this.scrollTo($firstChild, options);
    }

    scrollTo (element, options) {
        return element.velocity("scroll", options)
    }

    handleSearch = (searchValue) => {
        console.log("Board.handleSearch:", searchValue)
        // Change class
        if (searchValue === "") {
            // remove animation-disabling class from board
            this._board.removeClass('disable-animations')
        } else {
            // add animation-disabling class from board
            this._board.addClass('disable-animations')
        }

        this.props.searchBoard(searchValue);
        !searchValue && setTimeout(this.applyLayout, 200)

    }
}

export default connect(Board)
<|endoftext|>