const fs = require('fs');
const path = require('path');
const fileUrl = require('file-url');
const failFast = require('protractor-fail-fast');

const failFastActive = (process.argv.length > 4 && process.argv[4] == '--params=ff');

exports.config = {

    seleniumAddress: 'http://localhost:9515/wd/hub',
    baseUrl: fileUrl(path.resolve(__dirname, '../../..') + '/index.html'),

    suites: {
        default: [
            '../settings/*.spec.js',
            '../syncing/*.spec.js',
            '../images/*.spec.js',
            '../list/*.spec.js',
            '../resources/*.spec.js',
            '../map/*.spec.js',
            '../widgets/*.spec.js',
            '../import/*.spec.js'
        ],
        flaky: [
            '../flaky/*.spec.js'
        ]
    },

    allScriptsTimeout: 110000,
    getPageTimeout: 100000,
    framework: 'jasmine2',
    jasmineNodeOpts: {
        isVerbose: false,
        showColors: true,
        includeStackTrace: false,
        defaultTimeoutInterval: 400000
    },
    plugins: [{
        package: 'protractor-console-plugin',
        failOnWarning: true,
        failOnError: true,
        logWarnings: true,
        exclude: [
            "http://localhost:3001/" // pouchdb issues ignorable errors when syncing
        ]
    }],
    params: {
        appDataPath: 'test/test-temp',
        configPath: 'config/config.test.json',
        configTemplate: { 'dbs' : ['test'] }
    },
    onPrepare: function() {
        if (failFastActive) jasmine.getEnv().addReporter(failFast.init());

        var ProgressReporter = function() {

            this.specStarted = function(spec) {
                process.stdout.write("SPEC " + spec.fullName + " ")
            };

            this.specDone = function(spec) {
                console.log(spec.status.toUpperCase())
            }
        };
        jasmine.getEnv().addReporter(new ProgressReporter());
    },
    afterLaunch: function() {
        if (failFastActive) failFast.clean();
    },
    /**
     * ng2 related configuration
     *
     * useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
     * `rootEl`
     *
     */
    useAllAngular2AppRoots: true
};

if (failFastActive) exports.config.plugins.push({package: 'protractor-fail-fast'});
@@ -1806,16 +1806,821 @@
 rCase())
+;%0A%0A                browser.manage().logs().get('browser').then(function(browserLogs) %7B%0A%0A                    if (browserLogs.map(function (log)%0A                        %7Breturn log.level.value%7D).filter(function (value) %7B return (value %3E 900)%7D)%0A                        .length %3E 0) %7B%0A%0A                        console.log('There has been at least one browser console error!');%0A%0A                        browserLogs.forEach(function(log)%7B%0A                            if (log.level.value %3E 900) %7B // it's an error log%0A                                console.log(%22===%3E ERROR message: %22,log.message);%0A                            %7D else %7B%0A                                console.log(%22Log message: %22,log.message);%0A                            %7D%0A                        %7D);%0A                    %7D%0A%0A%0A                %7D);%0A
 %0A       

print err including context on console err